Guide To AI LogoGuide To AI
Unit 11

Statistics for Machine Learning

analyzing data, estimating patterns, and understanding uncertainty in machine learning models

Core Concepts Covered

  • Descriptive vs. inferential statistics
  • Hypothesis testing, confidence intervals, and significance testing
  • Maximum Likelihood Estimation (MLE) and parameter estimation

1. Descriptive vs. Inferential Statistics (Bessel's Correction)

Statistics provides the mathematical framework to summarize datasets, detect hidden patterns, and draw conclusions under uncertainty. It is broadly divided into two domains:

Descriptive Statistics: Summarizes the numerical properties of an observed sample (such as the sample mean xˉ=1nxi\bar{x} = \frac{1}{n} \sum x_i and sample variance s2s^2).

Why Bessel's Correction (n1n-1) is Crucial: When computing sample variance, we divide by n1n-1 rather than nn:

s2=1n1i=1n(xixˉ)2s^2 = \frac{1}{n-1} \sum_{i=1}^n (x_i - \bar{x})^2

Dividing by nn underestimates the true population variance because the sample data points are naturally closer to their own sample mean xˉ\bar{x} than they are to the true, unobserved population mean μ\mu. Dividing by n1n-1 (Bessel's Correction) mathematically corrects this bias, providing an unbiased estimator of the population variance.

Inferential Statistics: Uses sample data to make generalized predictions, test claims, or draw conclusions about a larger, unobserved population.

2. Hypothesis Testing, p-values, and A/B Testing

In machine learning, we use hypothesis testing to determine if our model improvements are statistically genuine or merely the result of random noise.

The A/B Test Example: Suppose your baseline model (A) has an accuracy of 80%80\%. You develop a new model (B) and test it on a sample of 100100 users, achieving an accuracy of 83%83\%. Is this 3%3\% improvement genuine, or did you just get lucky with a favorable sample of users? We resolve this using hypothesis testing:

Null Hypothesis (H0H_0): The default assumption that there is no real difference or effect (e.g., 'Model B has the same performance as Model A; the 3%3\% difference is random noise').

Alternative Hypothesis (HaH_a): The claim we want to prove (e.g., 'Model B is genuinely superior to Model A').

Significance Level (α\alpha): The threshold of risk we are willing to accept (typically set to 0.050.05 or 5%5\%). It is the probability of rejecting H0H_0 when it is actually true (Type I error).

The pp-value: The probability of observing an accuracy difference of 3%3\% or greater if the null hypothesis H0H_0 is true. If the calculated pp-value is below our significance level α\alpha (e.g., pp-value =0.01<0.05= 0.01 < 0.05), we reject the null hypothesis in favor of the alternative, concluding that Model B is statistically superior!

Confidence Intervals (CI): A range of values likely to contain the true population parameter with a specified confidence level (e.g., 95%95\% confidence interval: xˉ±zsn\bar{x} \pm z^* \frac{s}{\sqrt{n}}).

3. Parameter Estimation & Maximum Likelihood (MLE)

Machine learning is essentially the search for optimal parameters. We find these parameters using parameter estimation frameworks, most notably Maximum Likelihood Estimation (MLE).

The goal of MLE is to find the parameter values θ\theta that maximize the likelihood of observing our actual dataset DD. Assuming samples are independent and identically distributed (i.i.d.), the joint likelihood is the product of individual sample probabilities: L(θ)=i=1nP(xiθ)L(\theta) = \prod_{i=1}^n P(x_i | \theta)

Because multiplying probabilities causes numerical underflow, we maximize the log-likelihood function instead: lnL(θ)=i=1nlnP(xiθ)\ln L(\theta) = \sum_{i=1}^n \ln P(x_i | \theta)

The Coin-Flip Derivation: If we flip a coin nn times and observe kk heads (successes), we model this using a Bernoulli distribution with success parameter θ\theta. The likelihood function is: L(θ)=θk(1θ)nkL(\theta) = \theta^k (1 - \theta)^{n-k} Taking the natural log converts the exponent multiplication into addition: lnL(θ)=kln(θ)+(nk)ln(1θ)\ln L(\theta) = k \ln(\theta) + (n-k) \ln(1 - \theta) To find the parameter value that maximizes this log-likelihood, we take the derivative with respect to θ\theta, set it to 0, and solve: ddθlnL(θ)=kθnk1θ=0\frac{d}{d\theta} \ln L(\theta) = \frac{k}{\theta} - \frac{n-k}{1-\theta} = 0 kθ=nk1θ    k(1θ)=θ(nk)\frac{k}{\theta} = \frac{n-k}{1-\theta} \implies k(1-\theta) = \theta(n-k) kkθ=nθkθ    θMLE=knk - k\theta = n\theta - k\theta \implies \theta_{\text{MLE}} = \frac{k}{n} This proves mathematically that our intuitive estimate—the proportion of observed heads—is the mathematically optimal parameter maximizing the likelihood of our observations!

Interactive Practice Quiz

Test your understanding with instant feedback

QUESTION 01

Why do we divide by n1n-1 instead of nn when calculating the Sample Variance s2s^2?

QUESTION 02

If a hypothesis test yields a pp-value of 0.010.01 and we set our significance level α=0.05\alpha = 0.05, what is our conclusion?

QUESTION 03

Which of the following describes the objective of Maximum Likelihood Estimation (MLE)?

QUESTION 04

Why do we maximize the 'Log-Likelihood' instead of the raw 'Likelihood' function in MLE?

QUESTION 05

In a coin-flip experiment with a Bernoulli distribution, if you observe 12 heads in 20 trials, what is the MLE value of the success probability parameter θ\theta?

QUESTION 06

Which of the following describes the difference between Descriptive and Inferential Statistics?

QUESTION 07

In hypothesis testing, what is a 'Type I Error'?

QUESTION 08

In hypothesis testing, what does a 'Type II Error' represent?

QUESTION 09

What is the correct interpretation of a '95% Confidence Interval' for a population mean?

QUESTION 10

If we observe kk successes in nn independent Bernoulli trials, what is the log-likelihood function lnL(θ)\ln L(\theta) for the success parameter θ\theta?