Fractions, ratios and rates
Why this matters
Most numbers in AI work are fractions in disguise. A click rate is clicks over views. A model's accuracy is right answers over all answers. When a model is "0.73 sure", that's a share of one whole. Mix up a count with a rate, or a percent with a percentage point, and you'll back the wrong campaign or misread a result. This lesson makes fractions, rates and ratios second nature, with Python doing the arithmetic.
- Turn a fraction into a decimal and a percentage, and back again
- Compare groups of different sizes with rates instead of counts
- Tell a percent change from a change in percentage points
- Scale amounts up and down with a ratio, and compare unit prices
a = 30 / 200 b = 45 / 450 print(a, b)
A fraction is a division
A fraction says how much of a whole you have. 3/4 of a pizza means it was cut into 4 equal slices and you have 3. The line in the middle means divide: 3 ÷ 4 = 0.75. The same amount can be written three ways:
| fraction | decimal | percent |
|---|---|---|
| 3/4 | 0.75 | 75% |
| 1/2 | 0.5 | 50% |
| 1/8 | 0.125 | 12.5% |
Fractions that look different can be the same share: 3/4, 6/8 and 75/100 are all 0.75. Dividing turns each one into a single number, which is the easiest way to compare them.
Percent means "out of a hundred", so to turn a decimal into a percent, multiply by 100. To go back, divide by 100:
part = 3 whole = 8 share = part / whole print(share) # as a decimal print(share * 100, "%") # as a percent print(25 / 100) # 25% back as a decimal