Why this matters
Sometimes there is no label to predict. A mobile money agent network might want to understand its customers before designing new services, or an NGO might want to see which villages have similar needs. Unsupervised learning looks for structure in data without answers to learn from. It is less common in job adverts than prediction, which is why this topic is optional, but it is a useful tool for exploring data and starting conversations.
Clustering
Clustering groups records that are similar to each other. The most common method is k means:
- You choose how many groups you want, called k.
- The algorithm places k centre points.
- Each record joins its nearest centre.
- Each centre moves to the middle of its group.
- Steps 3 and 4 repeat until the groups stop changing.
The result is a group number for every record. The algorithm does not tell you what the groups mean. You work that out by looking at them.
Scale matters
k means measures distance between records. If one column is transfers per month (1 to 60) and another is average amount in cedis (5 to 800), the cedi column dominates simply because its numbers are bigger. Scale the columns first so each has a similar range. StandardScaler does this.