How to find the Precision, Recall, Accuracy using SVM?
Asked Answered
T

1

6

Duplicate calculating Precision, Recall and F Score

I have a input file with text description and classified level (i.e.levelA and levelB). I want to write a SVM classifier that measure precision, recall and accuracy. I looked at scikit and LIBSVM but I want to know more step by step.

Any sample code or basic tutorial would be really nice. Thanks for any suggestion in advance.

Teddy answered 11/7, 2013 at 9:42 Comment(2)
possible duplicate of How to calculate precision, recall and F-score with libSVM in pythonIndoeuropean
Here's an extension for libsvm: csie.ntu.edu.tw/~cjlin/libsvmtools/eval/index.htmlMythomania
B
10

These performance measures are easy to obtain from the predicted labels and true labels, as a post-processing step:

  1. Precision = TP / (TP+FP)
  2. Recall = TP / (TP+FN)
  3. Accuracy = (TP + TN) / (TP + TN + FP + FN)

With TP, FP, TN, FN being number of true positives, false positives, true negatives and false negatives, respectively.

Bates answered 11/7, 2013 at 10:51 Comment(4)
Thanks Marc, but I already did some study some basics but I need more specific information step by step implementation process.Teddy
The steps are: train an SVM (make sure to tune it properly), predict the test set, compute performance measures based on predicted labels and true labels.Bates
Can you please suggest me any tutorial or book with code snippets. I don't want exact whole code but for learning purpose it would be really useful. Thanks.Teddy
@Raid The code is trivial. It is just a matter of keeping four counters and then using the formulae that Marc provided. For each predicted label: if predicted label == true label and true label is positive, increment TP; if predicted label == true label and label is negative, increment TN; if predicted label is positive and true label is negative; increment FP; otherwise increment FN. Try this video: youtube.com/watch?v=2akd6uwtowc.Rarefied

© 2022 - 2024 — McMap. All rights reserved.