之前的版本的libsvm中对数据的预测可能只需要三输入两输出,而现在在libsvm3.2以上的需要变为四输入三输出,即传入predicted_label, accuracy, decision_values三个参数;
使用说明如下:
model = [train_Y, train_X,'libsvm_options']
Usage: [predicted_label, accuracy, decision_values/prob_estimates] = svmpredict(testing_label_vector, testing_instance_matrix, model, 'libsvm_options')
[predicted_label] = 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
-q : quiet mode (no outputs)
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.
补充说明:accuracy中包含三个数据,第一个是准确率(精度);第二个是mse;第三个是平方相关系数;第二与第三是在回归问题中使用。
其中 options 为一些参数选项,主要有:
- s svm 类型:SW 模型设置类型(默认值为 o)
0:C-SVC(C-Support Vector Classification)
1;nu-SVC(nu~ Support Vector Classification)
2:one- class SVM
3:epsilon-SVR(epsilon- Support Vector Regression)
4:nu- SVR(nu - Support Vector Regression)
-t 核函数类型:核函数设置类型(默认值为 2)
0:线性核函数u’v
1:多项式核函数(T*u’v + coefO)degree
2:RBR 核函数 exp(~r│u-v│^2)
3.sigmoid 核函數 tanh(r *v’v ’ coefo)
-d degree.核兩数中的 degree 参数设置(针对多项式核函数,默认值为 3)
- -g r(gama):核函数中的 gamma 参数函数设置(针对多项式/rbf/sigmoid 核函数,默认值为属性数目
的倒数,即若k 为属性的数目,则~a参数默认为 1/k)
– r coef0:核函数中的 coef0 参数设置(针对多项式/sigmoid 核函数,歌认值为 0)
– c cost:设置 C- SVC. epsilon- SVR 和 nu- SVR 的参(默认值为 1)
– n mu:设置 nu - SVC,one - class SVN 和 mu- SVR 的参数(默认值为 0.5)
– p epsilon:设置 epsilon - SVR 中损失函数的值(默认值为 0.1)
– m cachesize:设置 cache 内存大小,以 MB 为单位(默认值为 100)
–e eps:设置允许的终止阈值(默认值为 0.001)
– h shrinking:是否使用启发式,0 或 1(默认值为 1)
–wi weight:设置第几类的参数 C 为 weight * C(对于 C- SVC中的 C,默认值为 1)
–v n: n- fold 交互检验模式,n为折数,必须大于等于 2