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

18 ビュー (過去 30 日間)
hello_world
hello_world 2018 年 7 月 21 日
回答済み: Walter Roberson 2018 年 7 月 22 日
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 Center および File ExchangeStatistics and Machine Learning Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by