Nearest Neighbor Algorithm Help!
古いコメントを表示
Hey, so I'm struggling trying to find how to use the nearest neighbor algorithm (yes, NOT the command)in order to organize a group of 2000 points into either class 1 or class 2. I plan on using the norm and sort command to accomplish this, with the input of k determining the size of the neighborhood. Please tell me what I can do to fix this script!! Attached are the data points.
data=load('NN.dat'); [rows,cols]=size('data') class1=data([1:2:500],:),1 class2=data([2:2:500],:),2 x=norm(class1-class2)
if class1>x label=2 end if class1<x label(class1)=1 end if class1>x label(class1)=2 end if class2<x label(class2)=2 end tradata=zeros(1000,3); tradata(:,1:2)=filedata(1:1000,:); tradata([1:2:1000],3)=1; tradata([2:2:1000],3)=2;
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Nearest Neighbors についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!