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

10 次查看(过去 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] =
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 中查找有关 Image Data Workflows 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by