LIBSVM: MATLAB function "trainsvm" deprecated and replaced by "fitcsvm"

조회 수: 5 (최근 30일)
As MATLAB ha depreciated "svmtrain" and replaced it by "fitcsvm", LIBSVM is giving error:
% This is an example of using precomputed kernel
% using Libsvm in MATLAB, where K is the precomputed kernel (Gram matrix).
model = fitcsvm(TrainLabels, K, '-t 4');
Error using internal.stats.parseArgs (line 42)
Wrong number of arguments.
Error in classreg.learning.paramoptim.parseOptimizationArgs (line 5)
[OptimizeHyperparameters,~,~,RemainingArgs] = internal.stats.parseArgs(...
Error in fitcsvm (line 312)
[IsOptimizing, RemainingArgs] =
classreg.learning.paramoptim.parseOptimizationArgs(varargin);
Error in myKernelLIBSVM (line 153)
model = fitcsvm(TrainLabels, K, '-t 4');
Earlier, this would work fine using svmtrain.
Error using svmtrain (line 230)
svmtrain has been removed. Use fitcsvm instead.

채택된 답변

Walter Roberson
Walter Roberson 2018년 7월 22일
You have
fitcsvm(TrainLabels, K, '-t 4')
The valid syntaxes for fitcsvm are
Mdl = fitcsvm(Tbl,ResponseVarName)
Mdl = fitcsvm(Tbl,formula)
Mdl = fitcsvm(Tbl,Y)
Mdl = fitcsvm(X,Y)
Mdl = fitcsvm(___,Name,Value)
The only one of this that permits a third parameter is the last one, with name/value pairs. But '-t 4' is not a name/value pair.
MATLAB's svmtrain() also never supported that syntax. That syntax was valid only for libsvm . You can still pull in libsvm if you want to.
The syntax for fitcsvm never has the label information as a separate first parameter, only integrated as part of the first parameter, or as a second parameter.
You should be having a look at the KernelFunction option

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by