Supervised & Unsupervised Learning

Labeled vs unlabeled data — and the spectrum in between

Why

Framing a business problem correctly before reaching for an algorithm is the first real test of ML judgment. Treating a ranking problem as classification, or a segmentation problem as regression, leads to the wrong metric, the wrong loss function, and a model that never actually solves the real objective.

It also sets up every other ML topic: bias-variance, evaluation metrics, and regularization all mean something different depending on whether you're predicting a label or discovering structure.

Intuition

Supervised learning is learning with an answer key — every training example comes with the correct output, and the model learns the mapping from input to that recorded answer. Unsupervised learning has no answer key — the model just looks for patterns: which points are similar, which directions carry the most information.

Semi-supervised and self-supervised sit in between: a little labeled data plus a lot of cheap unlabeled data, or a task where the "labels" are manufactured automatically from the data's own structure — no human annotation needed.

Explanation
Classification vs regression

Both are supervised — the difference is the shape of the output.

Classification: output is discrete/categorical Examples: spam/not spam, digit 0-9, churn/no-churn Typical loss: cross-entropy Typical output: class probabilities (softmax/sigmoid) Regression: output is continuous Examples: house price, demand forecast, ETA Typical loss: MSE / MAE / Huber Typical output: a real number

Ordinal targets (star ratings, severity levels) are a common gray area — technically discrete but ordered, sometimes best modeled as regression then rounded, sometimes as ordinal classification.

Unsupervised learning: clustering & dimensionality reduction

No ground truth to check against, so evaluation is inherently harder — you're judging structure, not correctness.

Clustering
Groups similar points together. K-means (partitions by distance to centroids, needs k chosen upfront), hierarchical clustering (builds a dendrogram, no k needed), DBSCAN (density-based, finds arbitrary shapes and marks outliers as noise). Evaluated with silhouette score or inertia, not accuracy.
Dimensionality reduction
Compresses features while preserving structure. PCA finds directions of maximum variance (linear, good for preprocessing/noise reduction). t-SNE and UMAP preserve local neighborhoods for visualization but distort global distances — don't feed their output back into a model.
Semi-supervised & self-supervised learning

Semi-supervised: a small labeled set plus a much larger unlabeled set. Pseudo-labeling trains on the labeled data, predicts on the unlabeled data, then retrains including the confident pseudo-labels. Label propagation spreads labels through a similarity graph.

Self-supervised: labels are generated automatically from the data's own structure, no human annotation required — mask a word and predict it (language models), predict a rotated image's rotation, or pull two augmented views of the same image together while pushing different images apart (contrastive learning). This is how modern LLMs and vision foundation models get pretrained before any task-specific fine-tuning.

Choosing the right framing
Have labeled outcomes to predict? → supervised (classification/regression) Have some labels, lots of unlabeled data? → semi-supervised No labels, want structure/representations? → unsupervised or self-supervised Want to generate labels from raw data? → self-supervised pretraining