A small bookshop wants to group its loyalty-card customers. For each customer it has two numbers:
[0] money spent this year, in pounds (hundreds or thousands)[1] visits per month (between 1 and about 20)Those columns live on very different scales, so the shop scales them first.
Task: write customer_groups(customers, k).
StandardScaler().fit_transform(...).KMeans(n_clusters=k, random_state=0, n_init=10) on the scaled data.Cluster numbers are arbitrary, so only who is grouped with whom counts.