Recap: Gym Members
Part of the Unsupervised Learning section of Coddy's Machine Learning journey. Lesson 5 of 51.
Challenge
EasyRemember the cafe visits that opened this chapter? A gym wants the same for its floor: what kinds of members come in? members.csv holds each member's average minutes of cardio and of weights per visit.
- Fit KMeans: 3 clusters,
n_init=10,random_state=0. - For each group, biggest first, print its size, its center and its most typical member: the one nearest the center.
- Scatter each group labelled with its size, like
55 members, then black stars labelledcenters, a legend, and show.
For another gym:
Groups, biggest first:
45 members: 39 min cardio, 15 min weights (most typical: Rosa P.)
30 members: 20 min cardio, 47 min weights (most typical: Finn A.)
15 members: 56 min cardio, 46 min weights (most typical: Lu W.)and its chart:
Then Coddy describes your chart.
Try it yourself
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from sklearn.cluster import KMeans
# One row per member: average minutes of cardio and of weights per visit
members = pd.read_csv("members.csv")
X = members[["cardio_min", "weights_min"]]
fig, ax = plt.subplots()
ax.set_title("Gym Members")
ax.set_xlabel("Cardio (min per visit)")
ax.set_ylabel("Weights (min per visit)")
# Write your code below
All lessons in Unsupervised Learning
1Finding Groups
Learning Without LabelsMeasuring SimilarityK-Means by HandK-Means in scikit-learnRecap: Gym Members7PCA in Practice
Seeing 64 DimensionsComponents as PatternsCompress and RebuildPCA Before a ModelRecap: Face Scanner10Project: Digit Explorer
Look at the DigitsShrink with PCACluster the DigitsName the ClustersFind the Odd OnesPractice on your own: Online Python compiler