convert knnclassify to fitcknn
Mostrar comentarios más antiguos
please help me to convert knnclassify to fitcknn
x=readtable("datatraining.xlsx");
latih=x;
group=latih(:,3);
latih = [latih(:,1) latih(:,2)];
for i = 1 : 80
y=readtable("datatesting.xlsx");
sampel = y;
test = [sampel(:,1) sampel(:,2)];
%sampel = [2.6136 0.1284 1.3017 -0.8089 0.0441 -0,2084];
hasil=knnclassify(test,latih,group);
end
nama = "hasil KNN.xlsx";
hasil = [sampel(:,1) sampel(:,2) sampel(:,3) hasil];
xlswrite(nama,hasil);
7 comentarios
Walter Roberson
el 4 de Mayo de 2021
Do not read files inside a loop -- not unless you are reading a different file each time.
The body of your loop does not use i, so you are doing the same thing each iteration.
Frisda Sianipar
el 5 de Mayo de 2021
Walter Roberson
el 5 de Mayo de 2021
x=readtable("datatraining.xlsx");
y=readtable("datatesting.xlsx");
latih=x;
group=latih(:,3);
latih = [latih(:,1) latih(:,2)];
for i = 1 : 80
sampel = y;
test = [sampel(:,1) sampel(:,2)];
%sampel = [2.6136 0.1284 1.3017 -0.8089 0.0441 -0,2084];
hasil=knnclassify(test,latih,group);
end
nama = "hasil KNN.xlsx";
hasil = [sampel(:,1) sampel(:,2) sampel(:,3) hasil];
xlswrite(nama,hasil);
except rewritten to use fitcknn as discussed in your other postings.
Frisda Sianipar
el 5 de Mayo de 2021
Walter Roberson
el 5 de Mayo de 2021
Why did you go back to knnclassify() ? You were given conversion information at https://www.mathworks.com/matlabcentral/answers/505383-how-can-i-convert-knnclassify-to-fitcknn#comment_1500660
Frisda Sianipar
el 6 de Mayo de 2021
Walter Roberson
el 6 de Mayo de 2021
And I already answered you at https://www.mathworks.com/matlabcentral/answers/505383-how-can-i-convert-knnclassify-to-fitcknn#comment_1502310
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


