(I will try my best to make this note clearer. We mainly discuss one_class case while others will be introduced in the future.)
Starting from the usage of svm-predict:
./svm-predict svmguide1.t svmguide1.model svmguide1.t.predict
(Example data can be downloaded here: https://www.csie.ntu.edu.tw/~cjlin/libsvmtools/datasets/)
This is copied from the instruction of libsvm.
The model is loaded from svmguide1.model, which is output by training before.
i.e. model=svm_load_model(svmguide1.model)
Later, the prediction will be written in the file: svmguide1.t.predict.
the MAIN functions are:
predict(input,output);
svm_predict(model, x); //x data is used for prediction
svm_predict_values(model, x, dec_values);
//dec_values is one for one_class, or nr_class*(nr_class-1)/2
For function: svm_predict_values(const svm_model model, const svm_node *x, double dec_values):
double *sv_coef = model->sv_coef[0];
double sum = 0;
for(i=0;i<model->l;i++)
sum += sv_coef[i] * Kernel::k_function(x,model->SV[i],model->param);
sum -= model->rho[0];
*dec_values = sum;
if(model->param.svm_type == ONE_CLASS)
return (sum>0)?1:-1;
else
return sum;