# Probability for ML

> Random variables, distributions, conditional probability and Bayes' rule, the vocabulary for uncertainty, likelihoods and loss functions. Free notes, key...

Canonical: https://www.internhack.in/roadmaps/tracks/machine-learning/probability
Last updated: 2026-11-28

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](https://www.internhack.in/roadmaps/tracks/machine-learning/numpy)

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](https://seeing-theory.brown.edu/) (Brown University)
- [Khan Academy: Statistics and probability](https://www.khanacademy.org/math/statistics-probability) (Khan Academy)
- [Mathematics for Machine Learning (probability chapter)](https://mml-book.github.io/) (Deisenroth, Faisal, Ong)

Previous: [Calculus and Gradients](https://www.internhack.in/roadmaps/tracks/machine-learning/calculus-gradients) · Next: [Statistics for Data Science](https://www.internhack.in/roadmaps/tracks/machine-learning/statistics)

## More in The Math Behind the Models

- [Linear Algebra for ML](https://www.internhack.in/roadmaps/tracks/machine-learning/linear-algebra)
- [Calculus and Gradients](https://www.internhack.in/roadmaps/tracks/machine-learning/calculus-gradients)
- [Probability for ML](https://www.internhack.in/roadmaps/tracks/machine-learning/probability)
- [Statistics for Data Science](https://www.internhack.in/roadmaps/tracks/machine-learning/statistics)
- [Optimization and Gradient Descent](https://www.internhack.in/roadmaps/tracks/machine-learning/optimization)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Machine Learning Engineer Roadmap](https://www.internhack.in/roadmaps/tracks/machine-learning)
