1

i am trying to use WEKA-> libSVM for train a dataset using Support vector machine. Here is my code

        LibSVM svm = new LibSVM();

    FastVector predictionsvm = new FastVector();

    for (int i = 0; i < trainingSplits.length; i++) {
        Evaluation validation = SVMclassify(svm, trainingSplits[i], testingSplits[i]);  

        predictionsvm.appendElements(validation.predictions());

    }

    public static Evaluation SVMclassify(Classifier model,
        Instances trainingSet, Instances testingSet) throws Exception {

    //return the classification model after training with train set and test with test set

    Evaluation evaluation = new Evaluation(trainingSet);

    model.buildClassifier(trainingSet);
    evaluation.evaluateModel(model, testingSet);

    return evaluation;
}

but When i run the code i get an exception called

 Exception in thread "main" java.lang.Exception: libsvm classes not in CLASSPATH!
at weka.classifiers.functions.LibSVM.buildClassifier(Unknown Source)
at dentis.test.SVMclassify(test.java:59)
at dentis.test.main(test.java:202)

I do check whether libSVM in the package or not and libSVM is there. i import the weka.jar in right way too because this is the 4th classifier i am using and this one is only giving me error.

Note - i am using 10 fold cross validation

Nipun Alahakoon
  • 2,772
  • 5
  • 27
  • 45

0 Answers0