Probability for ML
Random variables, distributions, conditional probability and Bayes' rule, the vocabulary for uncertainty, likelihoods and loss functions.
Beginner · about 12 hours · difficulty 3/5
Learn first: NumPy and Array Thinking
Classifiers output probabilities, losses are negative log-likelihoods, and many models (naive Bayes, Gaussian mixtures, VAEs) are explicitly probabilistic. Probability lets you interpret all of them.
Concepts
- Random variables, PMFs and PDFs; expectation and variance.
- Key distributions: Bernoulli, binomial, categorical, Poisson, uniform, Gaussian (and the multivariate Gaussian).
- Joint, marginal and conditional probability; independence.
- Bayes' rule: updating beliefs from evidence; base rates and why rare-event classifiers produce many false positives.
- Likelihood and maximum likelihood estimation: MSE corresponds to a Gaussian likelihood, cross-entropy to a categorical one.
- Entropy, cross-entropy and KL divergence: the information-theory terms used in loss functions and generative models.
Practice
Simulate. Sample from distributions with NumPy, estimate means and probabilities empirically, and compare with the formulas. Simulation builds intuition faster than algebra alone.
Good enough to move on when you can explain why minimizing cross-entropy is the same as maximizing likelihood for a classifier.
Key concepts
- Random variables and expectation
- Common distributions
- Conditional probability and independence
- Bayes' rule
- Maximum likelihood estimation
- Entropy, cross-entropy and KL divergence
- Multivariate Gaussian
Mini project
Simulate a medical test with 1% prevalence, 95% sensitivity and 90% specificity for 100,000 people and compare the empirical probability of disease given a positive test to the Bayes' rule answer.
Check yourself
A fraud model flags 1,000 transactions with a 2% true fraud base rate. Why can precision be low even when recall and specificity look good?
Free resources
- Seeing Theory: a visual introduction to probability (Brown University)
- Khan Academy: Statistics and probability (Khan Academy)
- Mathematics for Machine Learning (probability chapter) (Deisenroth, Faisal, Ong)