Classical machine learning
Unsupervised learning
Clustering, dimensionality reduction and anomaly detection without labels.
Most of the world's data has no label. Logs, embeddings, clickstreams, support tickets — you often need structure first: groups of similar items, a low-dimensional view, or a flag that says "this row is weird." Unsupervised learning finds that structure without a target y.
It will not replace supervised models for decisions with clear labels. It will get you features, segments, visualizations and anomaly alerts when labels are scarce. Closely related: learning vector meaning in representation learning and embeddings.
Reach for these methods when you need segments without labeled personas, a map of a high-dimensional space, alerts for rare weirdness, or cluster ids and PC scores as inputs to a later supervised model. Do not use unsupervised learning to avoid labeling when labels are cheap and the decision is clear. A mediocre supervised model with honest evaluation usually beats a beautiful clustering that nobody acts on.
Concepts in this section
Read them in order. Each one builds on the one before.
| Step | Concept | What it answers |
|---|---|---|
| 1 | k-means clustering | How do you partition points into k groups? |
| 2 | DBSCAN and hierarchical clustering | What if the blobs are not spheres, or you want a tree? |
| 3 | PCA for machine learning | How do you compress variance into a few axes? |
| 4 | Anomaly detection | How do you flag rows that are weird? |
Clustering embeddings
A common pipeline: embed support tickets, normalize vectors, run k-means or HDBSCAN, label clusters by reading top terms or exemplar texts, then route tickets or discover topics.
50k support tickets → embedding → k-means with k=40 → one cluster is 90% "refund not received," another "SSO login loop." You just built a taxonomy without labeled topics. Re-embed and re-cluster quarterly as products change.
Scale features before distance-based methods. Prefer k-means++ and multiple inits. Use PCA to compress before clustering very wide data. Keep visualization algorithms (t-SNE, UMAP) out of the serving path. For anomalies, budget analyst time to review flags.
Interview angle: derive one k-means iteration on a 2D toy, explain why you standardize, say when DBSCAN beats k-means, warn about t-SNE misuse, describe isolation forests at a high level, and relate PCA to SVD.
Common mistakes
- Optimizing silhouette when nobody can act on 12 segments. Cut to the number of plays you can run.
- Feeding t-SNE coordinates into a classifier. They are a picture, not features.
- Setting isolation-forest
contaminationto "the true rate". It is a quota.
Key takeaways
- k-means assigns points to
kcentroids. Choosekwith elbow, silhouette and downstream utility. Scale inputs. - Hierarchical clustering and DBSCAN cover tree cuts and density-based shapes plus noise.
- PCA/SVD compresses variance into orthogonal components for visualization and features.
- t-SNE/UMAP are visual tools. Do not treat plot distances as data.
- Isolation forests and reconstruction errors flag anomalies. Thresholds still need human cost logic.
- Cluster embeddings for topic discovery. Judge success by decisions, not only internal scores.
Further learning
ISL chapters on PCA and clustering with labs:
An Introduction to Statistical LearningAn Introduction to Statistical Learning scikit-learn: ClusteringClustering of unlabeled data can be performed with the module sklearn.cluster. Each clustering algorithm comes in two variants: a class, that implements the fit method to learn the clusters on trai...scikit-learn
scikit-learn: Decomposing signals in components (PCA)Principal component analysis (PCA): Exact PCA and probabilistic interpretation: PCA is used to decompose a multivariate dataset in a set of successive orthogonal components that explain a maximum a...scikit-learn
Related
Embeddings and representation learning
Learning vectors that capture meaning, from word2vec and contrastive training to CLIP and retrieval. Start here for the map of embedding concepts.
Embeddings and similarity
Turning text into vectors, measuring similarity, and choosing an embedding model.
Linear algebra for ML
Vectors, matrices and matrix multiplication, the language every model is written in. Learn the shapes, then batching, FLOP counts and low-rank tricks.