Difference in Means
Part of the Statistics for ML section of Coddy's Machine Learning journey. Lesson 42 of 64.
Is a new model, page or keyboard better? Compare the groups by their difference in means: one group's mean minus the other's. Ten typists each tried one layout:
typing = pd.DataFrame({
"layout": ["Qwerty", "Dvorak", "Qwerty", "Dvorak", "Qwerty", "Dvorak", "Qwerty", "Dvorak", "Qwerty", "Dvorak"],
"wpm": [68, 76, 74, 65, 61, 82, 79, 70, 66, 74],
})
means = typing.groupby("layout")["wpm"].mean()
print(np.round(means["Dvorak"] - means["Qwerty"], 2))This prints 3.8: Dvorak typists averaged 3.8 more words per minute. Qwerty minus Dvorak gives -3.8, so say which group comes first.
Is 3.8 big? Single typists spread over 20 words per minute, so the luck of who got which keyboard could make this gap alone.
Challenge
MediumStudents practiced with one of two math apps. math_apps.csv has app (algo or numo), score and sets; the program reads one number column's name.
- Compute the numo mean minus the algo mean of that column.
- Let its sign pick the app ahead, and print the line below: the gap positive, the leader's mean first, all to 2 decimals.
For other students and the input score:
algo is ahead on score by 4.0 (151.0 vs 147.0)Try it yourself
import numpy as np
import pandas as pd
students = pd.read_csv("math_apps.csv")
column = input()
# 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 Life8Comparing Groups
Box Plots by GroupDifference in MeansCould It Be Chance?P-ValuesThe t-TestRecap: A/B Test3Probability 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