How to avoid this error while using psoSVMcgForRegress.m?

2 views (last 30 days)
I am trying to use PSOSVMcgForRegress in Matlab 2018 to optimize SVM parameters using SVM and I am getting the following error:
Error using svmtrain (line 230)
svmtrain has been removed. Use fitcsvm instead.
Error in psoSVMcgForRegress (line 54)
fitness(i) = svmtrain(train_label, train, cmd);
If I replace svmtrain with fitcsvm then I get different set of errors:
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 psoSVMcgForRegress (line 54)
fitness(i) = fitcsvm(train_label, train, cmd);
Any help would be greatly appreciated.
  1 Comment
Walter Roberson
Walter Roberson on 23 Apr 2019
You have two layers of problems:
  1. The code was written expecting libsvm's svmtrain() function, not MATLAB's svmtrain() function. MATLAB's svmtrain() function did not accept a command as the third parameter; after the second parameter it expects name/value pairs
  2. You are executing in a system in which libsvm is either not installed or else is later on the path than the Statistics and Machine Learning Toolbox is
  3. MATLAB's svmtrain has been replaced by fitcsvm, which takes different options than MATLAB's svmtrain did, neither of which was compatible with the "cmd" syntax of libsvm
At this point you can either install libsvm (earlier on the path than the Stats toolbox), or you can update to fitcsvm with parameters appropriate to do equivalent actions to what would have been done with the libsvm call.
I would need to see what was in cmd to suggest what the fitcsvm equivalent would be.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!