How to avoid this error while using psoSVMcgForRegress.m?

2 次查看(过去 30 天)
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 个评论
Walter Roberson
Walter Roberson 2019-4-23
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.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Traveling Salesman (TSP) 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by