The labelTrainData.csv is used to train the classifier for predicting sentiments of Testdata.csv. Finally i got BagOfCentroids.csv.
labelTrainData.csv
id sentiment Tweet
1 0 tweet_1
2 1 tweet_2
3 0 tweet_3
Testdata.csv
id Tweet
1 tweet_1
2 tweet_2
3 tweet_3
BagOfCentroids.csv
id sentiment
1 0
2 1
3 1
To calculate above metrics, I am trying this,
print 'Sentiment precision:'
nltk.metrics.precision(BagOfCentroids['sentiment'], Testdata['sentiment'])
print 'sentiment recall:'
nltk.metrics.recall(BagOfCentroids['sentiment'], Testdata['sentiment'])
print 'sentiment F-measure:'
nltk.metrics.f_measure(BagOfCentroids['sentiment'], Testdata['sentiment'])
Is there any way to calculate Precision, Recall and F-score?
this article will be helpful:
TEXT CLASSIFICATION FOR SENTIMENT ANALYSIS – PRECISION AND RECALL
Detail about nltk.metrics package
This might be because of some import issue
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.