Shapes of Data
Part of the Statistics for ML section of Coddy's Machine Learning journey. Lesson 8 of 64.
A histogram's outline is the data's shape, and it tells you which summary to trust:
A long tail pulls the mean toward it, while the median stays with the crowd. Seconds eleven visitors spent on a page:
visits = np.array([8, 12, 15, 15, 18, 20, 22, 25, 40, 75, 140])
print(np.round(visits.mean(), 1), np.median(visits))This prints:
35.5 20.0Mean above median: right-skewed, a tail of big values. Mean below: left-skewed. Close together: symmetric.
Skew is a warning before training: a few extreme rows sit far from the rest, and the mean describes almost nobody.
Challenge
EasyBefore training on 150 players' logs, a game team checks the shape of each column of players.csv. For each column, in order, print its name, its mean (1 decimal), its median and a verdict:
- right-skewed when the mean is more than 2 above the median,
- left-skewed when it is more than 2 below,
- symmetric otherwise.
For another game's log:
session_minutes: mean 14.3 above median 9.5, right-skewed
quiz_score: mean 83.3 below median 88.0, left-skewed
ping_ms: mean 46.4 close to median 46.0, symmetricTry it yourself
import numpy as np
import pandas as pd
players = pd.read_csv("players.csv")
# Write your code below
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Statistics for ML
1Center and Spread
Mean and MedianPercentiles and QuartilesVariance and StdSample or Population?The Most Common ValueRecap: Delivery Times4Samples and Populations
Population and SampleSample Means VaryThe Sampling DistributionBigger Samples, Less NoiseRecap: Polling a Town2Distributions
Density HistogramsShapes of DataThe Normal CurveThe 68-95-99.7 RuleZ-ScoresRecap: Battery Life3Probability by Simulation
Probability as FrequencyThe Law of Large NumbersSums of DiceExpected ValueConditional ProbabilityRecap: Dice Stall Odds6Relationships
Reading Scatter PlotsCorrelationCorrelation MatrixCorrelation HeatmapsCorrelation Is Not CauseRecap: Ice Cream and SunPractice on your own: Online Python compiler