What Is Probability?
From 0 to 1.
Will it rain tomorrow? Will this email turn out to be spam? Will this customer buy? Machine learning models rarely say yes or no. They say how likely. Probability is the language of how likely.

- Rain? Spam? Buy?
- Models say how likely
- Probability
The basics
A probability is a number between zero and one. Zero means impossible, and one means certain. A half means fifty fifty, like a fair coin landing heads. When all outcomes are equally likely, the probability of an event is the number of ways it can happen, divided by the number of possible outcomes.
| key | value |
|---|---|
| 0 | impossible |
| 1 | certain |
| 0.5 | a fair coin |
| Equal outcomes | ways ÷ total |
Rolling a die
A die has six equally likely faces. The probability of rolling a six is one out of six. The probability of an even number is three out of six, which is a half. And the probability of not rolling a six is one minus a sixth. Run it.
from fractions import Fraction
faces = [1, 2, 3, 4, 5, 6]
six = Fraction(1, len(faces))
even = Fraction(len([f for f in faces if f % 2 == 0]), len(faces))
print("P(six) =", six)
print("P(even) =", even)
print("P(not six) =", 1 - six)P(six) = 1/6 P(even) = 1/2 P(not six) = 5/6
Summary
Probability measures how likely something is, from zero to one. With equal outcomes, it's ways divided by total. Next, simulating chance with code.
Key takeaways- 0 impossible, 1 certain
- ways ÷ total
- P(not A) = 1 − P(A)