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,'OptimizeHyperparameters','auto','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
%%%%%%%%%%%%%%%
It runs for some time and gives error on classificationSVM.
Here Xdata is a 8x4 double. error says X should be a double or a single matrix. How to solve it and the other errors?

5 件のコメント

Walter Roberson
Walter Roberson 2020 年 7 月 24 日
You do not show the code near line 200 where you are calling ClassificationSVM.fit() passing in Feature. We need to more about the datatype of Feature at that line.
anand rathod
anand rathod 2020 年 7 月 24 日
the error says that classificationsvm can take only single or double as data types.
here feature has 'double' data type but svmstruct shows 'classificationsvm' as data type.
error:
Code at line 200:
Walter Roberson
Walter Roberson 2020 年 7 月 24 日
Why are you directly invoking the private ClassificationSVM.fit() instead of calling fitcsvm()? And you appear to be expecting the results to be species indicators but that is not what fit is for, and you would use predict() to use a trained classifier plus input data to estimate species.
Image Analyst
Image Analyst 2020 年 7 月 25 日
If you need more help, attach FA.mat and NF.mat.
anand rathod
anand rathod 2020 年 7 月 25 日
Image Analyst Here,

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

カテゴリ

ヘルプ センター および File ExchangeText Analytics Toolbox についてさらに検索

質問済み:

2020 年 7 月 24 日

コメント済み:

2020 年 7 月 25 日

Community Treasure Hunt

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

Start Hunting!

Translated by