フィルターのクリア

test data using knn

2 ビュー (過去 30 日間)
OO_98
OO_98 2020 年 5 月 28 日
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

回答 (0 件)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by