简体   繁体   English

如何使用python计算Precision、Recall和F-score?

[英]How to calculate Precision, Recall and F-score using python?

The labelTrainData.csv is used to train the classifier for predicting sentiments of Testdata.csv. labelTrainData.csv 用于训练分类器以预测 Testdata.csv 的情绪。 Finally i got BagOfCentroids.csv.最后我得到了 BagOfCentroids.csv。

labelTrainData.csv标签训练数据.csv

id   sentiment    Tweet
1    0            tweet_1
2    1            tweet_2
3    0            tweet_3

Testdata.csv测试数据.csv

id      Tweet
1       tweet_1
2       tweet_2
3       tweet_3

BagOfCentroids.csv 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?有没有办法计算 Precision、Recall 和 F-score?

this article will be helpful:这篇文章会有所帮助:

TEXT CLASSIFICATION FOR SENTIMENT ANALYSIS – PRECISION AND RECALL 情感分析的文本分类——精确和召回

Detail about nltk.metrics package 有关 nltk.metrics 包的详细信息

This might be because of some import issue这可能是因为一些导入问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在python中使用libSVM计算精度,召回率和F-score - How to calculate precision, recall and F-score with libSVM in python 如何计算此模型的召回率、准确率和 f 分数? - how can I calculate recall, precision and f-score for this model? 在一次传递中计算精度,召回和F分数 - 蟒蛇 - Calculating Precision, Recall and F-score in one pass - python 具有F分数,精度或召回力的LIBSVM评估 - LIBSVM Evaluation with F-Score, Precision or Recall 使用 KNN 分类器具有召回率、F 分数、精度 1 - Having recall, F-score, precision 1 with KNN classifier 精度,召回率,F分数要求相等的输入 - Precision, Recall, F-score requiring equal inputs 使用交叉验证计算 4 个模型的召回率和精度以及 F 分数时出错? - Error when computing recall and precision and F-score of 4 models using cross validation? 如何使用 Spacy v3 在命名实体识别中生成 Precision、Recall 和 F-score? 求ents_p,ents_r,ents_f 小定制NER model - How to generate Precision, Recall and F-score in Named Entity Recognition using Spacy v3? Seeking ents_p, ents_r, ents_f for a small custom NER model 如何在pyspark中使用MultiClassMetrics计算f-score? - How to calculate the f-score using MultiClassMetrics in pyspark? 使用 Python 机器学习模型时,精度和 F 分数是定义不明确的警告 - Precision and F-score are ill-defined warning while using Python machine learning model
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM