Click here to Skip to main content
16,013,322 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to do 3 fold cross validation using LIBSVM in Java. I found that I perform ten-fold cross validation with LibSVM like this-

Java
double[] target = new double[svmProblem.l];
    svm.svm_cross_validation(svmProblem, svmParameter, 10, target );


where I have created svmParameter and svmProblem. My question is can I pass the svm parameters returned from the svm_train function to the cross-validation function, something like this :

Java
double[] target = new double[svmProblem.l];
    svm.svm_cross_validation(svmProblem, test_model.param, 3, target );


where test_model is the model returned by svm_train? Can someone please tell me if this is right?

Thanks!
Posted
Comments
Richard MacCutchan 4-Nov-13 4:34am    
What does the documentation say, and what happens when you try it?
Member 10305598 4-Nov-13 8:25am    
I have tried both the ways, the predicted labels are same for the test data.
LIBSVM read-me file describes the function like this -Function: void svm_cross_validation(const struct svm_problem *prob,
const struct svm_parameter *param, int nr_fold, double *target);

This function conducts cross validation. Data are separated to
nr_fold folds. Under given parameters, sequentially each fold is
validated using the model from training the remaining. Predicted
labels (of all prob's instances) in the validation process are
stored in the array called target.
Is there any difference when I pass the model returned by svm_train to the cross-validation method?
Richard MacCutchan 4-Nov-13 11:49am    
No idea, you need to contact the developers of this library at http://www.csie.ntu.edu.tw/~cjlin/libsvm/.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900