【机器学习理论】分类问题中常用的性能评估指标 - 知乎

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

【机器器学习理理论】分类问题中常⽤用的性能评估指标 - 知乎 2020/12/8 下午9(19

Matthew
AI Research Engineer

48

Accuracy Precision Recall F

• TP ---
• FN ---
• FP ---
• TN ---

True False Positive Negative

Accuracy

Error

https://zhuanlan.zhihu.com/p/30953081 ⻚页码:1/7
【机器器学习理理论】分类问题中常⽤用的性能评估指标 - 知乎 2020/12/8 下午9(19

1 Precision

2 Recall

F-score

F-Score

F-score
48

Balanced F-Score


Macro-averaging Micro-
averaging

Averaging

https://zhuanlan.zhihu.com/p/30953081 ⻚页码:2/7
【机器器学习理理论】分类问题中常⽤用的性能评估指标 - 知乎 2020/12/8 下午9(19

Macro-averaging

Macro-averaging
Macro-Precision Macro-Recall F Macro-F Score

Micro-averaging

Micro-averaging

Macro-averaging Micro-averaging Macro-averaging


Micro-averaging

0.83 0.5
0.9 5

10 A B C 10

> A A A C B C A B B C
> A A C B A C A C B C

A / A

A / A

https://zhuanlan.zhihu.com/p/30953081 ⻚页码:3/7
【机器器学习理理论】分类问题中常⽤用的性能评估指标 - 知乎 2020/12/8 下午9(19

B / B

B / B

C / C

C / C

from sklearn.metrics import accuracy_score, precision_score, recall_score


from sklearn.metrics import f1_score, fbeta_score

y_true = [0, 0, 0, 2, 1, 2, 0, 1, 1, 2]
y_pred = [0, 0, 2, 1, 0, 2, 0, 2, 1, 2]

accuracy_score(y_true, y_pred) # Return the number of correctly classified samples


accuracy_score(y_true, y_pred, normalize=False) # Return the fraction of correctly classified samples

# Calculate precision score


precision_score(y_true, y_pred, average='macro')
precision_score(y_true, y_pred, average='micro')
precision_score(y_true, y_pred, average=None)

# Calculate recall score


recall_score(y_true, y_pred, average='macro')
recall_score(y_true, y_pred, average='micro')
recall_score(y_true, y_pred, average=None)

# Calculate f1 score
f1_score(y_true, y_pred, average='macro')
f1_score(y_true, y_pred, average='micro')
f1_score(y_true, y_pred, average=None)

# Calculate f beta score


fbeta_score(y_true, y_pred, average='macro', beta=0.5)
fbeta_score(y_true, y_pred, average='micro', beta=0.5)
fbeta_score(y_true, y_pred, average=None, beta=0.5)

https://zhuanlan.zhihu.com/p/30953081 ⻚页码:4/7
【机器器学习理理论】分类问题中常⽤用的性能评估指标 - 知乎 2020/12/8 下午9(19

1. . . .
2. . . .
3.
4. Wikepedia entry for f1-score
5. Pillai Ignazio G. Fumera and F. Roli. "F-measure optimisation in multi-label classifiers."
*International Conference on Pattern Recognition* IEEE 2012U2424-2427.
6. Asch V V Macro- and micro-averaged evaluation measures BASIC DRAFT . 2013.
7. Sokolova Marina and G. Lapalme. "A systematic analysis of performance measures for
classification tasks." *Information Processing & Management An International Journal*
45.4 2009 :427-437.
8. Özgür Arzucan Levent Özgür and Tunga Güngör. "Text categorization with class-based
and corpus-based keyword selection." *Computer and Information Sciences-ISCIS 2005*
2005 : 606-615.

2017-11-23

—— :
Accuracy Precision Recall ROC AUC
F-Score...

http://www.leadai.org
Accuracy Precision
Recall...P.S. - AUC
accuracy precision …

keail L... L...

https://zhuanlan.zhihu.com/p/30953081 ⻚页码:5/7
【机器器学习理理论】分类问题中常⽤用的性能评估指标 - 知乎 2020/12/8 下午9(19

...

2018-08-20

Macro-averaging Micro-averaging Macro-


averaging Micro-averaging
1

2018-08-20

A macro-average will compute the metric independently for each class and then take the
average hence treating all classes equally whereas a micro-average will aggregate the
contributions of all classes to compute the average metric. In a multi-class classification
setup micro-average is preferable if you suspect there might be class imbalance

2018-11-29

PRF
Macro-avg F1 Yang Y. 2001 September . A study of thresholding
strategies for text categorization. InProceedings of the 24th annual international ACM
SIGIR conference on Research and development in information retrieval pp. 137-145 .
ACM. 4.1 F1

mbck 01-28

F F
3

mbck 11-17

https://zhuanlan.zhihu.com/p/30953081 ⻚页码:6/7

You might also like