reem.abd
reem.abd

Reputation: 41

printing the Accuracy,Error rate,Specificity and Sensitivity of classification using Weka

I need to print the Accuracy,Error rate,Specificity and Sensitivity after applying classification on data using Weka API in my Java application. Is there any method helps me to extract these percentage? Thank you

Upvotes: 0

Views: 2254

Answers (1)

Sentry
Sentry

Reputation: 4113

The standard Weka output already lists everything you're asking for:

java -cp weka.jar <yourclassifier> -t input.arff -x 5 -i

=== Stratified cross-validation ===

Correctly Classified Instances        1648               72.4714 %
Incorrectly Classified Instances       626               27.5286 %
Kappa statistic                          0.433
Mean absolute error                      0.3858
Root mean squared error                  0.4361
Relative absolute error                 77.8927 %
Root relative squared error             87.6236 %
Total Number of Instances             2274


=== Detailed Accuracy By Class ===

               TP Rate   FP Rate   Precision   Recall  F-Measure   ROC Area  Class
                 0.583     0.159      0.752     0.583     0.657      0.773    A
                 0.841     0.417      0.71      0.841     0.77       0.773    B
Weighted Avg.    0.725     0.3        0.729     0.725     0.719      0.773


=== Confusion Matrix ===

    a    b   <-- classified as
   599  428 |    a = A
   198 1049 |    b = B

Everything you asked for is in there, or am I missing something? Extracting the information should be easy, should even be perfectly doable without the use of regex or such.

Hint: Precision == Recall

(Some command line options and formulas for Specificity and Sensitivity)

Upvotes: 1

Related Questions