matlab libsvm:无法预测 [英] matlab libsvm: unable to predict
问题描述
我在Matlab上使用libsvm.我想建立一个模型,并使用该模型进行预测. 接线说明svmpredict([predict_label,precision_all,prob_values])的返回为空.这是我的简单代码:
I am using libsvm on Matlab. I want to build a model and use this model for prediction. It is wired that the returns of svmpredict ([predict_label, accuracy_all, prob_values]) are empty. Here is my simple code:
svm_model = svmtrain([train_label],[train],'-t 2, -c 100 -q');
[predict_label, accuracy_all, prob_values] = svmpredict(testlabels,testdata,svm_model,'-q, -b 1');
[predict_label,precision_all,prob_values]是0x0矩阵. Matlab还会显示一些警告信息:
[predict_label, accuracy_all, prob_values] are 0x0 matrix. And also Matlab also shows some warning information:
Usage: [predicted_label, accuracy, decision_values/prob_estimates] = svmpredict(testing_label_vector, testing_instance_matrix, model, 'libsvm_options')
Parameters:
model: SVM model structure from svmtrain.
libsvm_options:
-b probability_estimates: whether to predict probability estimates, 0 or 1 (default 0); one-class SVM not supported yet
Returns:
predicted_label: SVM prediction output vector.
accuracy: a vector with accuracy, mean squared error, squared correlation coefficient.
prob_estimates: If selected, probability estimate vector.
有人可以帮助我吗?
推荐答案
SVM模型中的q是什么?它的价值在哪里?
What is q in the SVM model ? where is it's value ?
在SVM中有两个参数需要很好地定义c和g,您已经将100设置为c的值,但是r却没有q的值(或者必须是g,称为gamma)
there is two parameters in the SVM which need to be well defined c and g , you have put 100 as value of c but ther is no value for q (or must be g which is called gamma)
这就是您需要的
cmd = ['-t 2 -c ',num2str(C), ' -g ',num2str(gamma) ];
model = svmtrain2(trainClass, trainData, cmd);
[predClass, acc, decVals] = svmpredict(testClass, testData, model);
我也认为svmtrain必须重命名为svmtrain2,以避免与matlab的svmtrain功能混淆.
Also i think that svmtrain must be renamed svmtrain2 to avoid the confusion with svmtrain function of matlab.
这篇关于matlab libsvm:无法预测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!