Friedman Test and Nemenyi Post-Hoc Comparison
A two-step statistical procedure for comparing several models across multiple datasets — first a single test asking whether any differences exist at all, then a follow-up test identifying which specific pairs of models actually differ.
Prerequisites: Hypothesis Testing
Comparing more than two models across many datasets creates a multiple-comparisons problem: running a separate t-test for every pair of models inflates the chance of a false "significant" finding just from running so many tests. The standard fix is a two-stage procedure built around ranks rather than raw scores.
First, the Friedman test ranks all models on each dataset (best gets rank 1, and so on), then asks a single overall question: are the average ranks across models different enough that chance alone is an unlikely explanation? If the Friedman test rejects that null, a Nemenyi post-hoc test follows up by identifying which specific pairs of models have average ranks far enough apart to be considered meaningfully different.
The Friedman test asks a single question — do any of these models differ at all, based on their ranks across datasets — and only if it says yes does the Nemenyi test go on to identify which specific pairs actually differ, avoiding the false positives that pairwise testing alone would create.
Reading the result visually
The Nemenyi test's output is often shown as a "critical difference diagram": models are placed along a line by their average rank, and a bar (the critical difference) marks how far apart two average ranks must be before they're considered meaningfully different. Models whose ranks fall within that critical difference of each other are typically joined by a bar signaling "not distinguishable."
This pairing (Friedman then Nemenyi) is the standard, widely recommended way to compare multiple classifiers across multiple benchmark datasets in machine learning research.
Practice in interviews
Further reading
- Demšar, J., 'Statistical Comparisons of Classifiers over Multiple Data Sets' (2006)