Notes

Kruskal-Wallis Test

The Kruskal-Wallis test is a way to check whether several groups look meaningfully different when you don’t want to assume the data are nicely bell-shaped. It’s especially handy when you have skewed measurements, outliers, or ordinal ratings (like 1–5 scores).

What it is (and what it tests)
The Kruskal-Wallis test is a non-parametric alternative to one-way ANOVA for comparing three or more independent groups. Instead of comparing group means directly, it converts all observations across groups into ranks (smallest to largest) and asks: are the ranks distributed similarly across groups? The null hypothesis is that all groups come from the same distribution (often interpreted as “same median” when group shapes are similar).

How it works (intuition)
Think of mixing everyone’s scores into one big list, sorting them, and giving each score a position number (its rank). If one group tends to occupy higher ranks, that group likely has larger values. The test statistic (often written as H) summarizes how far each group’s average rank deviates from what you’d expect if groups were truly alike, and it’s compared to a chi-square reference distribution (with a tie correction when values repeat).

Practical examples

  • Comparing house sale prices across 4 neighborhoods when prices are heavily skewed.
  • Comparing patient pain ratings (1–10) across 3 treatments.
  • Comparing model latency across 5 hardware setups with occasional extreme spikes.

Why it matters in AI/ML
In ML workflows, you often compare multiple models, preprocessing variants, or A/B/C experiments where metrics are non-normal (e.g., log-loss, latency, click-through rates). Kruskal-Wallis provides a robust global check for differences before doing post-hoc pairwise comparisons (commonly Dunn’s test) and helps avoid misleading conclusions that can arise when ANOVA’s assumptions fail.

The Kruskal-Wallis Test is a nonparametric alternative to one-way ANOVA that tests whether three or more independent groups come from the same distribution, using ranks rather than raw values. It is useful in AI/ML when metrics are non-normal, contain outliers, or are ordinal. Example: comparing model error distributions across multiple preprocessing pipelines to detect statistically meaningful performance differences.

Imagine you’re taste-testing three brands of coffee and rating each one, but your ratings are a bit messy—maybe they’re not nicely “bell-shaped,” and you don’t want to assume they are. The Kruskal-Wallis Test is a way to check whether several groups seem to come from the same “typical” level, without relying on that bell-curve assumption.

Instead of comparing averages directly, it mostly compares the ranks (who scored higher or lower). In AI and machine learning, it’s useful for asking whether different models, settings, or user groups produce noticeably different results when the data isn’t well-behaved.