Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calculate Precision and Recall

I am really confused about how to calculate Precision and Recall in Supervised machine learning algorithm using NB classifier

Say for example
1) I have two classes A,B
2) I have 10000 Documents out of which 2000 goes to training Sample set (class A=1000,class B=1000)
3) Now on basis of above training sample set classify rest 8000 documents using NB classifier
4) Now after classifying 5000 documents goes to class A and 3000 documents goes to class B
5) Now how to calculate Precision and Recall?

Please help me..

Thanks

like image 521
user1051536 Avatar asked Dec 08 '12 11:12

user1051536


People also ask

How do you calculate precision and recall manually?

In general, precision is TP/(TP+FP). Note that TP+FP is the sum of the first row. Another very useful measure is recall, which answers a different question: what proportion of actual Positives is correctly classified? Looking at the table, we see that the number of actual Positives is 2+5=7 (TP+FN).


1 Answers

Hi you have to divide results into four groups -
True class A (TA) - correctly classified into class A
False class A (FA) - incorrectly classified into class A
True class B (TB) - correctly classified into class B
False class B (FB) - incorrectly classified into class B

precision = TA / (TA + FA)
recall = TA / (TA + FB)

You might also need accuracy and F-measure:

accuracy = (TA + TB) / (TA + TB + FA + FB)
f-measure = 2 * ((precision * recall)/(precision + recall))

More here:
http://en.wikipedia.org/wiki/Precision_and_recall#Definition_.28classification_context.29

like image 131
Tom Marek Avatar answered Sep 22 '22 23:09

Tom Marek