Mean, median and spread: feel what each one does
Edit the numbers or drag the largest one far away. Watch which summary moves and which stays put.
Drag to push the largest value up to 10 times further away.
By hand, as on the slide
What to notice
- One extreme value drags the mean; the median hardly moves.
- Standard deviation is the typical distance from the mean: square the gaps, average them, take the square root.
- pandas
std()divides by count − 1, so it is a little larger than the by-hand (divide by count) value.
Try this
Histogram: the shape of a column, and the bins you choose
A histogram cuts the range into bins and counts the values in each. The same data can tell a different story with different bins.
Histogram
Point at a bar to see its range and count.
What to notice
- Too few bins hide the shape; too many make it look noisy. Try 5, 15 and 80.
- Two separate
plt.histcalls choose their own bin edges, so bars of ham and spam do not line up. - matplotlib silently skips missing values: check
isna().sum()so you know how many were left out.
Try this
Scatter and correlation: how tightly two columns move together
Build your own cloud of points, or look at real columns from students.csv. Then test your eye in the guessing game.
Guess the correlation
What to notice
- r measures how close the points are to a straight line, from −1 to +1. It is not the slope.
- One outlier can change r a lot when there are few points.
- In students.csv, hours and prior_gpa are almost unrelated (r near 0), yet hours clearly differ between passed and failed students (see tab 4). Correlation only looks for straight-line patterns between numbers.
- Correlation is not causation: a hidden third factor can drive both columns.
Try this
Box plot: the middle half, the median and the unusual values
The box holds the middle 50% of values, the line is the median, the whiskers reach the furthest values within 1.5 box-lengths, and dots are outliers.
What to notice
- Half the values are inside the box; a quarter are below it and a quarter above.
- "Outlier" here only means "beyond the whiskers": change
whisand the number of dots changes. - Box plots compare groups quickly; tick "show every value" to see what the box hides.