Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

📖 Glossary & Cheat Sheet

A place to look things up when a symbol or a scikit-learn argument stops making sense mid-chapter.

Core vocabulary

Feature / predictor / independent variable
An input column of the design matrix XX. The three names are used interchangeably in this book, depending on whether the sentence is written from a machine-learning or a statistics perspective.
Target / response / label / dependent variable
The quantity yy we want to predict. Label is normally reserved for classification.
Training set
The data used to estimate the model parameters.
Test set
Data held back and touched only once, at the very end, to obtain an unbiased estimate of generalisation performance.
Validation set
Data used during model development to compare models or tune hyperparameters. Because you look at it repeatedly, it stops being an unbiased estimate of the test error.
Parameter
A quantity learned from the data, e.g. the coefficients β\beta of a regression.
Hyperparameter
A quantity fixed by you before training, e.g. the regularisation strength λ\lambda, the number of folds kk, or a tree’s max_depth.
Bias
Error caused by a model being too rigid to represent the true relationship. See ⚖️ Bias-Variance Tradeoff.
Variance
Sensitivity of the fitted model to the particular training sample that was drawn.
Irreducible error
Noise in the data itself. No model can go below it.
Overfitting
Fitting structure that is specific to the training sample and does not generalise. Low training error, high test error.
Underfitting
The model is not flexible enough to capture the real structure. High training and test error.
Discriminative model
Models P(YX)P(Y \mid X) directly (logistic regression, SVM, trees).
Generative model
Models P(XY)P(X \mid Y) and P(Y)P(Y), then applies Bayes’ theorem (LDA, QDA, Naïve Bayes).
Kernel
A function that computes inner products in an implicitly higher-dimensional space, letting a linear method draw non-linear boundaries.

Symbols used throughout

SymbolMeaning
nnnumber of observations
ppnumber of predictors
kknumber of folds in cross-validation (also number of classes in some chapters)
XXdesign matrix, shape n×pn \times p
yytarget vector, length nn
β\betaregression coefficients
f^\hat{f}the estimated function
y^\hat{y}predicted values
ε\varepsilonerror / noise term
σ2\sigma^2noise variance (the irreducible error)
λ\lambdaregularisation strength (called alpha in scikit-learn)
α\alphaelastic net mixing parameter (called l1_ratio in scikit-learn)
πk\pi_kprior probability of class kk
μk\mu_kmean vector of class kk
Σ\Sigmacovariance matrix
δk\delta_kdiscriminant function for class kk
η\etalearning rate in boosting

Metrics

MetricFormulaUsed for
MSE1n(yiy^i)2\frac{1}{n}\sum (y_i - \hat{y}_i)^2regression
RMSEMSE\sqrt{\text{MSE}}regression, in the units of yy
1(yiy^i)2(yiyˉ)21 - \frac{\sum(y_i-\hat y_i)^2}{\sum(y_i-\bar y)^2}regression
AccuracyTP+TNn\frac{TP+TN}{n}classification (balanced classes)
PrecisionTPTP+FP\frac{TP}{TP+FP}“when I say positive, how often am I right?”
RecallTPTP+FN\frac{TP}{TP+FN}“of all real positives, how many did I catch?”
F12PrecisionRecallPrecision+Recall2\cdot\frac{\text{Precision}\cdot\text{Recall}}{\text{Precision}+\text{Recall}}classification with imbalanced classes

Naming traps in scikit-learn

The standard workflow

Almost every chapter is a variation on the same five steps:

  1. Split — hold out a test set before doing anything else.

  2. Preprocess — fit scalers/encoders on the training data only, ideally inside a Pipeline.

  3. Select — compare models and hyperparameters with cross-validation on the training data.

  4. Fit — refit the chosen model on the full training data.

  5. Evaluate — score once on the held-out test set and report that number.