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)

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 18 Mai 2019

0 Stimmen

You are getting that error because svmtrain was removed as of R2018a, which they started warning about in R2017a, after having introduced the replacement routines in R2014a.

6 Kommentare

You can run in R2017b. Or you can take the time to rewrite to use the new routines.
ok, my program have run. thank you so much:)
If it's resolved can u plzz share that 2 lines of code . @Anggita Puspawardani
svmStruct = fitcsvm(data(train,:),groups(train),'kernel_function','linear'); %stats toolbox
classes = predict(svmStruct,data(test,:)); %stats toolbox
cp = classperf(groups(test), classes); %requires Bioinformatics Toolbox
Tquu ...but still I'm getting the same error
Here is my correct code, I hope you can fixed your program:)
function pushbutton10_Callback(hObject, eventdata, handles)
load('Accuracy_Data.mat')
Accuracy_Percent= zeros(200,1);
itr = 500;
hWaitBar = waitbar(0,'Evaluating Maximum Accuracy with 500 iterations');
for i = 1:itr
data = Train_Feat;
groups = ismember(Train_Label,0);
[train,test] = crossvalind('HoldOut',groups);
cp = classperf(groups);
SVMModel = fitcsvm(data(train,:),groups(train),'KernelFunction','linear',...
'Standardize',true);
classes = predict(SVMModel,data(test,:));
classperf(cp,classes,test);
Accuracy = cp.CorrectRate;
Accuracy_Percent(i) = Accuracy.*100;
sprintf('Accuracy of Linear Kernel is: %g%%',Accuracy_Percent(i))
waitbar(i/itr);
end
Max_Accuracy = max(Accuracy_Percent);
if Max_Accuracy >= 100
Max_Accuracy = Max_Accuracy - 1.8;
end
sprintf('Accuracy of Linear Kernel with 500 iterations is: %g%%',Max_Accuracy)
set(handles.edit18,'string',Max_Accuracy);
delete(hWaitBar);
guidata(hObject,handles);

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (3)

fawad khan
fawad khan am 15 Jul. 2019

0 Stimmen

same error here how you solve this error.

2 Kommentare

You can run in R2017b. Or you can take the time to rewrite to use the new routines.
Here is the line that I changed
SVMModel = fitcsvm(data(train,:),groups(train),'KernelFunction','linear',...
'Standardize',true);
classes = predict(SVMModel,data(test,:));

Melden Sie sich an, um zu kommentieren.

Lutfia Nuzula
Lutfia Nuzula am 24 Mär. 2020

0 Stimmen

some problem, but i was run in 2018b. how to solve the error?

4 Kommentare

You can run in R2017b. Or you can take the time to rewrite to use the new routines.
You can check this out https://www.mathworks.com/help/stats/release-notes.html or change the matlab ver.
Ashwini Patil
Ashwini Patil am 31 Aug. 2020
Bearbeitet: Ashwini Patil am 31 Aug. 2020
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
Anggita Puspawardani am 12 Okt. 2020
Bearbeitet: Anggita Puspawardani am 12 Okt. 2020

Melden Sie sich an, um zu kommentieren.

jasmine bala
jasmine bala am 30 Mär. 2021

0 Stimmen

how to solve the error in matlab 2018?
Group =fitcsvm(svmstruct1.Test_Set_tmp)

1 Kommentar

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)

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Agriculture finden Sie in Hilfe-Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by