[英]cross validation accuracy in libsvm java
I am using LIBSVM in java and I need to calculate the AUC values. 我在Java中使用LIBSVM,我需要计算AUC值。 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). 自述文件说我们可以使用
-v
选项将数据分成n个部分,并计算它们的交叉验证准确性/均方误差,但是在Java中,我使用的是svm_train函数,该函数没有-v
选项(它具有SVM问题和SVM参数作为输入)。 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_cross_validation
函数,但它未在目标数组中返回精度(返回标签)。
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. 我的数据不是不平衡的,所以我不确定是否应该使用LibLINEAR。 can anyone tell me how to find the cross validation accuracy of libsvm in java.
谁能告诉我如何在Java中找到libsvm的交叉验证准确性。
Thanks! 谢谢!
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++;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.