test data using knn
Afficher commentaires plus anciens
Hi, I am using the algorithm of the nearest neighbor in my project, and I did the training process for the data stored in (data) .. Also, I have an matrix (A) size 24 * 80 and I want to use it in the test to get the value of accuracy
help me please
this is my code but need change
v2=[];
for i=1: num_sample %change here for the number of people in database
for j=21:39 %change here for the number of images per person
v2=[v2; reshape(double(imresize(dat{i,j},[10, 8])), m1*n1, 1)'];
%Temp=zeros(1,num_sample);
%Temp(1,i)=1;
Temp=i;
T2=[T2;Temp];
end
end
TestSet=v2;
TrainSet=v;
TrainSet_y=T;
TestSet_y=T2;
k=7;
Class = knnclassify(TestSet,TrainSet,TrainSet_y,k);
C=confusionmat(TestSet_y,Class);
acc_of_knn=sum(diag(C))/sum(C(:));
acc_of_knn=acc_of_knn*100
Réponses (0)
Catégories
En savoir plus sur Nearest Neighbors dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!