# feature importance

*Entry of the [Dictionary of Applied Machine Learning](https://dictionaryofml.org) (course edition), by Alexander Jung, Aalto University. CC BY 4.0. Updated 2026-11-07. [HTML](https://dictionaryofml.org/terms/featureimportance.html) · [typeset PDF](https://dictionaryofml.org/terms/featureimportance.pdf) · [LaTeX](https://dictionaryofml.org/terms/featureimportance.tex) · [Python demo](https://dictionaryofml.org/terms/featureimportance.py) · [notebook](https://dictionaryofml.org/terms/featureimportance.ipynb)*

Math is LaTeX with the book's macros expanded, so no notation package is needed to read it.

## Abstract

Feature importance assigns a number to each feature, an attribute of a data point, measuring how strongly a learned hypothesis relies on that feature when it maps a feature vector to a prediction. Coefficients of a linear model describe the prediction change per unit of a feature; their magnitudes depend on the units of the features, which standardizing the features removes. The permutation importance of a feature is the increase of the average loss when its values are permuted across the data points. The score uses the learned hypothesis only through its predictions on a scoring dataset, so it applies to a random forest as well as to a linear model, whereas coefficient magnitudes need a linear hypothesis or a linear approximation of a nonlinear one. The score characterizes one fixed learned hypothesis and additionally depends on a scoring dataset distinct from the training set used to learn that hypothesis. It therefore measures reliance on a feature, not the usefulness of the feature itself: a feature that predicts the label well obtains a score near zero whenever the hypothesis ignores it.

## Definition

The weather station Krems an der Donau (Austria) records six observations of each day: the maximum and the minimum air temperature, the mean air pressure, the mean relative humidity, the sunshine duration, and the precipitation. Each data point is a day, the day whose maximum temperature is to be predicted. Its label $y$ is that maximum temperature, and its twelve features $x_{1},\ldots,x_{12}$ are the six observations of the day before and the six observations of two days before.

Fig. 1 depicts observed maximum daily temperatures along with their predictions obtained from a hypothesis $\widehat{h}$ learned via linear regression. The prediction (or forecast) $\widehat{h}({\mathbf x})$ for a day is computed from the feature vector ${\mathbf x} = \big(x_{1},\ldots,x_{12} \big)^{\top}$. An importance score quantifies how strongly this prediction relies on a particular feature of the data point. It assigns a number to each feature of a data point: a large number marks a feature which strongly affects the prediction, while a number near zero marks a feature that barely affects it.

Machine learning methods compute feature importance scores for different purposes. As an explanation in explainable artificial intelligence, a score describes how much a learned hypothesis relies on individual features of a data point (Molnar, 2025). During model selection, importance scores can guide the choice of a subset of the features of the data points, after which a new hypothesis is learned using that subset (Guyon and Elisseeff, 2003).

![Figure 1 of the entry featureimportance](https://dictionaryofml.org/terms/fig/featureimportance-fig1.svg)

*Figure 1: Measured maximum daytime temperature (gray stems with circular markers) at the weather station Krems an der Donau (Austria) for June 2024, and the corresponding predictions (black crosses) of a hypothesis learned by linear regression from the twelve features of the two preceding days. Data generated by pythondemos/featureimportance.py*

A natural choice of feature importance scores for a learned linear model $\widehat{h}({\mathbf x}) =
\sum_{j=1}^{12} \widehat{w}_{j}
x_{j}$ are the weights $\widehat{w}_{j}$. Increasing the $j$-th feature of a data point by one unit changes the prediction by $\widehat{w}_{j}$. A feature $x_{j}$ with a large magnitude $|\widehat{w}_{j}|$ can then be considered important.

One challenge of using the weights $\widehat{w}_{j}$ delivered by linear regression as feature importance scores is their dependence on the scale of the feature values. Scaling one feature by $10^{-5}$ makes linear regression learn a weight $\widehat{w}_{j}$ that is larger by the factor $10^{5}$, while every prediction stays the same. By rescaling a feature, or changing its measurement unit, its importance can therefore be made arbitrarily large or small. This dependence is avoided by applying linear regression to standardized features (see feature standardization): each column of the feature matrix is centered by its sample mean and divided by its standard deviation, so that $\widehat{w}_{j}$ becomes the prediction change per standard deviation of the $j$-th feature.

Algorithm 1 summarizes the construction of feature importance scores by applying linear regression to the standardized feature values of a given dataset with feature matrix ${\mathbf X} \in
\mathbb{R}^{m \times d}$, whose rows are the feature vectors $\big({\mathbf x}^{(r)}\big)^{\top}$, and label vector ${\mathbf y} = \big(y^{(1)}, \ldots,
y^{(m)}\big)^{\top}$. Algorithm 1 can also be used to compute feature importance scores for a given learned hypothesis (or trained model) $\widehat{h}$ that might be nonlinear (Ribeiro et al., 2016). Here, the label vector fed into Algorithm 1 contains the predictions of $\widehat{h}$, ${\mathbf y} = \big(
\widehat{h}({\mathbf x}^{(1)}), \ldots,
\widehat{h}({\mathbf x}^{(m)}) \big)^{\top}$, so the weights are those of a linear approximation of $\widehat{h}$ on the given dataset.

![Algorithm 1 of the entry featureimportance](https://dictionaryofml.org/terms/fig/featureimportance-alg1.svg)

*Algorithm 1: Feature importance from linear regression on standardized features*

Another construction of a feature importance score starts from a given hypothesis $\widehat{h}$ delivered by some machine learning method, and scores that hypothesis instead of learning one. This construction, introduced for random forests under the name variable importance (Breiman, 2001, Sect. 10), measures the change of the average loss when the values of a single feature are replaced by random values. In the original version, each decision tree of the random forest is scored on the training data points that were not in its own resampled training set, and the score is the relative increase of the misclassification rate. Algorithm 2 summarizes the method in a form that applies to a learned hypothesis of any kind. Fisher et al. (2019, Sect. 3) introduce this form under the name model reliance, for a fixed hypothesis: the ratio, or alternatively the difference, of the expected loss with the $j$-th feature replaced by an independent copy and the expected loss without the replacement. They estimate the loss after the replacement over all pairs of data points instead of by a random permutation, and show that the score can be estimated on the training set itself. Algorithm 2 uses the difference and $B$ random permutations, as the original construction does. Its input is a dataset, characterized by a feature matrix ${\mathbf X}
\in \mathbb{R}^{m \times d}$ and a label vector ${\mathbf y} \in \mathbb{R}^{m}$, and a learned hypothesis (or trained model) $\widehat{h}$. This dataset is referred to as the scoring dataset. It should have the same statistical properties as the training set used to learn $\widehat{h}$: ideally, the data points of both are realizations of independent and identically distributed RVs.

The score $I_{j}$ of the $j$-th feature compares the average loss of $\widehat{h}$ on the dataset $\big({\mathbf X}, {\mathbf y}\big)$ with its average loss on a perturbed dataset with the same ${\mathbf y}$ but a different feature matrix $\widetilde{{\mathbf X}}^{(j)} =
\big(\widetilde{{\mathbf x}}^{(1)}, \ldots,
\widetilde{{\mathbf x}}^{(m)}\big)^{\top}$. The perturbed feature matrix is obtained by permuting the entries of the $j$-th column of ${\mathbf X}$ across its rows, with every other column unchanged (Fig. 2). The permutation importance of the $j$-th feature is the increase of the average loss that this exchange causes,

$$
I_{j} :=
\frac{1}{m} \sum_{r=1}^{m}
L\left(\left( \widetilde{{\mathbf x}}^{(r)},y^{(r)} \right),\widehat{h} \right)
- \frac{1}{m} \sum_{r=1}^{m}
L\left(\left( {\mathbf x}^{(r)},y^{(r)} \right),\widehat{h} \right)
\text{,}
$$

where $y^{(r)}$ is the label of data point $r$. The permutation is random, so Algorithm 2 averages $I_{j}$ over $B$ independent permutations of the column.

![Algorithm 2 of the entry featureimportance](https://dictionaryofml.org/terms/fig/featureimportance-alg2.svg)

*Algorithm 2: Permutation importance (variable importance), similar to Fisher et al. (2019, Sect. 3)*

![Figure 2 of the entry featureimportance](https://dictionaryofml.org/terms/fig/featureimportance-fig2.svg)

*Figure 2: Left: the feature matrix ${\mathbf X}$ of a dataset provided to Algorithm 2. This dataset is obtained from daily weather observations at Krems an der Donau; the shaded column holds the maximum temperature of the day before. The first row is the data point of October 1, 2024, whose first feature, $15.4$, is the maximum temperature of September 30. Right: the perturbed feature matrix $\widetilde{{\mathbf X}}^{(1)}$ obtained by permuting the entries of that column across the $92$ rows while every other column stays as it is. The permutation importance of the feature is the increase of the average loss when the predictions are computed from the rows of $\widetilde{{\mathbf X}}^{(1)}$ instead of the rows of ${\mathbf X}$. Values from pythondemos/featureimportance_weather.csv; the permutation is the first one drawn by pythondemos/featureimportance.py*

Fig. 3 plots $I_{j}$ computed by Algorithm 2 with $B = 20$ for the weather data points of Krems an der Donau. The scoring dataset consists of the $92$ data points whose label is the maximum temperature of a day from October 1 to December 31, 2024, so their features are the observations of September 29 to December 30. The linear hypothesis of Fig. 1 was learned on the training set of the $272$ data points whose label days run from January 3 to September 30. The maximum temperature of the day before obtains the largest score, while the minimum temperature of the day before obtains a score near zero. That minimum temperature is not useless: its correlation with the label on the scoring dataset is $0.69$, as strong as that of the minimum temperature two days before. The score $I_{j}$ primarily reflects how much $\widehat{h}$ relies on the feature $x_{j}$, which can be different from its relevance for the label of a data point.

![Figure 3 of the entry featureimportance](https://dictionaryofml.org/terms/fig/featureimportance-fig3.svg)

*Figure 3: Permutation-importance scores (Algorithm 2, $B = 20$) for the twelve features of the data points used for the temperature forecast of Fig. 1, in ascending order of $I_{j}$ (black crosses), and the value $2 \widehat{w}_{j}^{2} \operatorname{var}\left(x_{j}\right)$ computed from the weights of the linear hypothesis (gray circles), which the squared error loss derivation below gives as an approximation of $I_{j}$. Algorithm 2 was run on the scoring dataset, the $92$ data points whose label days run from October 1 to December 31, 2024, whereas the linear hypothesis was learned on the data points whose label days run from January 3 to September 30. Tick labels: max temp and min temp are the maximum and the minimum air temperature, precip the precipitation, and day before and two days before count back from the day whose maximum temperature is the label. Data generated by pythondemos/featureimportance.py*

Algorithm 2 requires a choice of the loss function as input. For the squared error loss, the scores delivered by Algorithm 2 are closely related to the coefficients delivered by Algorithm 1. Indeed, randomly permuting column $j$ of ${\mathbf X}$ is the same as replacing $x_{j}$ with the realization of a random variable $x_{j}^{\prime}$. For a linear model, this replacement changes the prediction by $\delta_{j} =
\widehat{w}_{j} (x_{j}^{\prime}
- x_{j})$. The squared error loss increase is

\begin{equation}
\tag{1}
\delta_{j}^{2} - 2 \big(y -
\widehat{h}({\mathbf x})\big) \delta_{j}
\text{,}
\end{equation}

where $y$ is the label of the data point and $\widehat{h}({\mathbf x})$ the prediction for its feature vector. The score $I_{j}$ delivered by Algorithm 2 is obtained by averaging the loss increase Eq. (1) over all data points of the scoring dataset. The random variable $x_{j}^{\prime}$ has the same variance as $x_{j}$, and if the two have zero covariance, then $\mathbb{E}\{(x_{j}^{\prime}
-x_{j})^{2}\}
=2\,\operatorname{var}\left(x_{j}\right)$. Suppose that the prediction error $y-\widehat{h}({\mathbf x})$ has expectation zero given ${\mathbf x}$, as it does when $\widehat{h}$ is the conditional mean of $y$ given ${\mathbf x}$, and that $x_{j}^{\prime}$ is independent of the data point. Then this error is uncorrelated with $\delta_{j}$, the second term of the loss increase Eq. (1) has expectation zero, and the expected loss increase is $\mathbb{E}\{\delta_{j}^{2}\} =
2\widehat{w}_{j}^{2}
\operatorname{var}\left(x_{j}\right)$ (Gregorutti et al., 2017, Prop. 1). A learned $\widehat{h}$ only approximates that conditional mean, and a permuted column only approximates an independent copy, so the score satisfies $I_{j} \approx
2\widehat{w}_{j}^{2}
\operatorname{var}\left(x_{j}\right)$. For standardized features, $\operatorname{var}\left(x_{j}\right) = 1$ and $I_{j} \approx 2 \widehat{w}_{j}^{2}$: for a linear hypothesis, the score of Algorithm 2 is, up to the square, the score of Algorithm 1. The relation requires that the weights are standardized with respect to the dataset on which Algorithm 2 evaluates the average loss; this dataset need not be the training set of the hypothesis. For the maximum temperature of the day before, the weight of the hypothesis of Fig. 1 times the standard deviation of that feature on the scoring dataset is $4.96$, and $\sqrt{I_{j}/2} = 4.96$.

Algorithm 2 uses $\widehat{h}$ only through its predictions, so it applies to any learned hypothesis. Fig. 4 shows the scores for a random forest, an ensemble of decision trees, learned on the same training set and evaluated on the same scoring dataset as the linear hypothesis of Fig. 3. Both reach almost the same average squared error loss on the scoring dataset, $8.2$ in squared degrees Celsius, but they rely on the features differently.

![Figure 4 of the entry featureimportance](https://dictionaryofml.org/terms/fig/featureimportance-fig4.svg)

*Figure 4: Importance scores obtained from Algorithm 2 ($B = 20$; black circles) for the weather dataset of Fig. 1, for a random forest learned on the training set with label days from January 3 to September 30, 2024, and scored on the scoring dataset of Fig. 3, with label days from October 1 to December 31, in the feature order of that figure so that the two can be compared column by column. Tick labels as in Fig. 3. Data generated by pythondemos/featureimportance.py*

**Synonyms:** variable importance.

**See also:** [feature](https://dictionaryofml.org/terms/feature.html), [feature matrix](https://dictionaryofml.org/terms/featuremtx.html), linear model, [loss](https://dictionaryofml.org/terms/loss.html), [random forest](https://dictionaryofml.org/terms/randomforest.html), local interpretable model-agnostic explanations, covariance.

## References

- Fisher et al. (2019). All Models are Wrong, but Many are Useful: Learning a Variable's Importance by Studying an Entire Class of Prediction Models Simultaneously. *Journal of Machine Learning Research*. <https://www.jmlr.org/papers/v20/18-760.html>
- Molnar (2025). Interpretable Machine Learning: A Guide for Making Black Box Models Explainable. *Ebook*. <https://christophm.github.io/interpretable-ml-book/>
- Guyon and Elisseeff (2003). An introduction to variable and feature selection. *Journal of machine learning research*.
- Ribeiro et al. (2016). ``Why Should I Trust You?'': Explaining the Predictions of Any Classifier. *Proc. 22nd ACM SIGKDD Int. Conf. Knowl. Discovery Data Mining*. <https://doi.org/10.1145/2939672.2939778>
- Breiman (2001). Random Forests. *Machine Learning*. <https://doi.org/10.1023/A:1010933404324>
- Gregorutti et al. (2017). Correlation and variable importance in random forests. *Statistics and Computing*. <https://doi.org/10.1007/s11222-016-9646-1>

## Cite this entry

```bibtex
@misc{dictml_featureimportance,
  author = {Jung, Alexander},
  editor = {Olioumtsevits, Konstantina and Schnoor, Ekkehard},
  title = {feature importance},
  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-11},
  url = {https://dictionaryofml.org/terms/featureimportance.html}
}
```
