EXERCISE
1Both measure spread, but one speaks your language and the other speaks math's language.
Save
Variance is measured in squared units. If your data is speed in km/h, variance is in km²/h². That is hard to interpret! Standard deviation brings it back to km/h — which your brain can actually understand.
When to use which:
| Metric | Units | Best For |
|---|---|---|
| Variance (σ²) | Squared (km²/h²) | Math formulas, comparing distributions |
| Std Dev (σ) | Original (km/h) | Interpreting spread, explaining to humans |
import numpy
# Temperature in °C
temps = [22.1, 23.4, 21.8, 24.0, 22.5]
var = numpy.var(temps)
std = numpy.std(temps)
print(f"Variance: {round(var, 2)} °C²")
# Output: Variance: 0.57 °C²
print(f"Std Dev: {round(std, 2)} °C")
# Output: Std Dev: 0.76 °C
# "Temperatures vary by about 0.76°C" makes sense
# "Temperatures vary by 0.57 degrees-squared" does not
Practical ML example — comparing feature spreads:
import numpy
heights = [165, 170, 175, 180, 185]
weights = [55, 65, 70, 80, 95]
print(f"Height variance: {numpy.var(heights)}")
# Output: Height variance: 50.0
print(f"Weight variance: {numpy.var(weights)}")
# Output: Weight variance: 170.0
# Weight has MORE spread — this matters when scaling features
> 💡 Key Insight: In ML, variance appears in the formula for many algorithms — (Principal Component Analysis) finds the direction of maximum variance, and is one of the most important concepts in model evaluation. You will meet variance again and again throughout your ML journey.