Search code examples
machine-learningsvmlight

SVM-Light displays corrupted precision/recall results


I run SVM-Light classifier but the recall/precision row it outputs seem to be corrupted:

Reading model...OK. (20 support vectors read)
Classifying test examples..100..200..done
Runtime (without IO) in cpu-seconds: 0.00
Accuracy on test set: 95.50% (191 correct, 9 incorrect, 200 total)
Precision/recall on test set: 0.00%/0.00%

What should I configure to get valid precision and recall?


Solution

  • For example, if your classifier is always predicting "-1" -- the negative class; your test dataset, however, contains 191 "-1" and 9 "+1" as golden labels, you will get 191 of them correctly classified and 9 of them incorrect.

    True positives : 0        (TP)
    True negatives : 191      (TN)
    False negatives: 9        (FN)
    False positives: 0        (FP)
    Thus:
                   TP             0
    Precision = -----------  = --------- = undefined
                 TP + FP         0 + 0
    
                   TP             0
    Recall    = -----------  = --------- = 0
                 TP + FN        0 + 9
    

    From the formula above, you know that as long as your TP is zero, your precision/recall is either zero or undefined.

    To debug, you should output (for each test example) the golden label and the predicted label so that you know where the issue is.