Dictionary of Applied Machine Learning: 151 machine-learning terms, each with a definition, a figure, citations and a Python demo · All terms · Demos · Start here
Updated on 2026-11-17
Readiness 100/100
See also dataset data point feature vector feature matrix singular value decomposition sample covariance matrix principal component analysis dimensionality reduction
The feature matrix of a dataset collects the feature vectors of its data points as its rows, one row per data point and one column per feature. Its two most basic properties are the number of rows, which is the number of data points in the dataset, and the number of columns, which is the number of features of each data point. More properties of a dataset follow from the singular values of its feature matrix. The number of nonzero singular values is the rank, and a rank below the number of features leaves linear regression with infinitely many solutions. The ratio of the largest to the smallest nonzero singular value is the condition number of the feature matrix. The condition number determines the number of gradient descent (GD) steps required by linear regression and its robustness against perturbations of the features and labels in the training set.

featuremtx.py, which recomputes what the entry states: the script block by block · open in ColabB-dataA weather station at Krems an der
Donau records eight measurements on each of the $366$ days of the leap
year $2024$: the lowest,
highest, and mean air temperature, the humidity, the wind speed, the
precipitation, the sunshine duration, and the air pressure. Writing
the eight measurements of one day as a row, and placing the rows of
the $366$ days under one another, gives a two-dimensional numeric
array with
$366$ rows and eight columns. That array is a matrix, the
feature matrix of the dataset whose data points are the
$366$ days, and each of its rows is the feature vector of one day. The feature matrix is the form
in which machine learning (ML) software expects a dataset, and properties
of the ML methods applied to the dataset, such as
whether linear regression has a unique solution or how fast gradient descent (GD)
converges, are determined by it.
The feature matrix also defines a linear map. A linear model with model parameters ${\mathbf w}$ from the parameter space $\mathbb{R}^{d}$ predicts ${\mathbf w}^{\top} {\mathbf x}^{(r)}$ for the $r$-th data point, so the $m$ predictions are the entries of ${\mathbf X} {\mathbf w}$. The feature matrix therefore maps each ${\mathbf w} \in \mathbb{R}^{d}$ to the vector ${\mathbf X} {\mathbf w} \in \mathbb{R}^{m}$, which is compared with the label vector ${\mathbf y} = \big(y^{(1)}, \,\ldots, \,y^{(m)}\big)^{\top} \in \mathbb{R}^{m}$. Linear regression on a training set with feature matrix ${\mathbf X}$ and label vector ${\mathbf y}$ is the search for a vector ${\mathbf w}$ whose image ${\mathbf X} {\mathbf w}$ is close to ${\mathbf y}$ in Euclidean norm.
Linear regression has a unique solution only when ${\mathbf X}$ has full column rank, which requires $m \geq d$ (Golub and Loan, 2013, Sect. 5.3.1) (see normal equations). A rank below $d$ leaves infinitely many parameter vectors ${\mathbf w}$ with the same training error (Hastie et al., 2009, Sect. 3.2), and the one a method returns can have a large loss outside the training set. Using more features than data points (i.e., $d > m$) forces this case, since then ${\mathbf X}$ has fewer rows than columns, which rules out full column rank.
B-singvalsMore properties of a dataset follow from the
singular values of its feature matrix
${\mathbf X}$. The singular value decomposition (SVD) can be written as
(Golub and Loan, 2013, Sect. 2.4)
\[{\mathbf X} = \sum_{j=1}^{\min\{m, d\}}
\lambda_{j} {\mathbf v}^{(j)}
\big({\mathbf u}^{(j)}\big)^{\top} \text{,}\]
where the vectors
${\mathbf v}^{(1)}, \,\ldots, \,{\mathbf v}^{(\min\{m, d\})} \in \mathbb{R}^{m}$
are orthonormal among themselves, the vectors
${\mathbf u}^{(1)}, \,\ldots, \,{\mathbf u}^{(\min\{m, d\})} \in \mathbb{R}^{d}$
are orthonormal among themselves. The singular values
are ordered as
$\lambda_{1} \geq \ldots \geq \lambda_{\min\{m, d\}} \geq 0$.
The number of nonzero singular values is the rank of
${\mathbf X}$ (Golub and Loan, 2013, Cor. 2.4.6). A rank below
$d$ means that some feature is a linear combination
of the others and adds no information beyond them. A small but
nonzero singular value is the approximate form of such a
dependence. When $m \geq d$, the
$d$ right singular vectors form an
orthonormal basis of $\mathbb{R}^{d}$, and the
smallest singular value is the smallest
Euclidean norm of a linear combination of the feature
columns with unit-norm coefficients,
\[
\lambda_{d}
= \min_{{\mathbf u} \in \mathbb{R}^{d}, \, \Vert {{\mathbf u}} \Vert = 1}
\Vert {{\mathbf X} {\mathbf u}} \Vert \text{,}
\]
attained at the right singular vector
${\mathbf u}^{(d)}$. The identity holds since a unit-norm ${\mathbf u} =
\sum_{j=1}^{d} c_{j}
{\mathbf u}^{(j)}$ gives $\Vert {{\mathbf X} {\mathbf u}} \Vert^{2} =
\sum_{j=1}^{d} c_{j}^{2} \lambda_{j}^{2}$,
a weighted average of the squared singular values. When
$d > m$, a unit-norm ${\mathbf u}$ orthogonal to
all $m$ right singular vectors gives
${\mathbf X} {\mathbf u} = \mathbf{0}$, so the minimum is $0$. A small
singular value therefore says that some combination of the
feature columns with unit-norm coefficients is nearly the zero
vector: the features are nearly collinear, and the right
singular vector names the combination. For the weather year
of Fig. 1, with every measurement scaled to
zero sample mean and unit sample variance, the smallest
singular value is $0.05$ against a largest of $36.4$. Its
right singular vector places all of its weight on the lowest, the highest, and the mean temperature,
with coefficients $-0.37$, $-0.46$, and $0.81$, because the mean
temperature of a day is the midpoint of its lowest and its highest
up to a residual with standard deviation $0.03$ degrees. Dropping the mean
temperature raises the smallest singular value to $4.19$
(pythondemos/featuremtx.py). The size of a
singular value depends on the units of the columns, which is
why the scaling to unit sample variance comes first. The
squares of the
singular values are the eigenvalues of
${\mathbf X}^{\top} {\mathbf X}$, which for features with zero
sample mean is $m$ times their sample covariance matrix.
The same eigenvalues and eigenvectors of ${\mathbf X}^{\top} {\mathbf X}$ determine principal component analysis (PCA). Its dimensionality reduction keeps the eigenvectors of the largest eigenvalues as the new features, and the sum over the data points of the squared errors of reconstructing the feature vectors from them is the sum of the eigenvalues dropped (Bishop, 2006, Sect. 12.1.2).
Another important property of a feature matrix is the condition number $\kappa\!\left({\mathbf X}\right) = \lambda_{1} / \lambda_{\operatorname{rank}({\mathbf X})}$, the ratio of the largest singular value to the smallest nonzero one. For full column rank, it is the ratio of the largest to the smallest singular value (Golub and Loan, 2013, Sect. 5.3.1). The condition number enters linear regression twice: through the number of GD steps, and through the robustness of the learned model parameters against perturbations of the training set. The number that matters in both is its square $\kappa\!\left({\mathbf X}\right)^{2}$. The objective function $f({\mathbf w}) = (1/m) \Vert {{\mathbf X} {\mathbf w} - {\mathbf y}} \Vert^{2}$ has the constant Hessian $(2/m) {\mathbf X}^{\top} {\mathbf X}$, whose eigenvalues are the squared singular values of ${\mathbf X}$ scaled by $2/m$. The condition number of ${\mathbf X}^{\top} {\mathbf X}$ is therefore \begin{equation} \label{eq_featuremtx_condsq_dict} \kappa\!\left({\mathbf X}^{\top} {\mathbf X}\right) = \kappa\!\left({\mathbf X}\right)^{2} \text{.} \end{equation}
The square \(\eqref{eq_featuremtx_condsq_dict}\) determines the convergence speed of GD on the empirical risk minimization (ERM) problem of linear regression. One step with an exact line search multiplies the gap between $f\big({\mathbf w}^{(t)}\big)$ and the minimum $f\big(\widehat{{\mathbf w}}\big)$ by at most $1 - 1/\kappa\!\left({\mathbf X}\right)^{2}$ (Boyd and Vandenberghe, 2004, Sect. 9.3.1). The number of steps that reaches a given gap therefore grows in proportion to $\kappa\!\left({\mathbf X}\right)^{2}$.
B-transformFig. 2 shows this for two
feature matrices built from the weather measurements of
Fig. 1. The features are the
relative humidity and the wind speed, the label is the highest
temperature, and each has its sample mean removed. In the
recorded units the condition number is $14.5$. After scaling each
feature to unit sample variance, it is $1.45$. GD
starts at the point at distance $\Vert {\widehat{{\mathbf w}}} \Vert$
from $\widehat{{\mathbf w}}$ for which it is slowest, where the gap
shrinks per step by exactly the factor in
\(\eqref{eq_featuremtx_exactrate_dict}\) (Boyd and Vandenberghe, 2004, Sect. 9.3.2),
\begin{equation}
\label{eq_featuremtx_exactrate_dict}
f\big({\mathbf w}^{(t+1)}\big) - f\big(\widehat{{\mathbf w}}\big)
= \Big( \frac{\kappa\!\left({\mathbf X}\right)^{2} - 1}
{\kappa\!\left({\mathbf X}\right)^{2} + 1} \Big)^{2}
\Big( f\big({\mathbf w}^{(t)}\big) - f\big(\widehat{{\mathbf w}}\big) \Big) \text{.}
\end{equation}
From no start does the gap shrink by less, since this factor
bounds the shrinkage of every
exact-line-search step on a quadratic objective function
(Bertsekas, 2016, Prop. 1.3.1). A gap of $10^{-6}$ of the
initial one then takes $731$ steps in the recorded units and $7$
after the scaling.
pythondemos/featuremtx.py
Consider perturbations of the training set that change ${\mathbf X}$ to ${\mathbf X} + \delta {\mathbf X}$ and ${\mathbf y}$ to ${\mathbf y} + \delta {\mathbf y}$, with ${\mathbf X} + \delta {\mathbf X}$ still of full column rank, and let $\widehat{{\mathbf w}} + \delta \widehat{{\mathbf w}}$ be the model parameters learned by linear regression on the perturbed training set. They solve the normal equations of the perturbed training set, \[({\mathbf X} + \delta {\mathbf X})^{\top} ({\mathbf X} + \delta {\mathbf X}) \big(\widehat{{\mathbf w}} + \delta \widehat{{\mathbf w}}\big) = ({\mathbf X} + \delta {\mathbf X})^{\top} ({\mathbf y} + \delta {\mathbf y}) \text{.}\] Moving the terms with $\widehat{{\mathbf w}}$ to the right side and using ${\mathbf X}^{\top} {\mathbf r} = \mathbf{0}$ for the least squares residual ${\mathbf r} = {\mathbf y} - {\mathbf X} \widehat{{\mathbf w}}$, which is the normal equations of the unperturbed training set, gives the exact equation \[({\mathbf X} + \delta {\mathbf X})^{\top} ({\mathbf X} + \delta {\mathbf X}) \, \delta \widehat{{\mathbf w}} = ({\mathbf X} + \delta {\mathbf X})^{\top} \big(\delta {\mathbf y} - \delta {\mathbf X} \, \widehat{{\mathbf w}}\big) + \delta {\mathbf X}^{\top} {\mathbf r} \text{.}\] Solving for $\delta \widehat{{\mathbf w}}$ applies the pseudoinverse of ${\mathbf X} + \delta {\mathbf X}$ to the noise in the labels and to the noise in the features acting on $\widehat{{\mathbf w}}$, and the inverse of $({\mathbf X} + \delta {\mathbf X})^{\top} ({\mathbf X} + \delta {\mathbf X})$ to the noise in the features acting on the residual.
The largest singular value of ${{\mathbf X}}^{+}$ is $1 / \lambda_{d}$, and that of $\big({\mathbf X}^{\top} {\mathbf X}\big)^{-1}$ is $1 / \lambda_{d}^{2}$ (Golub and Loan, 2013, Sect. 5.3.6). The same holds for ${\mathbf X} + \delta {\mathbf X}$ with its own smallest singular value. Let the largest singular value of $\delta {\mathbf X}$ be at most $\varepsilon \lambda_{1}$ and the Euclidean norm of $\delta {\mathbf y}$ at most $\varepsilon \Vert {{\mathbf y}} \Vert$, with $\varepsilon \, \kappa\!\left({\mathbf X}\right) < 1$. The smallest singular value of ${\mathbf X} + \delta {\mathbf X}$ is then at least $\lambda_{d} - \varepsilon \lambda_{1}$ (Golub and Loan, 2013, Cor. 8.6.2), and taking Euclidean norms in the exact equation gives the perturbation bound \begin{equation} \label{eq_featuremtx_bound} \Vert {\delta \widehat{{\mathbf w}}} \Vert \leq \frac{\varepsilon \, \kappa\!\left({\mathbf X}\right)} {1 - \varepsilon \, \kappa\!\left({\mathbf X}\right)} \Big( \frac{\Vert {{\mathbf y}} \Vert}{\lambda_{1}} + \Vert {\widehat{{\mathbf w}}} \Vert \Big) + \frac{\varepsilon \, \kappa\!\left({\mathbf X}\right)^{2}} {\big(1 - \varepsilon \, \kappa\!\left({\mathbf X}\right)\big)^{2}} \frac{\Vert {{\mathbf r}} \Vert}{\lambda_{1}} \text{.} \end{equation} The bound \(\eqref{eq_featuremtx_bound}\) holds for every perturbation with $\varepsilon \, \kappa\!\left({\mathbf X}\right) < 1$.
The bound \(\eqref{eq_featuremtx_bound}\) carries over to the prediction for any given feature vector ${\mathbf x}$, such as that of a test data point. The learned linear model predicts ${\mathbf x}^{\top} \widehat{{\mathbf w}}$ before and ${\mathbf x}^{\top} \big(\widehat{{\mathbf w}} + \delta \widehat{{\mathbf w}}\big)$ after the perturbation. The prediction therefore changes by ${\mathbf x}^{\top} \delta \widehat{{\mathbf w}}$, and the Cauchy-Schwarz inequality bounds this change by \begin{equation} \label{eq_featuremtx_predbound} \big| {\mathbf x}^{\top} \delta \widehat{{\mathbf w}} \big| \leq \Vert {{\mathbf x}} \Vert \, \Vert {\delta \widehat{{\mathbf w}}} \Vert \leq \Vert {{\mathbf x}} \Vert \Bigg( \frac{\varepsilon \, \kappa\!\left({\mathbf X}\right)} {1 - \varepsilon \, \kappa\!\left({\mathbf X}\right)} \Big( \frac{\Vert {{\mathbf y}} \Vert}{\lambda_{1}} + \Vert {\widehat{{\mathbf w}}} \Vert \Big) + \frac{\varepsilon \, \kappa\!\left({\mathbf X}\right)^{2}} {\big(1 - \varepsilon \, \kappa\!\left({\mathbf X}\right)\big)^{2}} \frac{\Vert {{\mathbf r}} \Vert}{\lambda_{1}} \Bigg) \text{.} \end{equation} The change of the prediction is therefore at most $\Vert {{\mathbf x}} \Vert$ times the right-hand side of the bound \(\eqref{eq_featuremtx_bound}\), and grows with the norm of the feature vector.
Fig. 3 shows the robustness of $\widehat{{\mathbf w}}$ against perturbations on a related but different and smaller dataset, the first days of the twelve months of $2024$, twelve of the rows of Fig. 1. Each day has the feature vector ${\mathbf x} = (1, x)^{\top}$ with $x$ its lowest temperature, and its highest temperature as the label. A hypothesis of the linear model then has intercept $w_{1}$ and slope $w_{2}$, and the feature matrix has a column of ones and the column of the lowest temperatures. Its condition number is $14.9$, and the least squares residual is $0.20$ times the norm of ${\mathbf y}$.
Two constructions of a perturbation of relative size $\varepsilon = 0.01$ are compared. The first is chosen adversarially, to make the change of the model parameters learned by linear regression as large as possible: $\delta {\mathbf X} = -\varepsilon \lambda_{1} {\mathbf v}^{(2)} \big({\mathbf u}^{(2)}\big)^{\top}$ and $\delta {\mathbf y} = \pm \varepsilon \Vert {{\mathbf y}} \Vert {\mathbf v}^{(2)}$, with the sign for which $\widehat{{\mathbf w}}$ moves more. It changes $\widehat{{\mathbf w}}$ by norm $2.23$, which is $64$ percent of the right-hand side of the bound \(\eqref{eq_featuremtx_bound}\). The second construction uses $100$ realizations of random $\delta {\mathbf X}$ and $\delta {\mathbf y}$. They are generated with independent and identically distributed (i.i.d.) Gaussian random variables (RVs) as their entries and then normalized so that the largest singular value of $\delta {\mathbf X}$ is $\varepsilon \lambda_{1}$ and the Euclidean norm of $\delta {\mathbf y}$ is $\varepsilon \Vert {{\mathbf y}} \Vert$. The largest change among the $100$ realizations is $1.17$, which is $34$ percent of the right-hand side of the bound \(\eqref{eq_featuremtx_bound}\).
B-perturbFor a day with lowest temperature $x$ the feature vector
$(1, x)^{\top}$ has
norm $\sqrt{1 + x^{2}}$. By the prediction bound
\(\eqref{eq_featuremtx_predbound}\) the prediction therefore
changes by at most $\sqrt{1 + x^{2}}$ times the right-hand
side of the bound \(\eqref{eq_featuremtx_bound}\): $3.5$ degrees at
$x = 0$ and $69$ degrees at $x = 20$. The two dotted curves in
Fig. 3(a) trace that bound and leave the plotted
range. The hypotheses learned from the random
perturbations stay within $1.6$ degrees of the learned
hypothesis over the plotted range, and the hypothesis
after the adversarial construction within $3.1$ degrees. Panel
(b) repeats the comparison for $\varepsilon$ from
$5 \cdot 10^{-4}$ to $5 \cdot 10^{-2}$. The adversarial
construction reaches more than half of the right-hand side of the
bound \(\eqref{eq_featuremtx_bound}\) up to $\varepsilon = 0.02$, the
random construction less than half at every $\varepsilon$.
pythondemos/featuremtx.py
Synonyms: design matrix, data matrix.
See also: dataset, data point, feature vector, feature, array, matrix, design matrix, linear model, parameter space, singular value decomposition, singular value, rank, condition number, sample covariance matrix, principal component analysis, dimensionality reduction, column space.
@misc{dictml_featuremtx,
author = {Jung, Alexander},
editor = {Olioumtsevits, Konstantina and Schnoor, Ekkehard},
title = {feature matrix},
howpublished = {Dictionary of Applied Machine Learning (course edition)},
year = {2026},
doi = {10.5281/zenodo.21569296},
note = {ISBN 978-952-64-3013-3, CC BY 4.0, retrieved 2026-11-26},
url = {https://dictionaryofml.org/terms/featuremtx.html}
}