AI Compass
Compass

Unsupervised learning

Finding structure in data without anyone saying which structure. What it is good for, where it is overrated, and how to judge a result at all.

·2 min read·By Fachredaktion Technik
DETAIL
3 sections

The idea

You tip a box of screws onto a table and sort them without anyone naming the categories. By length? By head shape? By thread? Every sorting is correct, and which one is useful depends on what you plan to do next.

Unsupervised learning works exactly like that: it finds an order, but the meaning is yours to supply.

What it is good for

  • Discovering customer groups before anyone has defined segments.
  • Flagging unusual transactions, such as conspicuous bookings.
  • Condensing very many features into a few so a chart becomes readable.
  • Grouping similar documents before anyone reads them.

Methods by task

TaskMethodWhen it fits
Find groupsk-means, HDBSCANSpherical groups / arbitrary shapes with noise
Estimate densityGaussian mixturesSoft membership, probabilities needed
Find outliersIsolation Forest, One-Class SVMFew, unknown anomalies
Reduce dimensionsPCA, UMAPPreprocessing / display
Find topicsNMF, BERTopicSurveying a text corpus
import numpy as np
from sklearn.cluster import KMeans
from sklearn.metrics import silhouette_score
from sklearn.preprocessing import StandardScaler

rng = np.random.default_rng(0)
X = np.vstack([rng.normal(m, 0.6, (120, 2)) for m in ([0,0], [4,4], [0,5])])
X = StandardScaler().fit_transform(X)     # without scaling, the feature with
                                          # the largest unit dominates
for k in range(2, 7):
    labels = KMeans(k, n_init=10, random_state=0).fit_predict(X)
    print(k, round(silhouette_score(X, labels), 3))
  • Always scale, otherwise the unit of measurement decides the result.
  • Try several values of k and have a domain expert name the outcome.
  • Test stability: rerun with a different seed and compare.
  • Check group sizes. A cluster with three cases is usually an artefact.

Silhouette

Silhouette coefficient

s(i) = (b(i) − a(i)) / max(a(i), b(i))

A point is well assigned if it is clearly closer to its own cluster than to the nearest other one.

a(i)
mean distance from i to points in its own cluster
b(i)
mean distance from i to the nearest other cluster
s(i)
a value between −1 and 1

Values above 0.5 count as clear structure, below 0.25 as barely present. The coefficient does favour spherical clusters and systematically underrates HDBSCAN results that contain noise points.

Clustering personal data creates a new category that did not exist before. That category can effectively encode a special category under Art. 9 GDPR without naming it: neighbourhood plus purchasing behaviour plus time of day frequently resolves to origin or health. For purpose limitation this means the purpose of the original collection rarely covers the grouping. See GDPR basics and Bias in data.

An anomaly is not an error

An Isolation Forest flags the rare, not the wrong. In invoice checking, the largest invoice of the year is an anomaly and perfectly correct. Which is why every anomaly detection ends in a human review, and the metric is not the hit rate but the share of reviewed alerts that triggered an action.

Was this page helpful?
Unsupervised learning