liveBook · Manning

Harmonic mean

As explained in Grokking Machine Learning, Second Edition

The harmonic mean of positive numbers is the reciprocal of the arithmetic mean of their reciprocals.

The harmonic mean combines two numbers while staying closer to the smaller one than the ordinary average. For numbers a and b, it is 2ab/(a + b). When both numbers are high, the result is high; when either is low, the result falls. section 7.10

Why the smaller value matters

Suppose recall is 50% and precision is 100%. Their ordinary average is 75%, which can hide the weak recall. The harmonic mean gives the lower score more influence. The same pattern appears with 1 and 9: their average is 5, while their harmonic mean is smaller. section 7.10

Use the equation view to inspect the harmonic-mean formula and its role in combining two scores. section 7.10

How Grokking Machine Learning, Second Edition covers it

How deep it goes
Defines the two-number formula, compares it with the ordinary average, and applies it to F1-score without broader derivation.
Examples
Uses precision of 100% with recall of 50%, plus the numerical pair 1 and 9.
What it assumes
Assumes familiarity with precision and recall while building from the ordinary average.
What you can do after
Evaluate/understand why F1-score penalizes an imbalance between precision and recall.
How it connects
Connects harmonic mean with precision, recall, F1-score, Fβ-score, and classification-model evaluation.

Also explained in

Compare how 2 books explain harmonic mean →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Machine Learning, Second Edition. The section links point to the parts of the book it draws on.