How to correct the error - ClassificationSVM
이전 댓글 표시
My Matlab code -
clear
load fisheriris
% Only use the third and fourth features
x=meas(:,3:4);
gscatter(x(:,1),x(:,2),species);
% Only use the last two categories
x=meas(51:end,3:4);
group=species(51:end,1);
gscatter(x(:,1),x(:,2),group);
% Linear SVM
svmStruct = fitcsvm(x,group,'showplot',true);
% Kernel SVM
svmStruct = fitcsvm(xdata,group,'showplot',true,'kernel_function','rbf');
% Select different sigma
svmStruct = fitcsvm(xdata,group,'showplot',true,'kernel_function','rbf','rbf_sigma',0.5);
But here I get the error message such as below -
Error in fitcsvm (line 316)
obj = ClassificationSVM.fit(X,Y,RemainingArgs{:});
Error in Untitled (line 11)
svmStruct = fitcsvm(x,group,'showplot',true);
채택된 답변
추가 답변 (5개)
댓글 수: 1
Walter Roberson
2018년 6월 17일
Try different settings for the KernelFunction https://www.mathworks.com/help/stats/fitcsvm.html#bt9w6j6_sep_shared-KernelFunction and for the KernelScale and see what the effects are.
댓글 수: 1
Walter Roberson
2018년 6월 17일
Students experimenting is very important for studies.
댓글 수: 6
Walter Roberson
2018년 6월 18일
For some reason the ShowPlots is not resulting in any plotting, so what you are seeing is the output of your second gscatter() at the top.
Note that your second gscatter() is overwriting the output of your first gscatter() so you never see the result of the first gscatter().
Walter Roberson
2018년 6월 18일
Please do not create a new Answer to respond. Instead, click on "Comment on this Answer" to respond.
Walter Roberson
2018년 6월 18일
"I have no time to come here every day and write one or two statements"
But you expect other people to have plenty of time to write your homework for you.
"I think you are not understand my question and problem"
I understood your question. The answer is as I posted: fitcsvm() is not plotting anything. All you are seeing is what you plot with you gscatter() calls.
If the plotting from fitcsvm() was working, then what it would be showing is progress towards finding the best fit.
If you want to plot the results of the fitcsvm, then see https://stackoverflow.com/questions/16146212/how-to-plot-a-hyper-plane-in-3d-for-the-svm-results/19969412#19969412 (credit: https://www.mathworks.com/matlabcentral/answers/73087-how-to-plot-a-hyper-plane-in-3d-for-the-svm-results#answer_140035)
Walter Roberson
2018년 6월 18일
It sounds as if you are calling svm_3d_matlab_vis without passing in any parameters.
Don Mathis
2018년 6월 18일
FITCSVM does not have an argument named 'showplot'. When I run your original code in R2018a I get this:
Error using classreg.learning.FitTemplate/fillIfNeeded (line 612)
showplot is not a valid parameter name.
Error in classreg.learning.FitTemplate.make (line 124)
temp = fillIfNeeded(temp,type);
Error in ClassificationSVM.template (line 235)
temp = classreg.learning.FitTemplate.make('SVM','type','classification',varargin{:});
Error in ClassificationSVM.fit (line 239)
temp = ClassificationSVM.template(varargin{:});
Error in fitcsvm (line 316)
obj = ClassificationSVM.fit(X,Y,RemainingArgs{:});
Error in Untitled3 (line 11)
svmStruct = fitcsvm(x,group,'showplot',true);
댓글 수: 6
Walter Roberson
2018년 6월 18일
svmtrain() had 'showplot' and 'rbf_sigma' -- but svmtrain() has been replaced by fitcsvm. Which unfortunately has a more confusing user interface.
Hui Theng Leong
2019년 5월 2일
I have the same error as the above, could you please provide the workaround for this?
Thank You
Walter Roberson
2019년 5월 2일
As I posted above, you now need to use 'Hyperparameteroptimizationoptions', struct('Showplots', true)
AKSHATA BHAT
2021년 11월 20일
편집: Walter Roberson
2023년 4월 25일
even after making the changes, my code is giving following error:
My code is in the attached file. Kindly advice me about the same.
Error using classreg.learning.FitTemplate/fillIfNeeded (line 714)
showplot is not a valid parameter name.
Error in classreg.learning.FitTemplate.make (line 140)
temp = fillIfNeeded(temp,type);
Error in ClassificationSVM.template (line 235)
temp = classreg.learning.FitTemplate.make('SVM','type','classification',varargin{:});
Error in ClassificationSVM.fit (line 239)
temp = ClassificationSVM.template(varargin{:});
Error in fitcsvm (line 342)
obj = ClassificationSVM.fit(X,Y,RemainingArgs{:});
Error in DetectDisease_GUI>pushbutton5_Callback (line 297)
svmStruct = fitcsvm(data(train,:),groups(train),'showplot',false,'kernel_function','linear');
Error in gui_mainfcn (line 95)
feval(varargin{:});
Error in DetectDisease_GUI (line 41)
gui_mainfcn(gui_State, varargin{:});
Error in matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)DetectDisease_GUI('pushbutton5_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback.
Aishwarya
2023년 4월 25일
Did you get a solution?
Walter Roberson
2023년 4월 25일
Don Mathis
2023년 4월 25일
편집: Don Mathis
2023년 4월 25일
0 개 추천
svmtrain() was replaced by fitcsvm(), and fitcsvm does not have a 'showplot' argument. Making a 2D plot of data points and support vectors in not built-in to fitcsvm, nor the object that it returns, ClassificationSVM.
If you have a 2D input space and you want to plot points and support vectors, you can see an example of how to do that here: https://www.mathworks.com/help/stats/classificationsvm.html#bt7go4d
카테고리
도움말 센터 및 File Exchange에서 Classification Ensembles에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!