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.
0 个评论
采纳的回答
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.
0 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!