javawekacross-validationevaluation

How to get the accuracy of an evaluation object in weka java?


I am using weka with java for classification purposes, I did manually the cross validation and I would like to know if there is a way to get the accuracy of an evaluation object i don't want the whole metrics like:

 System.out.println(eval.toSummaryString("=== " + folds + "-fold Cross-validation ===", false));

Thank you


Solution

  • To get the accuracy you just have to use the function pctCorrect(), which gives you the percentage of instances correctly classified by your model.

    double accuracy = eval.pctCorrect();
    System.out.println("Accuracy = " + accuracy);