SVM train and Classification Errors

2 views (last 30 days)
Krishna Ganesh
Krishna Ganesh on 22 Apr 2019
Answered: Furkan DEMIR on 10 Dec 2020
Hello Everyone im getting this weird error while im using svm train and classificationSvm. Need some help fixing it as i am new to this
Code Block: load Trainset.mat
xdata = meas;
group = label;
svmStruct = fitcsvm(xdata,group,'HyperparameterOptimizationOptions', struct('showplot',true), 'KernelFunction','rbf','KernelScale',0.5);
species = ClassificationSVM(svmStruct,feat,'showplot',true);
if strcmpi(species,'MALIGNANT')
helpdlg(' Malignant Tumor ');
disp(' Malignant Tumor ');
else
helpdlg(' Benign Tumor ');
disp(' Benign Tumor ');
end
set(handles.edit18,'string', species);
and the errors are
Error using ClassificationSVM (line 249)
Use fitcsvm to train an SVM model.
Error in untitled2>pushbutton12_Callback (line 615)
species = ClassificationSVM(svmStruct,feat,'showplot',true);
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in untitled2 (line 42)
gui_mainfcn(gui_State, varargin{:});
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)untitled2('pushbutton12_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback.
Anybody has any idea in what im doing wrong? any help will be appreciated :)

Answers (2)

Alan Weiss
Alan Weiss on 23 Apr 2019
Try removing the line
species = ClassificationSVM(svmStruct,feat,'showplot',true);
To learn how to use the resulting SVM, see the documentation for fitcsvm.
Alan Weiss
MATLAB mathematical toolbox documentation

Furkan DEMIR
Furkan DEMIR on 10 Dec 2020
Hello.
load Trainset.mat has two file. one of these meas and label.
When I see meas files. I saw 20*13 matrix. what is the meaning. Why the file is 20*13 matrix

Community Treasure Hunt

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

Start Hunting!