Statistics for Machine Learning

Last Updated 05 Sep, 2026

Before a model can learn anything, someone has to understand the data it's learning from — and that's what statistics is for. It's the discipline of collecting, summarizing, and drawing conclusions from data, and it underpins nearly every decision made before, during, and after training a model: which features matter, whether an algorithm is a good fit, and whether a reported improvement is real or just noise.

Statistics for ML splits into two branches: descriptive statistics, which summarizes the data you have, and inferential statistics, which uses a sample to draw conclusions about a larger population. Both show up constantly in applied work — feature engineering, anomaly detection, quality control, and experiment design all lean on one or the other.

Descriptive Statistics: Summarizing What You Have

Mean, Median, and Mode

  • Mean — the sum of all values divided by the count. Sensitive to extreme values.
  • Median — the middle value once data is sorted. Unaffected by extreme outliers.
  • Mode — the most frequently occurring value.

These three don't always agree, and when they disagree, that disagreement tells you something important about your data.

Mean, Median, and Mode

Income data is a classic example: a small number of very high earners pull the mean upward, while the median stays closer to what a "typical" person actually earns. If you feed a model a feature like this without knowing its shape, you can badly misjudge what "average" means for your users.

Measures of Dispersion

The mean alone says nothing about how consistent your data is. Dispersion measures fill that gap:

  • Range — max value minus min value. Simple, but sensitive to a single extreme point.
  • Variance — the average squared deviation from the mean.
  • Standard deviation — the square root of variance, back in the original units, and the more interpretable of the two.
  • Interquartile range (IQR) — the range between the 25th and 75th percentile, a spread measure that ignores outliers entirely and is often preferred for skewed data.

In practice, this is why feature scaling (standardization) exists: subtracting the mean and dividing by the standard deviation puts every feature on comparable footing, so a feature measured in the thousands doesn't dominate one measured in single digits purely because of its scale.

Measures of Shape: Skewness and Kurtosis

Skewness describes asymmetry — whether the tail of a distribution stretches more to one side.

Measures of Shape: Skewness

Right-skewed data (like income, transaction amounts, or wait times) is common in real-world ML datasets. Many models assume roughly symmetric, normally distributed inputs — spotting skew early tells you whether a log transform or similar fix is needed before training.

Kurtosis describes how much of the data's variance comes from rare, extreme values — how "heavy" the tails are.

Measures of Shape: Kurtosis

High kurtosis (leptokurtic) means extreme values are more common than a normal distribution would predict — a warning sign in financial and fraud-related data, where "rare" outlier events happen more often than a naive model expects, and risk models that ignore this routinely underestimate tail risk.

Inferential Statistics: Reasoning About What You Don't Have

Inferential statistics uses a sample — a subset of data — to draw conclusions about a population — the full group you actually care about. Almost no ML system is trained on "all the data that will ever exist," so every model is, in a sense, making an inferential claim: that patterns in the training sample will generalize.

Estimation

  • Point estimation gives a single best-guess value for a population parameter (e.g., "the average session length is 4.2 minutes").
  • Interval estimation gives a range — a confidence interval — that's more honest about the uncertainty involved (e.g., "between 3.9 and 4.5 minutes, with 95% confidence").

Hypothesis Testing

Hypothesis testing is how you decide whether an observed effect is likely real or could plausibly be due to chance:

  • Null hypothesis (H₀) — the default assumption of no effect or no difference.
  • Alternative hypothesis (H₁) — what you're trying to find evidence for.
  • Type I error — rejecting a true null hypothesis (a false positive — declaring an effect that isn't real).
  • Type II error — failing to reject a false null hypothesis (a false negative — missing a real effect).
  • p-value — the probability of seeing results this extreme if the null hypothesis were actually true. A small p-value is evidence against the null.
  • t-tests and z-tests — compare means between groups.
  • ANOVA — compares means across more than two groups at once.
  • Chi-square tests — test whether categorical variables are associated.

This entire toolkit is what sits behind a legitimate A/B test: before shipping a new recommendation algorithm because it "performed better" in an experiment, hypothesis testing is what tells you whether that improvement is statistically meaningful or within the range of normal random variation.

Covariance and Correlation

Covariance measures whether two variables move together, though its scale depends on the units of the data, which makes it hard to interpret directly:

Cov(x, y) = Σ(xᵢ − x̄)(yᵢ − ȳ) / n

Correlation standardizes this into a unitless number between -1 and 1 (Pearson's coefficient is the most common version):

ρ(X, Y) = Cov(X, Y) / (σₓ · σᵧ)

Correlation

Correlation is a core feature-selection tool — features highly correlated with the target are worth keeping, and features highly correlated with each other (multicollinearity) can destabilize a model's coefficients. It's worth remembering the classic caveat: correlation alone never proves that one variable causes the other.

Spearman rank correlation is a related measure that captures monotonic relationships (variables that consistently move together, even if not in a straight line) — useful when data is ordinal or clearly non-linear.

Regression Analysis

Regression models the relationship between a dependent variable and one or more predictors:

  • Simple linear regression — one predictor.
  • Multiple linear regression — several predictors combined.
  • Its validity rests on assumptions: linearity, independence of errors, homoscedasticity (constant error variance), and normality of residuals — assumptions worth checking, not just assuming.
  • Model evaluation typically uses R-squared (variance explained), adjusted R-squared (penalized for extra predictors), and RMSE (average prediction error in the original units).

The Law of Large Numbers and Central Limit Theorem

Two theorems justify why statistics works at all in ML:

  • Law of Large Numbers — as sample size grows, the sample mean converges toward the true population mean. It's why training on more data generally produces more reliable estimates.
  • Central Limit Theorem — the distribution of sample means approaches a normal distribution as sample size increases, regardless of the shape of the underlying population. This is what allows confidence intervals and many hypothesis tests to be valid even when the raw data itself isn't normally distributed.

Bayesian Statistics

Bayesian statistics treats probability as a degree of belief that gets updated as new evidence arrives, combining what you already believed (the prior) with what the data shows (the likelihood):

P(A | B) = P(B | A) × P(A) / P(B)

Where P(A | B) is the posterior (updated belief), P(B | A) is the likelihood, P(A) is the prior, and P(B) is the overall probability of the evidence. This framework underlies Naive Bayes classifiers, Bayesian A/B testing (which updates conclusions continuously rather than waiting for a fixed sample size), and Bayesian optimization used in hyperparameter tuning.

Why This All Matters Before You Train a Model

Statistics isn't a formality that happens before the "real" machine learning starts — it's the reason you can trust any of it. Descriptive statistics tells you what your data actually looks like. Inferential statistics tells you whether your sample can be trusted to represent reality. And once a model is deployed, the same tools — confidence intervals, hypothesis tests, correlation checks — are what tell you whether it's still performing the way you think it is.