Borrar filtros
Borrar filtros

How to use fitcknn for multiple classes?

1 visualización (últimos 30 días)
Muhammad Kashif
Muhammad Kashif el 27 de Sept. de 2018
Comentada: Mohd Syamizal Mohd Isa el 6 de Mzo. de 2020
I am working on facial expression recognition. i made a dataset contain features & classes of 213 images.
  • Step1: Each row of my dataset represents the features of 1 image. so for 213 images 213 rows
  • Step2: the last column represents classes like; 1,2,3,4,5,6,7 i used fitcsvm it gives great results but now i want to use knn.
QUESTIONS
  1. How to use fitcknn or any knn classifier to classify
  2. along with cross-validation
  3. and find accuracy precision and recall
  4. help me with this code
clc;
close all;
data = load(fullfile('.', 'Features', 'jaffe_features.txt'));
% features_train = data(1:128,:);
% features_test = data(128:end,:);
nRows = size(data,1);
randRows = randperm(nRows); % generate random ordering of row indices
features = data(randRows(1:end),:);
labels1 = data(:,end);
[labels] = labels1;
Mdl = fitcknn(features,labels,'NumNeighbors',5,...
'ClassNames',{'1','2','3','4','5','6','7'},'Distance','euclidean', 'Standardize',1);
loss = resubLoss(Mdl);
CVMdl = crossval(Mdl);
classError = kfoldLoss(CVMdl);
label = predict(Mdl,features);
% plot confusion(features_test,idx)
% oofLabel = kfoldPredict(CVMdl);
% ConfMat = confusionmat(labels_test,label);
accuracy=confusionmatStats_2(labels_test,label);
% [m,n]=size(label);
%
% count=0;
% for i=1:m
% if(strcmp(labels_test(i),label(i)))
% count=count+1;
% end
% end
% Regards Regards
  2 comentarios
fatin suhana mohd khidzir
fatin suhana mohd khidzir el 19 de Abr. de 2019
hai..i am doing the same knn and svm classifier as yours for facial expression recognition. can you teach me how to classify the 7 facial expression and label it by using knn and svm? can i have your email to learn futher from you? thank you
Mohd Syamizal Mohd Isa
Mohd Syamizal Mohd Isa el 6 de Mzo. de 2020
hai fatin and kashif, can you send me the code of emotion recognition to my email syamizalloi@gmail.com.thank you

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Statistics and Machine Learning Toolbox en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by