why am I getting error when I detect dataset with SVM?
이전 댓글 표시
actually i have problem with method support vector machine (SVM), i didn't detect my dataset in the program.
here is the error:
Error using svmtrain (line 230)
svmtrain has been removed. Use fitcsvm instead.
Error in multisvm (line 28)
svmStruct = svmtrain(T,newClass);
Error in Detect (line 144)
result = multisvm(Train_Feat,Train_Label,test);
here is the code:
% Load All The Features
load('Training_Data.mat')
% Put the test features into variable 'test'
test = feat_disease;
result = multisvm(Train_Feat,Train_Label,test);
%disp(result);
% Visualize Results
if result == 0
helpdlg(' Alternaria Alternata ');
disp(' Alternaria Alternata ');
elseif result == 1
helpdlg(' Anthracnose ');
disp('Anthracnose');
elseif result == 2
helpdlg(' Bacterial Blight ');
disp(' Bacterial Blight ');
elseif result == 3
helpdlg(' Cercospora Leaf Spot ');
disp('Cercospora Leaf Spot');
elseif result == 4
helpdlg(' Healthy Leaf ');
disp('Healthy Leaf ');
end
%% Evaluate Accuracy
load('Accuracy_Data.mat')
Accuracy_Percent= zeros(200,1);
for i = 1:500
data = Train_Feat;
%groups = ismember(Train_Label,1);
groups = ismember(Train_Label,0);
[train,test] = crossvalind('HoldOut',groups);
cp = classperf(groups);
svmStruct = svmtrain(data(train,:),groups(train),'showplot',false,'kernel_function','linear');
classes = svmclassify(svmStruct,data(test,:),'showplot',false);
classperf(cp,classes,test);
Accuracy = cp.CorrectRate;
Accuracy_Percent(i) = Accuracy.*100;
end
Max_Accuracy = max(Accuracy_Percent);
sprintf('Accuracy of Linear Kernel with 500 iterations is: %g%%',Max_Accuracy)
채택된 답변
추가 답변 (3개)
fawad khan
2019년 7월 15일
0 개 추천
same error here how you solve this error.
댓글 수: 2
Walter Roberson
2019년 7월 16일
You can run in R2017b. Or you can take the time to rewrite to use the new routines.
Anggita Puspawardani
2020년 6월 4일
편집: Anggita Puspawardani
2020년 6월 4일
Lutfia Nuzula
2020년 3월 24일
0 개 추천
some problem, but i was run in 2018b. how to solve the error?
댓글 수: 4
Walter Roberson
2020년 3월 25일
You can run in R2017b. Or you can take the time to rewrite to use the new routines.
Anggita Puspawardani
2020년 6월 4일
Ashwini Patil
2020년 8월 31일
편집: Ashwini Patil
2020년 8월 31일
But not properly classify the plant disease ,wrong disease display in window ,plz can i get the right code for proper classify result .
Anggita Puspawardani
2020년 10월 12일
편집: Anggita Puspawardani
2020년 10월 12일
jasmine bala
2021년 3월 30일
0 개 추천
how to solve the error in matlab 2018?
Group =fitcsvm(svmstruct1.Test_Set_tmp)
댓글 수: 1
Walter Roberson
2021년 3월 30일
Code that used svmstruct is almost always written for the earlier SVM functions that MATLAB does not provide any more. Those functions used numeric arrays, and did not permit table objects.
The newer fitcsvm does not accept being passed just a single parameter: it needs one of
- table and name of response variable
- table and "formula" of which variables are related
- numeric data as first parameter, and information about the labels in the second parameter (not necessarily numeric)
카테고리
도움말 센터 및 File Exchange에서 Food Sciences에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!