Chapter 1

Learning tasks and measurement

Start by identifying the target, the loss and the data used to fit the model. A numerical class code is still a class label. A good training score alone does not establish performance on unseen observations.

1.1 Prediction tasks and model families

Past papers · DA 2024–2026 (3 papers): 2 questions, 2 marks

A supervised dataset is D={(xi,yi)}i=1nD=\{(\mathbf x_i,y_i)\}_{i=1}^n, where nn is the number of observations, xi∈Rd\mathbf x_i\in\mathbb R^d has dd features, and yiy_i is the target. Regression predicts a numerical response; classification selects a class. Unsupervised learning uses feature vectors without target labels.

Task or modelWhat is fitted or returnedKey distinction
RegressionA numerical prediction y^=f(x)\hat y=f(\mathbf x)Error has target units
ClassificationA label or class probabilitiesA probability threshold converts scores to labels
ClusteringGroups of similar observationsCluster numbers are arbitrary identifiers
Dimensionality reductionA smaller feature representationPCA uses variation; LDA uses labels
Generative classificationClass prior and class-conditional distributionNaive Bayes and probabilistic LDA
Discriminative classificationA boundary or conditional class probabilitiesLogistic regression and SVM

Feature selection keeps original coordinates; feature extraction constructs new coordinates. PCA and Fisher LDA are extraction methods. Sampling is a separate task; Markov chain Monte Carlo belongs to the Artificial Intelligence handbook.

1.2 Losses and regularisation

Past papers · DA 2024–2026 (3 papers): 1 question, 2 marks

Let y^i=fθ(xi)\hat y_i=f_{\boldsymbol\theta}(\mathbf x_i), where θ\boldsymbol\theta collects the parameters. Training minimises a chosen loss. Model evaluation may use a different metric; always use the quantity specified in the question.

For squared error, the best constant prediction is the target mean; for absolute error it is any target median; for zero-one loss it is a most frequent class. These follow by differentiating the quadratic, balancing absolute-error slopes, and counting correct predictions respectively.

1.3 Classification scores

Past papers · DA 2024–2026 (3 papers): 1 question, 2 marks

Choose a positive class before constructing a confusion matrix. In multiclass questions, treat the named class as positive and every other class as negative.

Actual / predictedPositiveNegative
PositiveTP: true positiveFN: false negative
NegativeFP: false positiveTN: true negative

Macro averaging takes the unweighted mean of the per-class scores. Micro averaging pools the per-class TP, FP and FN first; in single-label multiclass classification, micro precision, recall and F1F_1 equal accuracy. A ROC curve plots TPR against FPR while the threshold varies. Lowering a positive-score threshold cannot decrease either rate on a fixed dataset.

Last-minute recall

  • Regression targets are numerical; class numbers are labels.
  • Naive Bayes and LDA model class-conditional distributions.
  • Squared loss and absolute loss have different units and different minimisers.
  • An average loss and a summed loss need different penalty weights for the same fit.
  • Fix the positive class before computing precision or recall.
  • Accuracy can hide poor performance on a small class.

Revise offline: the whole Machine Learning handbook as one PDF

42 pages · 1.8 MBFree to read online. Sign in to download the PDF.We save the handbook, version and request time in My downloads. Privacy policy

All chapters · Corrections