Matlab keeps calling the wrong SVMtrain function

2 views (last 30 days)
Hi, I have a question about the svm train function. I have installed and done the make files using libsvm from the following website http://www.csie.ntu.edu.tw/~cjlin/libsvm/
However, when I call the function it gives me the following error in the files provided: Error using svmtrain (line 233) Y must be a vector or a character array.
Error in SVR_load_ver2 (line 107) model = svmtrain(lrndata.y, lrndata.X, param.libsvm);
After doing some research I realized that the statistics toolbox has a different svmtrain function with the same name and that is the one that was being called. I already have the libsvm files at the top of my paths.
Any possible solution would be greatly appreciated!
Thank you!!
  2 Comments
mehrose
mehrose on 18 Aug 2015
run the following command, you will find out which function is calling.
which -all svmtrain
then remove the lib you have added for svm. from the command line, add the path of your svm lib.
addpath your_lib_name
run the file. if the problem exists, try downloading the new version of lib, and try again. i have lib libsvm-mat-2.88-1. it doesnt work. i downloaded libsvm-3.20 with the above steps, it works!
Tung Nguyen
Tung Nguyen on 27 Nov 2016
Hi, I tried to addpath to a folder that contains my *.mexa64 files. But, Matlab keeps calling the default svmtrain.m file. I also tried to change the file name (svmtrain.m -> svmtrain_temp.m), and Matlab response:
Previously accessible file "/usr/local/MATLAB/R2016b/toolbox/stats/stats/svmtrain.m" is now inaccessible.
How can I force Matlab to choose the svmtrain in my .mex files?

Sign in to comment.

Answers (4)

the cyclist
the cyclist on 11 Jan 2015
You can use the path command to see and change the path, which will determine which version of the function is "seen" first, and used.

the cyclist
the cyclist on 11 Jan 2015
You can use
which -all svmtrain
to identify all the instances of this function, and specify the complete path to the one you want, not relying on MATLAB's priority. This can be a bit cumbersome, though.

Mubashir
Mubashir on 16 Aug 2018
Just copy the 'svmtrain' function from LibSvm Matlab folder to your folder, from which you are calling a function. This works with my same problem.

Abdul Ghaffar
Abdul Ghaffar on 20 Jul 2019
@all. I am also facing the same problem in 'svmtrain '.
"Error using svmtrain (line 230)
svmtrain has been removed. Use fitcsvm instead."
Please guide me how to resolve this issue.
I just download and can't do make files using libsvm from the following website http://www.csie.ntu.edu.tw/~cjlin/libsvm/

Categories

Find more on Statistics and Machine Learning Toolbox in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!