フィルターのクリア

How to use fitcknn for multiple classes?

1 回表示 (過去 30 日間)
Muhammad Kashif
Muhammad Kashif 2018 年 9 月 27 日
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 件のコメント
fatin suhana mohd khidzir
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
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 ExchangeStatistics and Machine Learning Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by