MATLAB Answers

Can anyone tell me how does this code works?

1 ビュー (過去 30 日間)
anand rathod
anand rathod 2020 年 7 月 23 日
コメント済み: anand rathod 2020 年 7 月 23 日
clc;
clear ;
close all;
%%
load FA
F1 = Feature;
load NF
F2 = Feature;
xdata = [F1;F2];
group = cell(1,1);
for ii = 1:size(F1,1)
group{ii,1} = 'Fatigue';
end
for ii = 1:size(F2,1)
group{ii+size(F1,1),1} = 'Non-Fatigue';
end
svmStruct = fitcsvm(xdata,group,'HyperparameterOptimizationOptions',struct('showplot',true));
% Testing
save svm svmStruct
load svm
for ii = 1:size(F1,1)
species = ClassificationSVM(svmStruct,F1(ii,:));
disp([ group{ii,1} ' = ' species]);
end
for ii = 1:size(F2,1)
species = ClassificationSVM(svmStruct,F2(ii,:));
disp([ group{ii+size(F1,1),1} ' = ' species]);
end
%%%%%%%%%%%%%%%%
I want to figure out specially what happens in the for loops.

  0 件のコメント

サインインしてコメントする。

採用された回答

Neuropragmatist
Neuropragmatist 2020 年 7 月 23 日
Hi,
It is difficult to know exactly what the code is doing without the data files it is loading.
However, at first glance I would guess it trains a machine learning algorithm on a known data set using the fitcsvm function and then it queries this model with unknown values in the for loops using ClassificationSVM.
Have you tried looking at the contents of xdata and group? What about the figure fitcsvm makes when you run the code? Then look at the help pages for these two functions:
With all the information together I'm sure it will make sense to you, if not you can start to ask more specific questions about the functions etc.
NP.

  1 件のコメント

anand rathod
anand rathod 2020 年 7 月 23 日
F1 contains feature data for fatigue (5x4), F2 containd feature data for non fatigue (3x4), Xdata - both , group is a 8x1 cell which contains 5 rows as "fatigue" and 3 rows as "non-fatigue".
fitcsvm is not excuting. I was experiencing errors using svmtrain and svm classify so i changed it to fitcsvm and classificationsvm and some arguments. but it is still not executing. This was the earlier function.
Now after changing it, I am stilll having error

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by