Reputation: 127
I use libsvm svmpredict method for classifying the images on Matlab. I need svmpredict method's output model file that has extension with ".model". But I cannot create it. My usage is that,
model = svmtrain(train_label_set_libsvmformat, train_data_set_libsvmformat, '-t 2 -c 0.3 -g 0.01');
[predict_label, accuracy, prob_values] = svmpredict(test_label_set_libsvmformat, test_data_set_libsvmformat, model, 'output.model');
I wait for creating this file "output.model", but it doesn't exist. Is there anything that is wrong for me?
Upvotes: 2
Views: 6841
Reputation: 4113
From https://sites.google.com/site/kittipat/libsvm_matlab
% Train the SVM
model = svmtrain(trainLabel, trainData, '-c 1 -g 0.07 -b 1');
% Use the SVM model to classify the data
[predict_label, accuracy, prob_values] = svmpredict(testLabel, testData, model, '-b 1'); % run the SVM model on the test data
The last argument of svmpredict
is not a filename, but the options you want to pass to svmpredict
. If you want to save a model to a file, this usually is done when training the model in svmtrain
. If you use the command line version of svm-train
, the model-file is an additional parameter.
From what I make of the source code of libsvm for MATLAB, the model you get from executing the svmtrain
command is just a scalar in MATLAB, so there is no built-in way to obtain a model-file.
If you want a model-file, you have to use the command line version of libsvm.
Upvotes: 2