macro, micro and weighted 图解

闲言少叙,直接举例:
macro, micro and weighted 图解_第1张图片

混淆矩阵

macro, micro and weighted 图解_第2张图片

TP, FP,FN结果

macro, micro and weighted 图解_第3张图片
下面就以precision这个指标作为示例进行计算:

P r e c i s i o n b i r d s = T P b i r d s T P b i r d s + F P b i r d s = 1 1 + 0 = 1 Precision_{birds} = \frac{TP_{birds}}{TP_{birds} + FP_{birds}} = \frac{1}{1 + 0} = 1 Precisionbirds=TPbirds+FPbirdsTPbirds=1+01=1
P r e c i s i o n c a t s = T P c a t s T P c a t s + F P c a t s = 4 4 + 1 = 0.8 Precision_{cats} = \frac{TP_{cats}}{TP_{cats} + FP_{cats}} = \frac{4}{4 + 1} = 0.8 Precisioncats=TPcats+FPcatsTPcats=4+14=0.8
P r e c i s i o n d o g s = T P d o g s T P d o g s + F P d o g s = 2 2 + 1 = 0.667 Precision_{dogs} = \frac{TP_{dogs}}{TP_{dogs} + FP_{dogs}} = \frac{2}{2 + 1} = 0.667 Precisiondogs=TPdogs+FPdogsTPdogs=2+12=0.667

Micro
不论类别统一计算
Micro-averaged Precision = T P t o t a l T P t o t a l + F P t o t a l = 7 7 + 2 = 0.7777 \text{Micro-averaged Precision} = \frac{TP_{total}}{TP_{total} + FP_{total}} = \frac {7}{7+2} = 0.7777 Micro-averaged Precision=TPtotal+FPtotalTPtotal=7+27=0.7777

Macro
先计算各类别,然后平均
Macro-averaged Precision = 1 3 P r e c i s i o n b i r d s + P r e c i s i o n c a t s + P r e c i s i o n d o g s = 1 3 ( 1 + 0.8 + 0.6666 ) = 0.8222 \text{Macro-averaged Precision} = \frac{1}{3}{Precision_{birds} + Precision_{cats} + Precision_{dogs}} = \frac {1}{3}(1+0.8+0.6666)=0.8222 Macro-averaged Precision=31Precisionbirds+Precisioncats+Precisiondogs=31(1+0.8+0.6666)=0.8222

Weighted
Macro plus, 考虑了样本量进行加权平均
Weighted-averaged Precision = P r e c i s i o n b i r d s ∗ N b i r d s + P r e c i s i o n c a t s ∗ N b i r d s + P r e c i s i o n d o g s ∗ N b i r d s Total number of samples = 1 ∗ 2 + 0.8 ∗ 4 + 0.6666 ∗ 3 2 + 4 + 3 = 0.8 \text{Weighted-averaged Precision} = \frac{Precision_{birds}*N_{birds} + Precision_{cats}*N_{birds}+Precision_{dogs}*N_{birds}}{\text{Total number of samples}} = \frac {1*2 + 0.8*4+0.6666*3}{2+4+3} = 0.8 Weighted-averaged Precision=Total number of samplesPrecisionbirdsNbirds+PrecisioncatsNbirds+PrecisiondogsNbirds=2+4+312+0.84+0.66663=0.8

文中例子来源:
MACHINE LEARNING MODEL EVALUATION METRICS PART 2: MULTI-CLASS CLASSIFICATION

你可能感兴趣的:(算法,python,机器学习)