I have an error with training SVM in Matlab. is there anyone can help me?

3 ビュー (過去 30 日間)
Vania krm
Vania krm 2019 年 1 月 18 日
コメント済み: Walter Roberson 2019 年 1 月 19 日
clear all
clc
ds=dataset('xlsfile','AD.xlsx');
feat1=ds.beta2L(1:100);
feat=ds.beta2T(1:100);
segmented_features = cell(1,3);
segmented_features =[feat1, feat];
[cA1,cH1,cV1,cD1] = dwt2(segmented_features,'db4');
[cA2,cH2,cV2,cD2] = dwt2(cA1,'db4');
[cA3,cH3,cV3,cD3] = dwt2(cA2,'db4');
DWT_feat = [cA3,cH3,cV3,cD3];
G = pca(DWT_feat);
whos DWT_feat
whos G
load trainset
xdata = meas;
group = label;
%svmStruct = svmtrain(xdata,group,'showplot',false);
% species = svmclassify(svmStruct,feat)
svmStruct1 = svmtrain(xdata,group,'kernel_function', 'linear');
species = svmclassify(svmStruct1,feat,'showplot',false);
classperf(cp,classes,test);
Accuracy_Classification = cp.CorrectRate.*100;
sprintf('Accuracy of Linear kernel is: %g%%',Accuracy_Classification)
**********************
Error using svmtrain (line 236)
Y must be a vector or a character array.
Error in newcodewithoutkmeans (line 22)
svmStruct1 = svmtrain(xdata,group,'kernel_function', 'linear');
  5 件のコメント
Vania krm
Vania krm 2019 年 1 月 19 日
Yes. Now my problem is solved. Very very thanks of your help. Just can I ask you that I use this code for accuracy based on Matlab codes of site but I have different accuracy in each time of run. How do I mention the final accuracy of system?
% Multiple runs for accuracy highest is 90%
groups = ismember(label,'AD ');
groups = ismember(label,'Nold');
[train,test] = crossvalind('HoldOut',groups);
cp = classperf(groups);
svmStruct = svmtrain(xdata(train,:),groups(train),'showplot',false,'kernel_function','linear');
classes = svmclassify(svmStruct,xdata(test,:),'showplot',false);
classperf(cp,classes,test);
Accuracy_Classification = cp.CorrectRate.*100;
sprintf('Accuracy of Linear kernel is: %g%%',Accuracy_Classification)
Walter Roberson
Walter Roberson 2019 年 1 月 19 日
svmtrain uses random partitions . You would need to set the random seed to repeat the same results .

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

回答 (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