1
votes

I am using LIBSVM in java and I need to calculate the AUC values. The read me file says we can use the -v option splits the data into n parts and calculates cross validation accuracy/mean squared error on them, but in java I am using the svm_train function which does not have a -v option (it has SVM Problem and SVM Parameters as inputs). So I am using the svm_cross_validation function as below but it does not return the accuracy (returns the labels) in the target array.

svm.svm_cross_validation(SVM_Prob, SVM_Param, 3, target);

I get results like below which does not show any accuracy

optimization finished, #iter = 21
nu = 0.06666666666666667
obj = -21.0, rho = 0.0
nSV = 42, nBSV = 0
Total nSV = 42

My data is not unbalanced so I am not sure if I should use LibLINEAR. can anyone tell me how to find the cross validation accuracy of libsvm in java.

Thanks!

1

1 Answers

1
votes

You can write a simple one by yourself:

double[] target = new double[labels.length];

svm.svm_cross_validation(problem, param, 3, target);
double correctCounter = 0;
for (int i = 0; i < target.length; i++) {
   if (target[i] == labels[i]) {
      correctCounter++;
   } 
}