登录
首页 » Matlab » matlab实现的的knn分类器 有训练样本和测试样本

matlab实现的的knn分类器 有训练样本和测试样本

于 2022-03-10 发布 文件大小:1.71 kB
0 85
下载积分: 2 下载次数: 2

代码说明:

clear;clc;ticload data.txt;a=data(1:30,1:4);aa=data(31:50,1:4);b=data(51:80,1:4);bb=data(81:100,1:4);c=data(101:130,1:4);cc=data(131:150,1:4);train_sample=cat(1,a,b,c);%组成训练样本(90*4)test_sample=cat(1,aa,bb,cc);%组成测试样本(60*4)k=5;cha=zeros(1,90);sum=0;[i,j]=size(train_sample);[u,v]=size(test_sample);for x=1:u    for y=1:i        result=sqrt((test_sample(x,1)-train_sample(y,1)).^2+(test_sample(x,2)-train_sample(y,2)).^2+(test_sample(x,3)-train_sample(y,3)).^2+(test_sample(x,4)-train_sample(y,4)).^2);        cha(1,y)=result;    end;    [z,ind]=sort(cha);    m1=0;    m2=0;    m3=0;    for n=1:k        if ind(1,n)

下载说明:请别用迅雷下载,失败请重下,重下不扣分!

发表评论

0 个回复

  • imageBin
    图像转换成二进制序列、二进制序列还原成图像MatlaB自编源代码(Image is converted into binary sequences, binary sequence to restore self-compiled source code into an image MatlaB)
    2021-02-06 21:19:56下载
    积分:1
  • testrun3_kmltomatlab
    converse data from kml file to matlab
    2013-05-21 17:53:18下载
    积分:1
  • 123
    融合程序,matlab的源代码。内含两个程序。(Fusion program, Matlab source code. Contains two procedures.)
    2012-06-09 10:23:51下载
    积分:1
  • APF
    有源电力滤波器的仿真研究,基于瞬时无功功率理论的谐波检测。(Simulation Research on active power filter, harmonic detection based on instantaneous reactive power theory.)
    2014-11-25 10:38:05下载
    积分:1
  • Final
    Compression DICOM images using different method according to region of interest (ROI)
    2015-02-11 14:11:06下载
    积分:1
  • Subdomain
    加权余量法--子域法求解一维扩散方程。参考书《Computational Techniques for Fluid Dynamics》(The weighted residual Law- sub-domain method for solving one-dimensional diffusion equation. Reference book " Computational Techniques for Fluid Dynamics" )
    2013-05-21 22:15:01下载
    积分:1
  • ompreconstruction
    应用OPM算法对肌电信号、心电信号以及脑电信号进行信号的重构(Using OPM algorithm to reconstruct EMG, ECG and EEG signals)
    2019-04-10 10:30:25下载
    积分:1
  • 签名识别
    %第一,选择输入的图像,单击"选择图像"。 %那么你就可以 %-将该图像添加到数据库 (点击"添加所选图像到数据库" %-执行签名识别 (单击"签名识别"按钮) %注: 如果您想要执行签名识别数据库都有,包括 %至少一个图像。 % 如果您选择将图像添加到数据库 %,一个正整数 (签名 ID) 是 所需的 %。此 posivive 整数是一个逐步的数字标识 %(对应于一类的每一个人) 的人。 例如 %: %-运行 GUI (类型在 Matlab 命令窗口上的"signature_recognition") %-删
    2022-01-21 19:28:59下载
    积分:1
  • 222
    退火算法,能够良好的处理数据,避免局部的最优值,因为添加了遗传算法(Annealing algorithm, can be a good deal of data, to avoid the local optimal value, because of an genetic algorithm)
    2009-09-11 16:19:51下载
    积分:1
  • histogram_graylevel
    contrasting using histogram equalization
    2013-03-14 04:27:01下载
    积分:1
  • 696516资源总数
  • 106914会员总数
  • 0今日下载