Learn / Unsupervised
Unsupervised learning
Finding structure when nobody has labelled the data. Clustering groups rows, dimensionality reduction compresses columns.
On this page
Intuition
There is no answer column. The algorithm is asked a looser question (what goes together, what are the main directions of variation, what looks unusual), and it is your job to decide whether the structure it finds means anything.
That last part is the catch. A supervised model can be scored against the truth. An unsupervised one always returns something: ask k-means for five clusters in pure noise and you will get five clusters.
What the data looks like
Unsupervised data has the same shape as supervised data, minus the answer column. That missing column is the whole difference.
| rowcustomer | inputavg_balance_lei | inputpayments_month | inputcard_share | inputapp_logins_month |
|---|---|---|---|---|
| C-2001 | 1200 | 38 | 0.82 | 41 |
| C-2002 | 64000 | 6 | 0.1 | 3 |
| C-2003 | 2100 | 45 | 0.91 | 52 |
| C-2004 | 58000 | 4 | 0.05 | 2 |
There is no label. Clustering will group similar rows; dimensionality reduction will summarise the columns. You judge whether the result means something.
Example rows are invented for illustration.
The two tasks
| Clustering | Dimensionality reduction | |
|---|---|---|
| Works on | Rows | Columns |
| Output | A group for each point | Fewer coordinates for each point |
| Question | Which customers behave alike? | What are the few numbers that summarise this customer? |
- Clustering: k-means, DBSCAN, Gaussian mixtures and hierarchical clustering.
- Dimensionality reduction: PCA, Kernel PCA, t-SNE and UMAP.
How the data is prepared
Everything here is driven by distance or variance, so scale decides the result. Standardise numeric features, pick a distance metric that fits the data (cosine for embeddings), and deal with outliers before they define a cluster or a component on their own. See data preparation for a demo.
How to judge the result
- Internal metrics such as inertia and silhouette say how tight and separated the groups are. They do not say whether they are useful.
- Stability: do you get the same structure with a different seed or a different sample?
- Usefulness: can a domain expert name the segments, and would they act differently on each?
Pitfalls
- Reading meaning into clusters that exist only because the algorithm had to produce k of them.
- Interpreting distances between clusters in a t-SNE or UMAP plot.
- Forgetting to scale.