ML problems are grouped by the feedback the learner gets: labels (supervised), no labels (unsupervised), a few labels (semi-supervised), labels made from the data itself (self-supervised) or rewards (reinforcement learning).
| Type | Training data | Goal | Typical tasks & algorithms |
|---|---|---|---|
| Supervised | Inputs X with labels y | Predict y for new X | Classification, regression — linear/logistic regression, trees, SVM, boosting |
| Unsupervised | Inputs X only | Find structure | Clustering (k-means, DBSCAN), dimensionality reduction (PCA), anomaly detection |
| Semi-supervised | Few labelled + many unlabelled rows | Use unlabelled data to improve a supervised model | Self-training, label propagation |
| Self-supervised | Raw data; labels created from the data (the next word, a masked patch) | Learn general representations | Pre-training language and vision models |
| Reinforcement | States, actions, rewards from an environment | A policy maximising cumulative reward | Game playing, robotics, recommendations as sequential decisions |
Supervised vs unsupervised on the same data
The iris dataset has 150 flowers of 3 species. A classifier learns from the species labels; k-means never sees them but still finds groups that largely match them:
from sklearn.cluster import KMeans
from sklearn.datasets import load_iris
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import adjusted_rand_score
X, y = load_iris(return_X_y=True)
clf = LogisticRegression(max_iter=1000).fit(X, y) # supervised: uses y
print(clf.predict(X[[0, 50, 100]])) # [0 1 2] ← species 0, 1, 2
km = KMeans(n_clusters=3, n_init=10, random_state=0).fit(X) # unsupervised: never sees y
print(km.labels_[[0, 50, 100]]) # [1 0 2] ← cluster ids are arbitrary names
print(round(adjusted_rand_score(y, km.labels_), 2)) # 0.73 ← 1.0 = perfect match, ≈0 = random; versicolor/virginica overlapSupervised: classification vs regression
| Classification | Regression | |
|---|---|---|
| Target | A category (spam / not spam; cat / dog / bird) | A number (price, temperature, demand) |
| Output | Class label, usually with a probability or score | A real value |
| Loss (training) | Log-loss (cross-entropy), hinge | Squared error, absolute error, Huber |
| Metrics | Accuracy, precision, recall, F1, ROC-AUC, PR-AUC | MAE, RMSE, R² |
| Variants | Binary, multi-class (one of k), multi-label (any subset of k) | Single- or multi-output |
Other ways to slice ML
| Distinction | One side | Other side |
|---|---|---|
| Batch vs online | Batch: train on the full dataset, retrain periodically | Online: update incrementally as data arrives (partial_fit in SGDClassifier, MultinomialNB) |
| Model-based vs instance-based | Model-based: learn parameters, then discard the data (linear models) | Instance-based: keep the training data and compare new points to it (k-NN) |
| Parametric vs non-parametric | Parametric: a fixed number of parameters regardless of data size (linear/logistic regression, Naive Bayes) | Non-parametric: complexity grows with the data (k-NN, decision trees, kernel SVMs) |
| Discriminative vs generative | Discriminative: model P(y | x) or the boundary directly (logistic regression, SVM) | Generative: model how data is produced, P(x | y)·P(y) (Naive Bayes, Gaussian mixtures) |
Reinforcement learning in one paragraph
An agent observes a state, takes an action, receives a reward and a new state from the environment, and learns a policy (state → action) that maximises total future reward. Unlike supervised learning, nobody gives the correct action — only delayed, scalar feedback — so the agent must balance exploration and exploitation. Q-learning, MDPs and value iteration are worked through in the Artificial Intelligence notes.
Is anomaly detection supervised or unsupervised?
What is self-supervised learning and why does it matter?
Parametric vs non-parametric — give an example of each.