为什么F-Measure是一个调和均值而不是精确和召回措施的算术平均值?

Lon*_*guy 64 classification machine-learning data-mining

当我们计算考虑精度和召回的F-测量时,我们采用两个测量的调和平均值而不是简单的算术平均值.

采用调和均值而不是简单平均值的直观原因是什么?

Sea*_*wen 71

为了解释,例如,考虑30mph和40mph的平均值是多少?如果你在每个速度下开车1小时,那么2小时内的平均速度确实是算术平均值,每小时35英里.

但是如果你以每个速度驾驶相同的距离 - 比如10英里 - 则超过20英里的平均速度是30和40的调和平均值,大约34.3英里每小时.

原因是,为了使平均值有效,您确实需要将值设置为相同的缩放单位.每小时的里程需要在相同的小时数内进行比较; 比较相同的里程数,你需要平均每英里的小时数,这正是调和平均值所做的.

精确度和召回率在分子和不同的分母中都有真正的积极作用.为了平均它们,平均它们的倒数实际上是有意义的,因此调和均值.

  • 谢谢,这是一个很好的论据,为什么这得到了理论的支持; 我的回答更多是务实的一面. (6认同)

Ano*_*sse 63

因为它更多地惩罚极端值.

考虑一个简单的方法(例如总是返回A类).B类有无限数据元素,A类有单个元素:

Precision: 0.0
Recall:    1.0
Run Code Online (Sandbox Code Playgroud)

当取算术平均值时,它将有50%的正确率.尽管是最糟糕的结果!使用调和平均值,F1测量值为0.

Arithmetic mean: 0.5
Harmonic mean:   0.0
Run Code Online (Sandbox Code Playgroud)

换句话说,具有较高的F1,你需要具有较高的精确度和召回.

  • 选择更多平衡不仅仅是一种启发式方法.鉴于这些比率的单位,谐波均值是唯一有意义的方法.平均值没有比较意义 (2认同)

isa*_*ndi 22

调和平均值等于应该用算术平均值平均的量的倒数的算术平均值.更准确地说,使用调和均值,您将所有数字转换为"可平均"形式(通过取倒数),您可以获取算术平均值,然后将结果转换回原始表示形式(再次采用倒数).

精确度和召回是"自然的"倒数,因为它们的分子是相同的,它们的分母是不同的.当它们具有相同的分母时,通过算术平均值对分数更敏感.

为了更直观,假设我们保持真正积极项目的数量不变.然后通过取精度和召回的调和平均值,你隐含地得到假阳性和假阴性的算术平均值.它基本上意味着当真正的积极因素保持不变时,误报和漏报对你来说同样重要.如果算法具有N个更多的假阳性项但是N个更少的假阴性(具有相同的真阳性),则F测量保持相同.

换句话说,F-measure适用于:

  1. 错误同样是错误的,无论是误报还是假阴性
  2. 错误的数量是相对于真阳性的数量来衡量的
  3. 真正的否定是无趣的

点1可能或可能不是真的,如果该假设不成立,则可以使用F-度量的加权变量.第2点是很自然的,因为如果我们只是对越来越多的点进行分类,我们可以预期结果会扩展.相对数字应该保持不变.

第3点非常有趣.在许多应用中,否定是自然默认,甚至可能很难或任意指定真正的负面因素.例如,每当普朗克时间过去时,火警每秒,每纳秒都会发生一次真正的负面事件.即使是一块岩石也始终存在这些真正的负面火灾探测事件.

或者在面部检测的情况下,大多数时候你" 正确地不返回 "图像中数十亿个可能的区域,但这并不有趣.有趣的情况是,当您确实返回建议的检测或何时应该返回它.

相比之下,分类准确性同样关注真阳性和真阴性,如果样本总数(分类事件)定义明确且相当小,则更为合适.

  • 很好解释! (4认同)

小智 20

上面的答案很好地解释了.这只是为了快速参考,以了解算术平均值的性质和图中的调和平均值.从图中可以看出,将X轴和Y轴视为精度和调用,将Z轴视为F1分数.因此,从调和平均值的曲线来看,精度和召回都应该对F1得分的均匀贡献,而不像算术平均值.

这是算术平均值.

在此输入图像描述

这是为了谐波的意思.

在此输入图像描述


Ler*_*ang 7

Here we already have some elaborate answers but I thought some more information about it would be helpful for some guys who want to delve deeper(especially why F measure).

According to the theory of measurement the composite measure should satisfy the following 6 definitions:

  1. Connectedness(two pairs can be ordered) and transitivity(if e1 >= e2 and e2 >= e3 then e1 >= e3)
  2. Independence: two components contribute their effects independently to the effectiveness.
  3. Thomsen condition: Given that at a constant recall (precision) we find a difference in effectiveness for two values of precision (recall) then this difference cannot be removed or reversed by changing the constant value.
  4. Restricted solvability.
  5. Each component is essential: Variation in one while leaving the other constant gives a variation in effectiveness.
  6. Archimedean property for each component. It merely ensures that the intervals on a component are comparable.

We can then derive and get the function of the effectiveness: 在此处输入图片说明

And normally we don't use the effectiveness but the much simper F score because:
在此处输入图片说明

Now that we have the general formula of F measure:

在此处输入图片说明

where we can place more emphesis on recall or precision by setting beta, because beta is defined as follows:

在此处输入图片说明

If we weight recall more important than precision(all relevant are selected) we can set beta as 2 and we get the F2 measure. And if we do the reverse and weight precision higher than recall(as much selected elements are relevant as possible, for instance in some grammar error correction scenarios like CoNLL) we just set beta as 0.5 and get the F0.5 measure. And obviously we can set beta as 1 to get the mostly used F1 measure(harmonic mean of precision and recall).

I think to some extent I have already answered why we do not use the arithmetic mean.

References:
1. https://en.wikipedia.org/wiki/F1_score
2. The truth of the F-measure
3. Information retrival