Tech Lover
Tech Lover

Reputation: 135

How can I calculate Precision and Recall for sentiment analysis multi-class classifier using Confusion Matrix?

I wonder how to compute precision and recall using a confusion matrix sentiment analysis multi-class classifier using Confusion Matrix. I have a dataset of 5000 texts and I did human labeling for a sample of 100. Now, I would like to compute the Precision and Recall for the classifier based on this sample of data. I have three classes; Positive, Neutral and Negative.

So how can I compute these metrics for each class?

As I am new here in stackoverflow, I couldn't illustrate the confusion matrix I have, so let us assume that we have the following confusion matrix:

red color   > Negative
green color > Positive
purple color> Neutral

enter image description here

Upvotes: 2

Views: 3516

Answers (2)

H M
H M

Reputation: 119

you can measure

precision=TPos/(TPos+TNeg+TNeu) i.e 30/(30+20+10)=50% ,

recall=TPos/(TPos+FNeg+FNeu) i.e 30/(30+50+20)=30% ,

F-measure=2*precision*recall/(precision+recall)=37.5% ,and

Accuracy(all true)/(all data) =30+60+80/300=56.7% .

for more http://blog.kaggle.com/2015/10/23/scikit-learn-video-9-better-evaluation-of-classification-models/

Upvotes: 3

THe_strOX
THe_strOX

Reputation: 717

You can use sklearn's classification report.

Upvotes: 0

Related Questions