Probability Basics
Quantifying uncertainty — the language of all machine learning
Free tier: read the explanation here. Upgrade to Pro for Drills, Speed challenges & Mastery badges.
UpgradeKnowledge Debt detected
You can study this freely — but your score may plateau if these foundations have gaps. The Mastery badge requires them to be solid.
Explanation
Probability measures how likely an event is to occur, from 0 (impossible) to 1 (certain).
P(event) = favorable outcomes / total outcomes
P(heads) = 1/2 = 0.5Key rules:
Complement rule: P(not A) = 1 - P(A) `` P(not rain) = 1 - P(rain) = 1 - 0.3 = 0.7
Addition rule (OR):
- Mutually exclusive: P(A or B) = P(A) + P(B)
- Not exclusive: P(A or B) = P(A) + P(B) - P(A and B)
Multiplication rule (AND) — independent events:
P(two heads in a row) = 0.5 × 0.5 = 0.25
Why data scientists need this: Every ML model output is a probability. A classifier doesn't say "this is a cat" — it says "there is a 0.94 probability this is a cat."
Examples
Basic probability calculations
Independence means we can multiply probabilities
# P(rolling a 6) = 1/6
print(1/6) # 0.1667
# P(rolling a 6 twice in a row)
print((1/6) * (1/6)) # 0.0278
# P(rolling 1 OR 2)
print((1/6) + (1/6)) # 0.333How well did you understand this?
Next in Mathematics for Data Science
Conditional Probability