0
votes

I'm training an SVM inside a for loop changing the features of my instances and I would like to plot the final objective value vs iteration. I'm using LIBSVM in Matlab but I don't find explicitly the final objective value in the returned model. How do I compute the final objective value with the returned model in each interation?

It's possible read the script printed by the svmtrain but I'd like to compute this value without this trick.

P.D. I have a basic knowledge of C++.

1
Are you using C-SVM? If so, see this faq csie.ntu.edu.tw/~cjlin/libsvm/faq.html#f401. If not, can you include the name of the function you are using for training and the output of the training (if any)? - kitchenette
Yes I'm using the C-SVM in Matlab with the function "svmtrain". This return a model structure with the parameters: "nr_class", "totalSV", "rho", "Label", "ProbA", "ProbB", "nSV", "sv_coef", "SVs" - escorciav

1 Answers

1
votes

I modify the svm.cpp and svm.h to return the objective value adding a few lines of code.

1) Add new field in the svmmodel (svm.h) and decision_function (svm.cpp) structures.

2) Copy the si.obj in the new field of the decision_function.

3) Copy the field catch by the decision_function into the newer field of the svmmodel structure (svm_train function in the svm.cpp).

4) Modify the svm_model_matlab.c to admit the new field in the svmmodel structure.

  • Incremet the NUMBER_OF_FIELD variable and add a new field in the output structure.
  • According to the order in the output structure modify the function model_to_matlab_struct. (It's easy copy the code used for the field rho and replace rho by your variable's name)
  • Modify the matrix_matlab_to_model function

It's really easy and straighforward.

I can pass the new files only send me an email with the purpose: LIBSVM-ObjModification