Clinic Survey
Part of the Statistics for ML section of Coddy's Machine Learning journey. Lesson 64 of 64.
A clinic asked 48 patients about their visit: age, visit type, minutes waited and satisfaction, from poor to excellent. It is all in clinic.csv.
What drives satisfaction? Two columns are text, so encode them first. Satisfaction has an order; visit types do not:
Then every column is a number, and one heatmap shows how everything relates. The manager also wants a report per visit type and the least satisfied age group.
Challenge
HardThe program reads a visit type. Round to 2 decimals.
- Map satisfaction to 1 to 4, one-hot
visitintoencoded(dtype=int), keep its correlations. - For the visit type: its visits, mean wait and satisfaction, and the share unhappy (2 or less) among them and overall.
- Bin ages at 17, 34, 54, 85 as
18-34,35-54,55-85; print the least satisfied. - Draw the matrix:
coolwarmfrom -1 to 1, a color bar, column names on both axes, titleClinic Survey.
For another clinic and urgent:
urgent: 16 visits, mean wait 30.44, mean satisfaction 2.44
Unhappy after urgent: 0.56 (overall 0.33)
Least satisfied: 35-54 (2.6)After your lines, Coddy describes your heatmap.
Try it yourself
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
visit = input()
df = pd.read_csv("clinic.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