How to use fitcknn for multiple classes?
조회 수: 1 (최근 30일)
이전 댓글 표시
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
- How to use fitcknn or any knn classifier to classify
- along with cross-validation
- and find accuracy precision and recall
- 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
fatin suhana mohd khidzir
2019년 4월 19일
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
2020년 3월 6일
hai fatin and kashif, can you send me the code of emotion recognition to my email syamizalloi@gmail.com.thank you
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Statistics and Machine Learning Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!