Glossary
- A
- accuracy
- The fraction of samples whose predicted class equals the true class.
Easy to understand, but on imbalanced data a useless classifier can
score very high, so always report it with a baseline and with precision
and recall.
Introduced in 2.5.
See also: class imbalance, precision, recall
- axis
- One dimension of an array. For a 2-D array axis 0 indexes rows and axis
1 indexes columns, so
X.mean(axis=0)gives the mean of every column (one value per feature) andX.mean(axis=1)the mean of every row.Introduced in 1.2.
See also: shape
- B
- baseline
- A deliberately simple reference model, such as always predicting the
mean of the training targets or the most common class. If your model
cannot beat the baseline on held-out data, it has learned nothing
useful. In scikit-learn,
DummyRegressorandDummyClassifierbuild baselines.Introduced in 2.3.
See also: generalisation, test set
- bias–variance trade-off
- The tension between two sources of error. Bias is the error from a model
that is too simple to capture the true pattern; variance is the error
from a model so flexible that it follows the noise in a particular
training set. Increasing model complexity lowers bias but raises
variance.
Introduced in 2.4.
See also: overfitting, underfitting
- boolean mask
- An array of booleans with the same shape as the data, usually produced
by a comparison such as
x > 0, and used inside square brackets to select just the elements where it is True. Masks are how you filter data without loops in NumPy and pandas.Introduced in 1.2.
See also: vectorisation
- box plot
- A chart showing the median (line), the middle 50% of values (box, from
the 25th to the 75th percentile), whiskers to the most extreme
non-outlying points and individual outliers beyond them. Violin plots
show the same plus the full shape of the distribution.
Introduced in 1.4.
See also: outlier
- broadcasting
- The set of rules NumPy uses to combine arrays of different but
compatible shapes, for example subtracting a vector of column means from
every row of a matrix without writing a loop.
Introduced in 1.2.
See also: vectorisation
- C
- calibration
- A classifier is well calibrated when its predicted probabilities match
observed frequencies, so that among samples predicted with probability
0.8, about 80% are actually positive. Good ranking (AUC) does not
guarantee good calibration.
Introduced in 2.5.
See also: logistic regression
- categorical data
- Data whose values are labels from a fixed set (species, island, sex)
rather than measurements. pandas has a dedicated
categorydtype for them; models need them encoded as numbers, for example with one-hot encoding.Introduced in 1.3.
See also: one-hot encoding
- class imbalance
- A situation where one class is far more common than another, for example
1% active compounds in a screen. Accuracy then rewards predicting the
majority class; precision, recall, PR curves and class weights are the
tools that cope with it.
Introduced in 2.5.
- classification
- A supervised learning task where the target is a category, such as
toxic/non-toxic or one of several cell types.
Introduced in 2.1.
See also: regression, label
- coefficient
- The weight multiplying one feature in a linear model. Its size depends
on the feature’s units and scale, and when features are correlated the
coefficients can swap importance between them, so interpret them
cautiously.
Introduced in 2.2.
See also: parameter
- coefficient of determination (R²)
- \(R^2 = 1 - \frac{\sum_i (y_i -
\hat{y}_i)^2}{\sum_i (y_i - \bar{y})^2}\). A value of 1 means
perfect predictions, 0 means no better than predicting the mean, and
negative values are possible on test data when the model is worse than
the mean baseline.
Introduced in 2.3.
See also: mean absolute error (MAE), root mean squared error (RMSE), baseline
- colour-blind-safe palette
- A palette whose colours differ in lightness and hue in ways that remain
distinguishable for readers with colour-vision deficiency (about 8% of
men and 0.5% of women). The Okabe–Ito palette and viridis are standard
choices; red–green pairs are the classic mistake.
Introduced in 1.4.
- ColumnTransformer
- A scikit-learn transformer that routes columns to different
preprocessing steps, for example scaling the numeric columns and one-hot
encoding the categorical ones, then concatenates the results. It is the
standard first step of a pipeline on mixed data.
Introduced in 2.6.
See also: pipeline, one-hot encoding
- conda / mamba
- conda is a package and environment manager; mamba is a faster drop-in
replacement. Both read
environment.yml, create an isolated environment and install libraries (including compiled ones such as RDKit later in the course) from the conda-forge channel.Introduced in 0.2.
See also: virtual environment
- confusion matrix
- A table that cross-tabulates true classes against predicted classes. For
a binary problem it has four cells: true positives, false positives,
false negatives and true negatives. Precision, recall and accuracy are
all read off it.
Introduced in 2.5.
- correlation coefficient
- Pearson’s \(r\), a number between \(-1\) and \(1\) measuring the strength of the
linear relationship between two variables. Zero means no linear
relationship, not no relationship. A heatmap of all pairwise
correlations is a standard EDA figure.
Introduced in 1.4.
See also: scatter plot
- cross-validation
- A resampling method that splits the data into \(k\) folds, trains on \(k-1\) of them and evaluates on the
remaining fold, rotating until each fold has served as the evaluation
set. The \(k\) scores are averaged. It
gives a more stable estimate than a single split and is the standard way
to choose hyperparameters.
Introduced in 2.4.
See also: validation set, hyperparameter
- D
- data leakage
- Any way in which information that would not be available at prediction
time, or information from the test set, influences training. Typical
causes are preprocessing before splitting, duplicated samples across the
split, and features derived from the target. Leakage makes test scores
unrealistically good.
Introduced in 2.3.
See also: train/test split, test set
- DataFrame
- The central pandas data structure, a two-dimensional table with labelled
rows (the index) and labelled columns, where each column has its own
data type.
Introduced in 1.3.
See also: tidy data
- decision boundary
- The set of points in feature space where a classifier’s prediction
changes from one class to another. For logistic regression it is a
straight line (hyperplane); for kNN it is irregular and follows the
training points.
Introduced in 2.5.
See also: classification
- decision threshold
- The cut-off applied to a predicted probability to decide the class, 0.5
by default. Moving it trades precision against recall, which is what ROC
and precision–recall curves display across all thresholds.
Introduced in 2.5.
See also: ROC curve and AUC, precision–recall curve
- distribution shift
- A systematic difference between the data a model was trained on and the
data it is applied to, for example new chemical scaffolds, a different
hospital or a different sequencing batch. Models typically degrade under
shift, and random splits do not reveal it.
Introduced in 2.1.
See also: generalisation, scaffold split
- dtype
- The data type of the elements of a NumPy array or pandas column, for
example
float64,int64,boolorstr. Mixing types in one array forces a common type (oftenobject), which is slow and a sign that something is wrong.Introduced in 1.2.
See also: NumPy array
- duplicate
- A row that repeats another one, exactly or in all the ways that matter
(the same molecule under two names, the same patient measured twice).
Duplicates inflate apparent dataset size, and when copies fall on both
sides of a train/test split they leak information.
Introduced in 1.5.
See also: data leakage
- E
- estimator
- scikit-learn’s name for any object that learns from data through a
fitmethod. Models addpredictandscore; preprocessors addtransform. Because all estimators share this interface, they can be swapped and combined in pipelines.Introduced in 2.2.
See also: pipeline
- exploratory data analysis (EDA)
- The first stage of any data project: summarising and plotting the data
to understand distributions, relationships, missing values, outliers and
duplicates before any model is fitted.
Introduced in 1.5.
See also: tidy data
- F
- f-string
- A formatted string literal, written
f"...", in which expressions inside braces are evaluated and inserted. Format specifiers control the output, for examplef"{rmse:.3f}"prints three decimals.Introduced in 1.1.
- F1 score
- \(F_1 = 2 \cdot \frac{\mathrm{precision} \cdot
\mathrm{recall}}{\mathrm{precision} + \mathrm{recall}}\), a
single number summarising the trade-off between precision and recall. It
is high only when both are high.
Introduced in 2.5.
- feature
- A measurable property of a sample used as input to a model, such as
molecular weight or the number of hydrogen-bond donors. The features of
all samples form the matrix \(X\) with
one row per sample and one column per feature.
Introduced in 1.2.
See also: label, molecular descriptor
- feature scaling
- Transforming each feature so that they have comparable ranges, most
often by standardising to zero mean and unit standard deviation
(
StandardScaler). Distance-based models such as kNN and regularised models depend on it.Introduced in 2.6.
See also: k-nearest neighbours (kNN), pipeline
- G
- generalisation
- The ability of a model to perform well on data it has not seen during
training. Generalisation, not training performance, is the real goal of
machine learning.
Introduced in 2.1.
See also: overfitting, test set
- Google Colab
- Google Colaboratory, a free hosted Jupyter notebook service that runs in
the browser. Every lab has an Open in Colab button. Files you
create there disappear when the session ends unless you save them to
Drive.
Introduced in 0.2.
See also: Jupyter notebook
- gradient
- For a function of several variables, the vector of its partial
derivatives. It points in the direction in which the function increases
fastest, which is why optimisation steps go the opposite way.
Introduced in A.
See also: gradient descent
- gradient descent
- An iterative optimisation method that repeatedly moves the parameters a
small step in the direction that decreases the loss fastest, the
negative gradient. The step size is the learning rate.
Introduced in 2.2.
See also: loss function, gradient
- grid search
- Systematically evaluating every combination of candidate hyperparameter
values with cross-validation and keeping the best. scikit-learn’s
GridSearchCVdoes this and then refits the best model on all the training data.Introduced in 2.4.
See also: cross-validation, hyperparameter
- group split
- Any train/test or cross-validation split that assigns whole groups of
related samples, such as all measurements from one patient or all
molecules with one scaffold, entirely to one side. scikit-learn’s
GroupKFoldimplements it.Introduced in 2.6.
See also: scaffold split, data leakage
- groupby
- The pandas operation that splits a DataFrame into groups sharing a key
(for example species), applies an aggregation such as
meanorcountto each group, and combines the results into a new table. The pattern is often called split-apply-combine.Introduced in 1.3.
See also: DataFrame
- H
- histogram
- A chart that divides the range of a variable into bins and draws a bar
whose height is the number of values in each bin. The first plot to make
for any numeric column.
Introduced in 1.4.
See also: kernel density estimate (KDE)
- hyperparameter
- A setting of a learning algorithm that is not learned from the data but
chosen beforehand, such as the regularisation strength of ridge
regression or the number of neighbours in kNN. Hyperparameters are tuned
with validation data or cross-validation, never with the test set.
Introduced in 2.4.
See also: cross-validation, regularisation
- I
- i.i.d.
- Random variables \(X_1, \ldots, X_n\)
are independent and identically distributed if they all have
the same distribution and are mutually independent. Most results about
averages (the law of large numbers, the central limit theorem) assume
it, and a random train/test split assumes that training and test samples
are i.i.d. draws from the same population. Duplicates, closely related
molecules and batch effects break the assumption, which is why later
chapters use scaffold and group splits.
Introduced in A.
See also: train/test split, data leakage
- imputation
- Replacing missing values with estimates, for example the column median
(
SimpleImputer). It must be fitted on the training data only and applied inside a pipeline, otherwise test information leaks into training.Introduced in 2.6.
See also: missing value (NaN), pipeline
- index (pandas)
- The labels attached to the rows of a DataFrame or Series. By default
they are integers starting at 0, but they can be anything (compound
names, dates).
locselects by these labels,ilocby position.Introduced in 1.3.
See also: loc and iloc
- J
- joblib
- A utility library for saving Python objects efficiently.
joblib.dump(model, "model.joblib")persists a fitted scikit-learn pipeline andjoblib.loadrestores it. Record the library versions alongside the file: a model saved with one scikit-learn version may not load with another.Introduced in 2.6.
- Jupyter notebook
- A document made of cells that can hold code, its output (text, tables,
figures) or formatted text. Notebooks run in JupyterLab, VS Code or
Google Colab. The course labs are notebooks; the episodes are rendered
from the same kind of cells.
Introduced in 0.2.
See also: kernel, Google Colab
- K
- k-nearest neighbours (kNN)
- A model that predicts a sample by looking up the \(k\) training samples closest to it in
feature space and averaging their labels (regression) or taking a vote
(classification). It has no training phase and is sensitive to feature
scaling.
Introduced in 2.5.
See also: feature scaling
- kernel
- The background Python process that executes notebook cells. It keeps all
variables in memory between cells, which is why running cells out of
order can confuse you: restart the kernel and run from the top when in
doubt.
Introduced in 0.2.
See also: Jupyter notebook
- kernel density estimate (KDE)
- A smooth curve estimating the distribution of a variable, obtained by
placing a small bump (kernel) at every data point and summing them. It
is a smoothed histogram; the bandwidth controls how smooth.
Introduced in 1.4.
See also: histogram
- L
- label
- The target value associated with each sample, which a supervised model
learns to predict. Continuous labels give a regression problem;
categorical labels give a classification problem. The labels of all
samples form the vector \(y\).
Introduced in 2.1.
See also: feature, regression, classification
- lasso regression
- Linear regression whose loss adds \(\alpha
\sum_j |\theta_j|\). Unlike ridge, the absolute-value penalty
drives some coefficients to exactly zero, so lasso performs feature
selection as a side effect.
Introduced in 2.4.
See also: regularisation, ridge regression
- learning curve
- A plot of training and validation score against the number of training
samples. A large persistent gap signals overfitting (more data would
help); two low curves close together signal underfitting (a richer model
would help).
Introduced in 2.4.
See also: validation curve, bias–variance trade-off
- learning rate
- The factor that scales each gradient-descent step. Too large and the
loss oscillates or explodes; too small and training takes forever. It is
the first hyperparameter of any iterative optimiser.
Introduced in 2.2.
See also: gradient descent
- list comprehension
- A compact expression that builds a list (or dict, set) by transforming
and filtering another sequence, for example
[m.upper() for m in names if m]. It replaces a three-line for-loop with an append.Introduced in 1.1.
- loc and iloc
- The two indexers of a DataFrame.
df.loc[rows, cols]uses labels (index values and column names, including boolean masks);df.iloc[rows, cols]uses integer positions. Using plain square brackets for anything beyond a column name is a common source of confusion.Introduced in 1.3.
See also: index (pandas), boolean mask
- log transform
- Replacing a positive variable \(x\) by
\(\log_{10} x\) (or \(\ln x\)). It compresses quantities that
span several orders of magnitude, such as solubilities or
concentrations, into a range where additive models and symmetric error
measures make sense.
Introduced in 1.5.
See also: logS
- logistic regression
- A linear model for binary classification: it computes a weighted sum of
the features and passes it through the sigmoid function to give a
probability between 0 and 1. Despite the name it is a classifier.
Introduced in 2.5.
See also: classification, sigmoid function
- logS
- The base-10 logarithm of a compound’s aqueous solubility expressed in
moles per litre. A logS of −3 means a solubility of 0.001 mol/L. Taking
the logarithm makes a quantity that spans many orders of magnitude
easier to model.
Introduced in 1.5.
See also: molecular descriptor
- loss function
- A function that measures the disagreement between predictions and true
values, such as the mean squared error. Training a model means adjusting
its parameters to make the loss on the training data small.
Introduced in 2.1.
See also: mean squared error (MSE), gradient descent
- M
- mean absolute error (MAE)
- The average of the absolute differences between predictions and true
values, \(\mathrm{MAE} = \frac{1}{n}\sum_i
|y_i - \hat{y}_i|\). It is in the same units as the target and
treats all errors proportionally.
Introduced in 2.3.
See also: root mean squared error (RMSE), coefficient of determination (R²)
- mean squared error (MSE)
- \(\mathrm{MSE} = \frac{1}{n}\sum_i (y_i -
\hat{y}_i)^2\), the average squared difference between
predictions and truth. It is the loss minimised by ordinary
least-squares regression; its square root is the RMSE.
Introduced in 2.2.
See also: root mean squared error (RMSE), loss function
- melt and pivot
- Two reshaping operations.
meltconverts a wide table with one column per measurement into a long one with a variable and a value column, which is what seaborn expects.pivotandpivot_tablego the other way, spreading one column’s categories into separate columns.Introduced in 1.3.
See also: tidy data
- merge (join)
- Combining two DataFrames by matching rows on one or more key columns, as
in a database join.
how="inner"keeps only matching rows;how="left"keeps every row of the left table.Introduced in 1.3.
See also: DataFrame
- missing value (NaN)
- A cell with no recorded value, represented as
NaN(not a number) or<NA>in pandas. Count them withdf.isna().sum(). Options are to drop the rows, drop the column or impute a replacement; scikit-learn models refuse to fit with NaNs present.Introduced in 1.3.
See also: imputation
- model
- A function \(f(x;\theta)\) that turns a
feature vector \(x\) into a prediction,
with parameters \(\theta\) that are
adjusted (trained) to make its predictions match known labels. Linear
regression, logistic regression, kNN and neural networks are all models
in this sense.
Introduced in 2.1.
See also: parameter, loss function
- molecular descriptor
- A numerical property computed from a molecular structure, for example
molecular weight, number of rings or topological polar surface area.
Descriptors are the simplest way to turn molecules into feature vectors;
Chapter 5 computes them with RDKit.
Introduced in 1.5.
- N
- nested cross-validation
- An outer cross-validation loop for estimating performance with an inner
loop, run on each outer training fold, for choosing hyperparameters. It
is the honest way to report the performance of a tuned model when you
cannot afford a separate test set.
Introduced in 2.4.
See also: cross-validation
- normal equation
- The linear system \(X^\top X \theta = X^\top
y\), obtained by setting the gradient of the mean squared error
to zero; its solutions are exactly the least-squares fits. When the
columns of \(X\) are linearly
independent, \(X^\top X\) is invertible
and the unique solution is \(\hat\theta =
(X^\top X)^{-1} X^\top y\). In code, solve the system rather than
inverting the matrix:
np.linalg.solve(X.T @ X, X.T @ y).Introduced in 2.2.
See also: gradient descent, mean squared error (MSE)
- NumPy array
- NumPy’s core data structure,
ndarray: a grid of elements that all share one data type, with a shape such as(1128, 5). Arithmetic on arrays is applied element-wise in compiled code, which is what makes scientific Python fast.Introduced in 1.2.
See also: dtype, shape, vectorisation
- O
- one-hot encoding
- Representing a categorical feature with one binary column per category,
so that a model that only understands numbers can use it. scikit-learn’s
OneHotEncoderdoes this inside a pipeline.Introduced in 2.6.
See also: pipeline
- outlier
- A value that lies far from the bulk of the data. Outliers can be
measurement errors, data-entry mistakes, or genuine rare cases, and only
domain knowledge can tell which. Look at them before deciding whether to
remove them.
Introduced in 1.5.
See also: exploratory data analysis (EDA)
- overfitting
- When a model fits its training data so closely, noise included, that it
performs worse on new data. Symptoms are a large gap between training
and test performance. Remedies include more data, simpler models,
regularisation and cross-validated model selection.
Introduced in 2.4.
See also: underfitting, regularisation, generalisation
- P
- parameter
- A value inside a model that is learned from the data, such as the slope
and intercept of a line. Distinguish from hyperparameters, which are
chosen before training.
Introduced in 2.1.
See also: hyperparameter
- parity plot
- A scatter plot with the true value on one axis and the predicted value
on the other. Perfect predictions fall on the diagonal line \(y = x\). It shows at a glance where a model
is biased, where it saturates and which points are outliers.
Introduced in 2.3.
See also: residual
- pathlib
- The standard-library module whose
Pathclass represents file-system paths. It joins paths with/, checks existence with.exists()and reads files with.read_text(), and it handles Windows and Unix separators for you.Introduced in 1.1.
- pipeline
- A scikit-learn object that chains preprocessing steps (scaling,
imputation, encoding) with a final model so that they are fitted
together on the training data and applied together to new data.
Pipelines prevent data leakage and make cross-validation honest.
Introduced in 2.6.
See also: estimator, data leakage
- polynomial features
- Features created by raising the originals to powers and multiplying them
together (\(x^2\), \(x_1 x_2\), …). A linear model on polynomial
features fits curved relationships; raising the degree too far is the
classic way to overfit.
Introduced in 2.4.
See also: overfitting
- precision
- \(\mathrm{precision} = \frac{TP}{TP +
FP}\), the fraction of predicted positives that are truly
positive. High precision means few false alarms.
Introduced in 2.5.
See also: recall, confusion matrix
- precision–recall curve
- A plot of precision against recall as the decision threshold varies.
Unlike the ROC curve it ignores true negatives, so it is the better
picture when the positive class is rare, as in a screening campaign.
Introduced in 2.5.
See also: ROC curve and AUC, class imbalance
- R
- random number generator
- NumPy’s
Generatorobject, created withnp.random.default_rng(seed), which produces pseudo-random numbers. Fixing the seed makes every run identical. Create one generator at the top of a script and pass it around rather than calling the legacynp.random.*functions.Introduced in 1.2.
See also: random state
- random state
- A number (the seed) that initialises a pseudo-random number
generator so that a random operation, such as a train/test split or a
shuffled cross-validation, produces exactly the same result every time
it is run. In scikit-learn the argument is
random_state; in NumPy you create a generator withnp.random.default_rng(seed).Introduced in 1.2.
See also: train/test split
- recall
- \(\mathrm{recall} = \frac{TP}{TP +
FN}\), the fraction of actual positives that the model
identifies. Also called sensitivity. High recall means few misses.
Introduced in 2.5.
See also: precision, confusion matrix
- regression
- A supervised learning task where the target is a continuous number, such
as a solubility, a binding affinity or a body mass.
Introduced in 2.1.
See also: classification, label
- regularisation
- Adding a penalty term to the loss function that discourages large or
many coefficients, trading a little training accuracy for better
generalisation. Ridge regression penalises squared coefficients; Lasso
penalises absolute values and drives some coefficients to exactly zero.
Introduced in 2.4.
See also: overfitting, hyperparameter
- residual
- The difference between an observed value and the model’s prediction,
\(r_i = y_i - \hat{y}_i\). Plotting
residuals against predictions or against features reveals systematic
errors that a single summary metric hides.
Introduced in 2.3.
See also: parity plot
- ridge regression
- Linear regression whose loss adds \(\alpha
\sum_j \theta_j^2\), the squared size of the coefficients. The
penalty shrinks all coefficients towards zero, stabilising the fit when
features are correlated or numerous. \(\alpha\) is a hyperparameter.
Introduced in 2.4.
See also: regularisation, lasso regression
- ROC curve and AUC
- The receiver operating characteristic curve plots the true-positive rate
against the false-positive rate as the decision threshold varies. The
area under it (AUC) summarises ranking quality: 1 is perfect, 0.5 is
random.
Introduced in 2.5.
- root mean squared error (RMSE)
- The square root of the mean of the squared errors, \(\mathrm{RMSE} = \sqrt{\frac{1}{n}\sum_i (y_i -
\hat{y}_i)^2}\). Also in target units, but because errors are
squared first, a few large mistakes raise RMSE much more than they raise
MAE.
Introduced in 2.3.
See also: mean absolute error (MAE), coefficient of determination (R²)
- S
- scaffold split
- A way of splitting a molecular dataset by core structure (scaffold)
rather than at random, so that the test set contains scaffolds the model
has never seen. It gives a more realistic estimate of performance on new
chemistry. Introduced properly in Part II.
Introduced in 2.6.
See also: distribution shift, group split
- scatter plot
- A chart with one point per sample positioned by two numeric variables,
optionally coloured by a third (
hue). It shows relationships, clusters and outliers that summary statistics hide.Introduced in 1.4.
See also: correlation coefficient
- Series
- pandas’ one-dimensional labelled array. Selecting one column of a
DataFrame gives a Series; it has an index, a name and a single dtype.
Introduced in 1.3.
See also: DataFrame, index (pandas)
- shape
- A tuple giving the length of an array along each of its axes. A feature
matrix has shape
(n_samples, n_features); a label vector has shape(n_samples,). Checking.shapeis the first thing to do when code misbehaves.Introduced in 1.2.
See also: NumPy array, axis
- sigmoid function
- \(\sigma(z) = \frac{1}{1 + e^{-z}}\),
an S-shaped function mapping any real number to the interval \((0, 1)\). Logistic regression uses it to
turn a linear score into a probability.
Introduced in 2.5.
See also: logistic regression
- SMILES
- Simplified Molecular-Input Line-Entry System, a compact text notation
for molecular structures, for example
CCOfor ethanol orc1ccccc1for benzene. In this course SMILES strings appear as plain text columns until Chapter 5, where RDKit parses them into molecules.Introduced in 1.5.
See also: molecular descriptor
- supervised learning
- Learning a function from input features to known labels, using examples
where both are given. Regression and classification are the two main
kinds.
Introduced in 2.1.
See also: unsupervised learning, label
- T
- target leakage
- A form of data leakage where a feature carries information about the
target that would not be available at prediction time, for instance a
lab value recorded only for patients already diagnosed. Models with
target leakage look superb in testing and fail in use.
Introduced in 2.6.
See also: data leakage
- test set
- Data held back from training and used only at the end to estimate how
the model will perform on new, unseen examples. Looking at the test set
while choosing models or settings turns it into a validation set and
makes the final estimate optimistic.
Introduced in 2.3.
See also: train/test split, validation set
- tidy data
- A layout convention for tables: each variable is a column, each
observation is a row, and each type of observational unit is a table.
Tidy tables are what plotting libraries and scikit-learn expect.
Introduced in 1.3.
See also: DataFrame
- traceback
- The report Python prints when an exception is not handled. The last line
names the error and its message; the lines above trace the chain of
function calls that led there, innermost last. Read the last line first,
then find the line of your code nearest the bottom.
Introduced in 1.1.
- train/test split
- Dividing a dataset into a training set, which the model learns
from, and a test set, which is kept back and used only once to
estimate how the model performs on new data. The split should be random
and reproducible (
random_state), and the test set must never influence any modelling decision.Introduced in 2.3.
See also: test set, training set, data leakage
- training set
- The subset of the data used to fit (train) a model. Performance measured
on the training set is optimistic, because the model has already seen
these examples.
Introduced in 2.3.
See also: train/test split, test set
- U
- underfitting
- When a model is too simple or too constrained to capture the structure
in the data, so it performs poorly on both the training and the test
set.
Introduced in 2.4.
See also: overfitting
- unsupervised learning
- Learning patterns from inputs alone, without labels, for example
clustering samples into groups or compressing many features into a few
components (PCA).
Introduced in 2.1.
See also: supervised learning
- V
- validation curve
- A plot of training and validation score against the value of one
hyperparameter, such as polynomial degree or ridge \(\alpha\). The best setting is where the
validation score peaks, not where the training score does.
Introduced in 2.4.
See also: learning curve, hyperparameter
- validation set
- Data held back from training and used to compare models or tune
hyperparameters. Unlike the test set it may be consulted many times,
which is why a separate, untouched test set is still needed for the
final estimate.
Introduced in 2.4.
See also: test set, cross-validation
- vectorisation
- Expressing a computation as operations on whole arrays rather than
element-by-element Python loops. NumPy executes vectorised operations in
compiled code, typically tens to hundreds of times faster.
Introduced in 1.2.
See also: broadcasting
- virtual environment
- A self-contained directory holding a Python interpreter and its own
installed packages. Each project gets its own, so upgrading a library
for one project cannot break another. Created with
python -m venv,uv venvorconda create.Introduced in 0.2.
See also: conda / mamba
- X
- X / y convention
- The layout scikit-learn and this course use everywhere: features live in
a two-dimensional array
Xwith one row per sample and one column per feature, and the target lives in a one-dimensional arrayywith one entry per sample. Capital X because it is a matrix, lower-case y because it is a vector.Introduced in 1.2.