Concepts 🚀 Project 🧮 Labs
🧮 Labs / ML Advanced / Probability for ML — Bayes, distributions, maximum likelihood

Probability for ML — Bayes, distributions, maximum likelihood

ML is applied probability. Understand Bayes' theorem, common distributions, and maximum likelihood estimation.

script.py v3.1
Python output click Run to execute
Click "Run" to execute the code on the left.
The output will appear here.
🧠 How it works

ML = applied probability. 3 concepts to know: BAYES' THEOREM: P(A|B) = P(B|A)*P(A)/P(B). Update beliefs with evidence. Used in: Naive Bayes, Bayesian inference, A/B testing. Base rate fallacy: people ignore P(A). 80% of spam has 'FREE' ≠ most 'FREE' emails are spam. DISTRIBUTIONS: know the shape of your data. Normal — symmetric (height, age, errors). Lognormal — right-skewed (income, prices). Log-transform to make normal. Uniform — flat (random sampling). Bernoulli — 0/1 (click/no-click). Binomial — count of successes (# heads in N flips). Poisson — count of events per period (# emails/hour). MLE (Maximum Likelihood Estimation): find params that make data MOST LIKELY. LinearRegression = MLE of Gaussian noise. LogisticRegression = MLE of Bernoulli. Cross-entropy loss = MLE of categorical. MLE is the bridge: probability theory → ML training. Understand these 3 = understand why ML models use the loss functions they do.

✏️ Try these changes
  • Change P(A) from 0.3 to 0.5
    → P(spam|FREE) jumps — base rate matters
  • Change the Bernoulli p from 0.7 to 0.3
    → bar chart flips — more 0s than 1s
  • Change Poisson lambda from 3 to 10
    → distribution shifts right — more events per period
  • Change the MLE example: 70 heads in 100 flips
    → MLE = 0.7 still, but confidence higher