I wonder what is an intrinsic value of using harmonic mean (for instance to calculate F-measures), as opposed to weighted arithmetic mean in combining precision and recall? I am thinking that weighted arithmetic average could play the role of harmonic mean, or am I missing something?
-
9$\begingroup$ The harmonic mean is a weighted arithmetic mean: each $x_i$ has a weight proportional to $1/x_i^2$. $\endgroup$– whuber ♦Commented Feb 12, 2018 at 18:24
-
$\begingroup$ Can you say more about how precision and recall are combined in this fashion? $\endgroup$– AdamOCommented Feb 12, 2018 at 20:54
-
6$\begingroup$ @whuber Not sure if your comment is serious or tongue-in-cheek. Weights are usually assumed to be a function of the sample index, not of the sample value. Otherwise any mean is a weighted arithmetic mean $\endgroup$– Luis MendoCommented Feb 12, 2018 at 23:47
-
2$\begingroup$ @Luis The truth lies in between. The sample index often is meaningless. Weights are functions of the objects, but those functions typically do not depend on the values being averaged. Examples are weights associated with times (EWMA), with location (as in measures of spatial correlation), rank (as in the Shapiro-Wilk test), and sampling probabilities. But not all means are weighted AMs: the GM is not, for instance. Since Filippa asks about the "instrinsic value," it seemed germane to point out the mathematical relationship between the harmonic mean and weighted means. $\endgroup$– whuber ♦Commented Feb 13, 2018 at 13:37
2 Answers
In general, harmonic means are preferred when one is trying to average rates, instead of whole numbers. In the case of an F1-measure, a harmonic mean will penalize very small precisions or recalls whereas the unweighted arithmetic mean won't. Imagine averaging 100% and 0%: Arithmetic mean is 50% and Harmonic mean is 0%. The harmonic mean requires that both precision and recall be high.
In addition, when the precision and recall are close together, the harmonic mean will be close to the arithmetic mean. Example: the harmonic mean of 95% and 90% is 92.4% compared to the arithmetic mean of 92.5%.
Whether this is a desirable property is probably dependent on your use case, but typically it's considered good.
Finally, note that, as @whuber stated in the comments, the harmonic mean is indeed a weighted arithmetic mean.
-
2$\begingroup$ "harmonic means are preferred when one is trying to average rates" Perhaps if you travel $10$km out at $120$ km/h and $10$km back at $60$km/h to get an average overall speed of $80$km/h, though not if you travel $10$ minutes at $120$ km/h and $10$ minutes at $60$km/h to get an average overall speed of $90$km/h. But I do not see why that applies to fractions $\endgroup$– HenryCommented Feb 13, 2018 at 8:23
-
$\begingroup$ Indeed, the first paragraph is more of a general statement on the harmonic mean. But you're right, precision and recall are fractions and not rates. I believe there is a notion that an arithmetic average is preferred for values that have an interpretable summation (which wouldn't apply in this case), but certainly one can take an arithmetic average of precision and recall and output a useful result. $\endgroup$– ilanmanCommented Feb 13, 2018 at 15:41
-
$\begingroup$ Excellent! I'm more looking for "justifications" for using harmonic averaging rule. But I'm not sure how to think about the justifications.. $\endgroup$– olgaCommented Feb 20, 2018 at 1:54
The harmonic mean may be a handy substitute to the arithmetic mean when the latter has no expectation or no variance. It may indeed be the case that $\mathbb{E}[X]$ does not exist or is infinite, while $\mathbb{E}[1/X]$ exists. For instance, the Pareto distribution with density$$f(x)=\dfrac{\alpha x_0^{\alpha}}{x^{\alpha+1}}\mathbb{I}_{x\ge x_0}$$has no finite expectation when $\alpha\le 1$, which implies that the arithmetic mean has an infinite expectation, while$$\mathbb{E}[1/X]=\int_{x_0}^\infty \dfrac{\alpha x_0^{\alpha}}{x^{\alpha+2}}\,\text{d}x=\dfrac{\alpha x_0^{\alpha}}{(\alpha+1) x_0^{\alpha+1}}=\dfrac{\alpha}{(\alpha+1) x_0}$$which implies that the harmonic mean has a finite expectation.
Conversely, there are distributions for which the harmonic mean has no expectation, as for instance the Beta $\mathcal{B}e(\alpha,\beta)$ distribution when $\alpha\le1$. And many more for which it has no variance.
There is also a link with Monte Carlo approximations to integrals, and particularly normalising constants, based on the Bayesian posterior identity$$\mathbb{E}\left[\dfrac{\varphi(\theta)}{\pi(\theta)L(\theta|x)}\Big| x\right]=\dfrac{1}{m(x)}$$where $\varphi(\cdot)$ is any density, $\pi(\cdot)$ is the prior, $L(\cdot|x)$ the likelihood, and $m(\cdot)$ the marginal, as discussed on that other question on X validated, where I comment on the dangers of using what Radford Neal (U Toronto) calls the worst Monte Carlo estimator ever. (I also wrote several entries on my blog on that topic.)
-
2$\begingroup$ Why are these properties preferable when averaging rates? $\endgroup$ Commented Feb 12, 2018 at 21:38
-
$\begingroup$ I do not know of optimality results, but having an estimator with a finite expectation seems preferable to one without! $\endgroup$– Xi'anCommented Feb 14, 2018 at 13:29