← back to EEE 485
Week 11119 min full read
7 concepts22 worked examples30 exercises4 exam-level7 figures
What are you here for?

11 Feature selection: ranking by correlation and mutual information, mRMR, best subset and forward stepwise

Start with this

One question before you read anything. Getting it wrong is the point: it shows you what this section is for.

§11.1 — two measurements to keep for a solar panel

A solar installation can keep only two of four measurements to predict daily energy $y$ with a straight-line model. Over 30 days their sample correlations with $y$ were computed.

Find(a) Which two measurements should be kept?
Givencloud cover $-0.9$, air temperature $0.3$, hours of daylight $0.6$, panel serial number $0.1$
Hint 1/4

Decide what makes a correlation strong before comparing the four numbers.

Hint 2/4

The strength of a straight-line trend is $\lvert\hat R_j\rvert$, or equally $\hat R_j^2$; the sign is only its direction.

Hint 3/4

Here the sizes are $0.9$, $0.3$, $0.6$ and $0.1$ for cloud cover, air temperature, daylight and serial number.

Hint 4/4

The two largest are cloud cover and daylight.

Show solution

For a straight-line model a feature's fit alone depends only on $\hat R_j^2$, so squaring is the whole method.

Square

$$(-0.9)^2=0.81,\quad 0.3^2=0.09,\quad 0.6^2=0.36,\quad 0.1^2=0.01$$

Squaring removes the direction and keeps the strength.

Keep the two largest

$$0.81\ (\text{cloud cover})\ \ge\ 0.36\ (\text{daylight})\ \ge\ 0.09\ \ge\ 0.01$$

Only two measurements are kept.

Answer $$\boxed{\text{cloud cover and daylight}}$$
Check

Each alone leaves the fraction $1-\hat R_j^2$ of the spread of $y$ unexplained: $0.19$ and $0.64$ for the two kept, $0.91$ and $0.99$ for the others.

A negative correlation is a direction, not a weakness.

A wafer fab can afford to log only two of its four sensors. The furnace thermometer and a backup thermometer are each the best single predictor of a defective wafer, so keeping both looks safe. Yet together they predict no better than one of them, while one thermometer and the humidity sensor explain every one of the 16 wafers.

By the end you can score features by correlation and by , pick $k$ of them with in a few subtractions, and choose a model size by cross-validation instead of by training error.

In 60 seconds

keeps $k$ of the $p$ original features. Ranking scores each feature from the data alone, mRMR adds features by relevance minus redundancy, and best subset and forward stepwise train the model on subsets and let cross-validation choose the size.

Correlation score
$$s_j=\hat R_j^2,\qquad \hat R_j=\frac{S_{jy}}{\sqrt{S_{jj}S_{yy}}}$$

screening features for straight-line trends; the sign is dropped

Mutual information
$$\begin{aligned}I(X;Y)&=\sum_{x,y}p(x,y)\log\tfrac{p(x,y)}{p(x)p(y)}\\&=H(Y)-H(Y\mid X)\end{aligned}$$

scoring any kind of dependence, in bits

mRMR step
$$\begin{aligned}X_l^*&=\arg\max_{X\notin S_{l-1}}\Big[I(X;Y)\\&\quad-\tfrac1{l-1}\textstyle\sum_{X'\in S_{l-1}}I(X;X')\Big]\end{aligned}$$

adding features without repeats, with two-variable estimates only

Fits needed
$$\begin{aligned}&\text{best subset: }2^p\\&\text{forward stepwise: }1+\tfrac{p(p+1)}2\end{aligned}$$

choosing between the two; the size is then picked by cross-validation

Three most common mistakes
  1. Ranking by the signed correlation: $-0.9$ is a strong feature. Score by $\hat R_j^2$.

  2. Adding relevances or keeping near copies: two thermometers tell no more than one. Use mRMR or a joint score.

  3. Choosing the model size by training RSS or $R^2$, which always favour the largest model. Use cross-validation.

Two course documents give different weights:

  • Chapter 1 slides, undergraduate line: midterm 25, final 25, four quizzes 20, two-phase project 30.
  • STARS syllabus page printed on 21 September 2026: midterm 30, final 30, problem sets and quizzes 20, project 20. It is the later document; confirm which split applies.
  • The STARS weekly list has feature extraction and feature selection as its ninth item; the lecture slides make feature selection chapter 11.
How much time do you have?
10 minutes

The squared-correlation score, mRMR on the wafer sensors, and the rule that cross-validation, not RSS, picks the size.

The 60-second card · Ranking features by a score, with correlation as the score · Minimum redundancy, maximum relevance (mRMR) · Best subset selection, with the size chosen by cross-validation · Formula card
45 minutes

Every method once with a worked example, then mRMR by hand from a full solution down to a bare problem.

The 60-second card · Ranking features by a score, with correlation as the score · Mutual information · Maximum relevance · Maximum dependency, exhaustively and by incremental search · Minimum redundancy, maximum relevance (mRMR) · Best subset selection, with the size chosen by cross-validation · Forward stepwise selection · Scaffolding comes off · Formula card
full read

Adds the proofs, the look-alike pairs, a full exam-style question and mixed practice where you pick the method yourself.

The opening pages · Recall first · Ranking features by a score, with correlation as the score · Mutual information · Maximum relevance · Maximum dependency, exhaustively and by incremental search · Minimum redundancy, maximum relevance (mRMR) · Best subset selection, with the size chosen by cross-validation · Forward stepwise selection · Method boxes · Look-alike pairs · Scaffolding comes off · Full exam-style question · Practice set · Check yourself
By the end of this section
  1. Rank features by a score and build the reduced data set; compute $\hat R_j$ from data and score by $\hat R_j^2$.

  2. Compute , and mutual information from a table, by the definition and by $H(Y)-H(Y\mid X)$.

  3. Explain why maximum relevance fails on near copies and on features that only work together.

  4. Run maximum dependency exhaustively and by incremental search, count their evaluations, and judge when a joint estimate can be trusted.

  5. Apply mRMR step by step from tables of relevance and pairwise mutual information.

  6. Select a model by best subset selection and choose its size by cross-validation, not by RSS or $R^2$.

  7. Compare forward stepwise with best subset selection: the path, the number of fits, and when the greedy path misses.

Syllabus coverage

Feature selection — covered

Selecting k of the p original features

  • and the reduced data set
  • the correlation score
  • entropy and mutual information
  • maximum relevance
  • maximum dependency and its incremental search
  • minimum redundancy maximum relevance (mRMR)
  • best subset selection with the size chosen by cross-validation
  • forward stepwise selection

Both halves of the weekly line name it: the lecturer's chapter title and the ninth item of the official list. The blocks follow the lecture's order.

Feature extraction — covered

Building new features out of the old ones, as PCA does, set against keeping a subset of the original ones.

The extraction method itself, PCA, was taught with ICA in the section on blind source separation. Here it is the contrast the lecture draws at the start of the chapter, and it returns in an interleaved practice question.

The lecture's comparison on gene data — covered

Maximum dependency against mRMR on a gene expression data set with 60 samples, 9703 genes and 9 cancer classes: mRMR selects features faster, and with many selected features it classifies more accurately, measured by leave-one-out cross-validation with a naive Bayes classifier, because joint mutual information is hard to estimate from 60 samples.

The lecture's plots are not reproduced. The estimation problem behind them is shown by a simulation in the maximum dependency block, and the choice of method at this scale is an exam-level practice question.

Selecting features inside each cross-validation fold — off syllabus

Any selection step that looks at the labels has to be repeated inside each fold, or the error estimate comes out too low.

Further reading, not in the lecture: it appears in one interleaved practice question only.

Recall first
Covariance and centered sums

$\operatorname{Cov}(X,Y)=E[(X-E[X])(Y-E[Y])]$. From data, $S_{xy}=\sum_i(x_i-\bar x)(y_i-\bar y)$ and $S_{xx}=\sum_i(x_i-\bar x)^2$.

The correlation score is built from these sums.

Least squares with one feature

$\hat\beta_1=S_{xy}/S_{xx}$, $\hat\beta_0=\bar y-\hat\beta_1\bar x$, and the residual sum of squares is $\mathrm{RSS}=S_{yy}-S_{xy}^2/S_{xx}$.

It shows that ranking by $\hat R_j^2$ is ranking by one-feature fit.

Joint, marginal and conditional pmf; independence

$p(x)=\sum_yp(x,y)$ and $p(y\mid x)=p(x,y)/p(x)$. $X$ and $Y$ are independent when $p(x,y)=p(x)p(y)$ for every $x$ and $y$; zero covariance does not imply it.

Mutual information is built from these three pmfs and is zero exactly at independence.

Least squares with several features

$\hat\beta$ minimizes $\mathrm{RSS}(\beta)=\sum_i\big(y_i-\beta_0-\sum_jx_{ij}\beta_j\big)^2$ over all coefficient vectors; the model with no features predicts $\bar y$.

Best subset and forward stepwise compare these fits across subsets.

Cross-validation

Leave-one-out: $\mathrm{CV}(n)=\frac1n\sum_i\big(y_i-\hat f_{D_i}(x_i)\big)^2$, each point predicted by a fit that never saw it; $k$-fold does the same with $k$ folds. Training error falls with flexibility, cross-validation error need not.

It is the fair judge between models of different sizes.

Lasso and PCA

Lasso minimizes $\mathrm{RSS}+\lambda\sum_j\lvert\beta_j\rvert$ and sets some coefficients of one linear model exactly to $0$. PCA builds scores $z_{im}=x_i^Tu_m$, each a combination of all $p$ features, without looking at $y$.

They are the two tools the chapter starts from, and the contrast for feature ranking.

Try it yourself first (2 questions)
1§11.2 — uncorrelated but dependent

A variable $x$ takes the values $-1$, $0$ and $1$ with probability $\tfrac13$ each, and $y=x^2$. A classmate computes $\operatorname{Cov}(x,y)=0$ and concludes that $x$ and $y$ are independent.

Find(a) Are $x$ and $y$ independent?
Given
  • $P(x=-1)=P(x=0)=P(x=1)=\tfrac13$

  • $y=x^2$

  • $\operatorname{Cov}(x,y)=E[x^3]-E[x]E[x^2]=0$

Hint 1/4

Independence is a statement about every pair of values, not about one summary number.

Hint 2/4

$x$ and $y$ are independent only if $P(y\mid x)=P(y)$ for every $x$ and $y$.

Hint 3/4

Here $P(y=0)=\frac13$, since only $x=0$ gives $y=0$, while $P(y=0\mid x=0)=1$.

Hint 4/4

The two differ, so $x$ and $y$ are dependent although uncorrelated.

Show solution

One cell where the product rule fails is enough to refute independence.

Marginal and conditional

$$\begin{aligned}&P(y=0)=P(x=0)=\tfrac13\\&P(y=0\mid x=0)=1\end{aligned}$$

$y=0$ happens only when $x=0$, and then always.

Compare

$$\begin{aligned}&p(0,0)=\tfrac13\\&\ne p(x=0)\,p(y=0)=\tfrac19\end{aligned}$$

The product rule fails in the cell $(0,0)$.

Answer $$\boxed{\begin{aligned}&\text{dependent,}\\&\text{although }\operatorname{Cov}(x,y)=0\end{aligned}}$$
Check

Covariance check: $E[xy]=E[x^3]=\frac13(-1+0+1)=0$ and $E[x]=0$, so the covariance really is $0$; the dependence is curved, not straight.

Zero covariance rules out a straight-line trend only; this section builds a score that is zero only at independence.

2§11.6 — adding a column of random numbers

A least squares model with an intercept is refitted after a column of random numbers, unrelated to $y$, is added as an extra feature.

Find(a) What can the new training RSS be?
Given
  • the old fit had training RSS $40.0$

  • the new column is pure noise

Hint 1/4

Compare the sets of models that least squares chooses from before and after the column is added.

Hint 2/4

The old model sits inside the new one: set the new coefficient to $0$.

Hint 3/4

Here the old fit, with the new coefficient at $0$, still gives RSS $40.0$ and is available to the new fit.

Hint 4/4

So the new RSS is at most $40.0$, and usually a little less.

Show solution

An argument about which fits are available is shorter than any computation.

The old fit is still available

$$\beta_{\text{new}}=0\ \Rightarrow\ \mathrm{RSS}=40.0$$

The larger model contains the smaller one.

Least squares takes the minimum

$$\mathrm{RSS}_{\text{new}}=\min_\beta\mathrm{RSS}(\beta)\le40.0$$

A minimum over a larger set cannot be larger.

Answer $$\boxed{\mathrm{RSS}_{\text{new}}\le40.0}$$
Check

Edge case: if the new column copies an old feature or the constant, the fit cannot change and RSS stays at $40.0$; the bound is reached, never exceeded.

Training error can only fall as features are added, so it cannot decide how many to keep.

Notation
symbolreads asmeanswatch out
$D=\{(x_i,y_i)\}_{i=1}^n,\ \ x_i\in\mathbb R^p$

the data set

$n$ labelled samples with $p$ features

$y_i$ may be a class label or a number.

$X=(X_1,\dots,X_p),\ \ Y$

the random features, the random label

$(X,Y)\sim P$, sampled independently

Capital letters for random variables, small ones for observed values.

$s_j,\ \ (j)$

the score of feature j; the feature ranked j-th

$s_{(1)}\ge s_{(2)}\ge\dots\ge s_{(p)}$

$(j)$ is a place in the ranking, $j$ a feature's index.

$\tilde D$

D tilde

the data restricted to the $k$ kept features

Same samples and labels, fewer columns.

$\hat R_j$

R hat j

the sample correlation of feature $j$ with $y$

Between $-1$ and $1$; the score is its square.

$H(Y),\ \ H(Y\mid X)$

entropy of Y; conditional entropy of Y given X

the uncertainty about $Y$ before and after $X$ is seen, in bits

$H(Y\mid X)$ averages over $x$ with weights $p(x)$.

$I(X;Y)$

mutual information of X and Y

$H(Y)-H(Y\mid X)$

Symmetric and never negative; at most $\min(H(X),H(Y))$.

$S,\ \ I(S;Y)$

a feature subset; its joint information with Y

the features in $S$ taken as one random vector

Needs the joint pmf of $\lvert S\rvert+1$ variables.

$\mathcal A,\ \ S^*$

all k-subsets; the maximum dependency subset

$\lvert\mathcal A\rvert=\binom pk$

Exhaustive search visits every member of it.

$S_l,\ \ X_l^*$

the set after step l; the feature added at step l

$S_l=S_{l-1}\cup\{X_l^*\}$ with $S_0=\emptyset$

Used by incremental search, mRMR and forward stepwise.

$M_0,\ \ M_k$

the ; the best model with k features

$M_0$ predicts $\bar y$; $M_k$ has the smallest RSS among models with $k$ features

The lecture's slides write $m_k^*$ for $M_k$.

$\mathrm{RSS},\ \ \mathrm{TSS},\ \ R^2$

residual and total sums of squares; R squared

$R^2=1-\mathrm{RSS}/\mathrm{TSS}$

Training quantities: they improve with every added feature.

$\mathrm{CV}(n),\ \ \mathrm{CV}(k)$

leave-one-out and k-fold errors

estimates of test error

The fair judge between model sizes.

Conventions used here
Logarithms and units.

$\log$ is base 2, so entropy and mutual information are in bits; $0\log0=0$.

The lecture writes log without a base. Natural logs give nats, 1 nat = 1.443 bits; rankings do not change, but never mix the two in one table.

.

Probabilities are replaced by counts over $n$; every mutual information computed from data on this page is a plug-in estimate.

It is the simplest estimate, and the one the lecture's warning about small samples applies to.

Ties.

When two features have the same score, the one with the lower index is taken.

The lecture does not fix a rule; a fixed one makes answers comparable.

Rounded tables.

Mutual information tables are given to two decimals, and mRMR is run on the rounded values.

In every worked example the winner beats the runner-up by more than the rounding, so the path does not depend on it.

Relevance and redundancy.

Relevance is $I(X;Y)$; the redundancy of a candidate is the average of $I(X;X')$ over the features already chosen.

This is the lecture's mRMR penalty; other texts use other penalties.

Least squares models.

Every model in the last two blocks is least squares with an intercept, and $M_0$ predicts $\bar y$.

RSS values are comparable only within one family of models.

Choosing the size.

Models of different sizes are compared by cross-validation error, never by training RSS or $R^2$.

Training fit improves with every added feature.

Correlation score.

$s_j=\hat R_j^2$, as in the lecture; ranking by $\lvert\hat R_j\rvert$ gives the same order.

Squaring removes only the sign; the order of the sizes is kept.

Counting evaluations.

An evaluation is one estimate of a mutual information or one least squares fit; the null model counts as a fit.

The counts on this page, such as $1+p(p+1)/2$, use this convention.

11.1Ranking features by a score, with correlation as the score

Keeps the $k$ original features with the largest scores; with correlation the score is $\hat R_j^2$, so strong negative features stay.

Lasso picked features inside one linear model, and PCA replaced all $p$ features by mixtures; here we keep $k$ of the original columns and let the label choose them.

Solvable with what we have
  • Fit least squares on all $p$ features, as long as $n>p$.

  • Let lasso set some coefficients of one linear model to $0$, for one $\lambda$.

  • Compress the features into $k$ principal components, each a mixture of all $p$.

  • Compute each feature's sample correlation with $y$.

Not solvable yet
  • Choose $k$ original features once, before any model is trained, and hand them to any learner.

  • Keep the measurements readable: a doctor can act on two gene readings, not on a mixture of 9703.

  • Turn four correlations into a keep or drop decision that the sign does not distort.

Rank by $\hat R_j$ itself. The solar data give $\hat R=(-0.9,\ \textcolor{#8250df}{0.3},\ \textcolor{#8250df}{0.6},\ 0.1)$, so the top two are daylight ($0.6$) and air temperature ($0.3$), and cloud cover comes last.

Why it fails

The sign says which way $y$ moves, not how well $x_j$ predicts it: cloud cover at $-0.9$ is the strongest of the four. Squaring gives $0.81,\ \allowbreak 0.09,\ \allowbreak 0.36,\ \allowbreak 0.01$ and keeps cloud cover and daylight.

MethodMethod 11.1: Feature ranking with the correlation score
Conditions
  • $D=\{(x_i,y_i)\}_{i=1}^n$ with $x_i\in\mathbb R^p$ and a label $y_i$

  • $(j)$ is the index of the feature with the $j$-th largest score, as in the lecture

  • $S_{jy}=\sum_i(x_{ij}-\bar x_j)(y_i-\bar y)$, $S_{jj}=\sum_i(x_{ij}-\bar x_j)^2$, $S_{yy}=\sum_i(y_i-\bar y)^2$

$$\boxed{\begin{aligned}&s_{(1)}\ge s_{(2)}\ge\dots\ge s_{(p)}\\&\text{keep }(1),\dots,(k)\\&\tilde D=\{((x_{i(1)},\dots,x_{i(k)}),y_i)\}_{i=1}^n\\&\hat R_j=\frac{S_{jy}}{\sqrt{S_{jj}\,S_{yy}}},\quad s_j=\textcolor{#1f6feb}{\hat R_j^2}\end{aligned}}$$

Score every feature, sort the scores, and keep the columns with the $k$ largest; the reduced data set $\tilde D$ goes to any learner. With correlation the score is the square of the sample correlation, so a feature that moves against $y$ counts as much as one that moves with it.

Why the square is the right score

One feature, one line. The least squares line of $y$ on $x_j$ alone has slope $S_{jy}/S_{jj}$ and leaves $\mathrm{RSS}_j=S_{yy}-S_{jy}^2/S_{jj}$.

The same number, rescaled. Dividing by $S_{yy}$ gives $\mathrm{RSS}_j/S_{yy}=1-\hat R_j^2$.

So the ranking is by fit. A larger $\hat R_j^2$ means a smaller one-feature RSS, whatever the sign of $\hat R_j$; ranking by $\lvert\hat R_j\rvert$ gives the same order.

Looks like this, but is not

A feature with $\hat R_j=0$ looks useless, and a correlation screen would drop it.

Correlation sees straight-line trends only. For $x=-1, \allowbreak -1, \allowbreak 0, \allowbreak 0, \allowbreak 1, \allowbreak 1$ and $y=x^2$ the correlation is exactly $0$, yet $x$ fixes $y$. The next block's score catches this.

featurecorrelationscoreRSS alone

$x_1$ cloud

$-0.9$

$0.81$

$19$

$x_2$ air temp.

$0.3$

$0.09$

$91$

$x_3$ daylight

$0.6$

$0.36$

$64$

$x_4$ serial no.

$0.1$

$0.01$

$99$

Sorting by the score and sorting by the one-feature RSS give the same order: $x_1$, $x_3$, $x_2$, $x_4$.

Ranking four solar panel measurements by squared correlation

A solar installation logs 30 days. For the daily energy $y$ (kWh), $S_{yy}=100$. The sums for four measurements are listed below. Keep the best two by the correlation score.

Find$\hat R_j$ for each feature, the scores, and the two features kept.
Given
  • $x_1$ cloud cover: $S_{11}=25$, $S_{1y}=-45$

  • $x_2$ air temperature: $S_{22}=16$, $S_{2y}=12$

  • $x_3$ hours of daylight: $S_{33}=4$, $S_{3y}=12$

  • $x_4$ panel serial number: $S_{44}=9$, $S_{4y}=3$

  • $S_{yy}=100$

Solution

Three sums per feature are all the score needs, so no model is fitted; the sign is dropped on purpose by squaring.

Correlation of each feature with y

$$\begin{aligned}\hat R_1&=\frac{-45}{\sqrt{25\cdot100}}\\&=\frac{-45}{50}=-0.9\end{aligned}$$

Dividing by $\sqrt{S_{11}S_{yy}}$ puts every feature on the same scale from $-1$ to $1$, whatever its units.

$$\begin{aligned}&\hat R_2=\frac{12}{\sqrt{16\cdot100}}=0.3\\&\hat R_3=\frac{12}{\sqrt{4\cdot100}}=0.6\\&\hat R_4=\frac{3}{\sqrt{9\cdot100}}=0.1\end{aligned}$$

Same formula; $x_3$ has the same cross-product as $x_2$ but a smaller spread, so its correlation is larger.

Score, sort, keep

$$\begin{aligned}s&=(\hat R_1^2,\dots,\hat R_4^2)\\&=(0.81,\ 0.09,\ 0.36,\ 0.01)\end{aligned}$$

The score is the square, so $-0.9$ turns into the largest score.

$$\begin{aligned}&s_{(1)}=s_1=0.81\\&s_{(2)}=s_3=0.36\\&s_{(3)}=s_2,\quad s_{(4)}=s_4\end{aligned}$$

In the lecture's notation $(j)$ is the feature in place $j$ of the sorted list.

$$\tilde D=\big\{\big((x_{i1},x_{i3}),\,y_i\big)\big\}_{i=1}^{30}$$

The reduced data keep two original columns, so a reader still sees cloud cover and daylight, not mixtures.

Answer $$\boxed{\begin{aligned}&\text{keep }x_1\text{ (cloud cover)}\\&\text{and }x_3\text{ (daylight)}\\&s_1=0.81,\quad s_3=0.36\end{aligned}}$$
Check

One-feature least squares agrees: $\mathrm{RSS}_j=S_{yy}(1-\hat R_j^2)$ gives $19,\ 91,\ 64,\ 99$, and the two smallest belong to $x_1$ and $x_3$.

This answers the solar question that opens the page: square first, then sort. Cloud cover stays because its trend is strong, not because it points up.

Sample correlation of one feature from five raw readings

Five days of a sensor $x$ and an output $y$ were recorded: $x=(1,2,3,4,5)$ and $y=(5,3,4,2,1)$. Find $\hat R$ and the score $s=\hat R^2$.

Find$\hat R$ and $s$.
Given
  • $x=(1,2,3,4,5)$

  • $y=(5,3,4,2,1)$

Solution

Centering first keeps all three sums small and exact; the shortcut $\sum_ix_iy_i-n\bar x\bar y$ gives the same numbers with larger intermediate values.

Center both columns

$$\bar x=3,\ \bar y=3:\quad x-\bar x=(-2,-1,0,1,2),\quad y-\bar y=(2,0,1,-1,-2)$$

Both means are $15/5$; the correlation compares these deviations, not the raw values.

Three sums

$$S_{xy}=-4+0+0-1-4=-9,\qquad S_{xx}=10,\qquad S_{yy}=10$$

Products of paired deviations for $S_{xy}$, squares for the other two.

Correlation and score

$$\begin{aligned}&\hat R=\frac{-9}{\sqrt{10\cdot10}}=-0.9\\&s=\hat R^2=0.81\end{aligned}$$

The largest possible $\lvert S_{xy}\rvert$ is $\sqrt{S_{xx}S_{yy}}=10$, so $-9$ is close to a perfect downhill line.

Answer $$\boxed{\hat R=-0.9,\qquad s=0.81}$$
Check

The least squares slope is $S_{xy}/S_{xx}=-0.9$ and $\mathrm{RSS}=S_{yy}-S_{xy}^2/S_{xx}=10-8.1=1.9$, so $1-\mathrm{RSS}/S_{yy}=0.81$ matches the score.

Center, then three sums: the score never needs the slope, but the slope checks it.

Checkpoint
§11.1 — keeping two features by correlation

A screen of four features for a regression gives their sample correlations with $y$.

Find(a) Which two features does the ranking keep?
Given
  • $\hat R_1=0.20,\ \allowbreak \hat R_2=-0.70,\ \allowbreak \hat R_3=0.65,\ \allowbreak \hat R_4=-0.10$

  • $k=2$, score $s_j=\hat R_j^2$

Hint 1/4

The ranking needs one score per feature; settle the score before sorting anything.

Hint 2/4

$s_j=\hat R_j^2$, and the $k$ largest scores are kept.

Hint 3/4

Here $\hat R=(0.20,\ -0.70,\ 0.65,\ -0.10)$ and $k=2$, so $s=(0.04,\ 0.49,\ 0.4225,\ 0.01)$.

Hint 4/4

The two largest scores belong to $x_2$ and $x_3$.

Show solution

The score is fixed by the rule, so the only work is four squares and a sort.

Scores

$$s=(0.04,\ 0.49,\ 0.4225,\ 0.01)$$

The score is $\hat R_j^2$; the sign carries no weight.

Sort and keep

$$0.49\ (x_2)\ \ge\ 0.4225\ (x_3)\ \ge\ 0.04\ \ge\ 0.01$$

Only the two largest survive when $k=2$.

Answer $$\boxed{\text{keep }x_2\text{ and }x_3}$$
Check

Sorting by $\lvert\hat R_j\rvert$ gives the same order, $0.70>0.65>0.20>0.10$, as it must, since squaring keeps the order of sizes.

Square before you sort; the sign only tells the direction of the trend.

⚠ Ranking by the signed correlation

The largest number looks like the best feature, and negative numbers look small.

wrong$$s_j=\hat R_j:\quad \text{keep }x_3\ (0.6)\text{ and }x_2\ (0.3)$$
right$$s_j=\hat R_j^2:\quad \text{keep }x_1\ (0.81)\text{ and }x_3\ (0.36)$$
⚠ Reading zero correlation as no relation

Zero covariance sounds like independence, but it only rules out a straight-line trend.

wrong$$\hat R_j=0\ \Rightarrow\ X_j\text{ tells nothing about }Y$$
right$$y=x^2,\ x\in\{-1,0,1\}:\quad \hat R=0,\ \text{yet }x\text{ fixes }y$$

11.2Mutual information: how much a feature tells about the label

Measures in bits how much knowing $X_j$ reduces the uncertainty about $Y$; zero exactly when they are independent, whatever the shape.

Correlation missed $y=x^2$ because it only measures straight-line trends; we want a score that is zero exactly when $X_j$ and $Y$ are independent.

DefinitionDefinition 11.2: Entropy and mutual information
Conditions
  • $(X,Y)\sim P$ with joint pmf $p(x,y)$ and marginals $p(x)=\sum_yp(x,y)$, $p(y)=\sum_xp(x,y)$

  • logarithms in base 2, so the unit is the bit; terms with $p=0$ count as $0$

  • $H(Y\mid X)=\sum_xp(x)\,H(Y\mid X=x)$ is the uncertainty about $Y$ left once $X$ is seen

  • for densities the sums become integrals, as in the lecture's continuous case

$$\boxed{\begin{aligned}&H(Y)=-\sum_yp(y)\log p(y)\\&I(X;Y)=\sum_{x,y}p(x,y)\log\tfrac{p(x,y)}{p(x)p(y)}\\&\quad=\textcolor{#1f6feb}{H(Y)-H(Y\mid X)}\\&\quad=H(X)-H(X\mid Y)\\&I(X;Y)\ge0\\&I(X;Y)=I(Y;X)\\&I(X;Y)=0\\&\quad\iff X,Y\ \text{independent}\end{aligned}}$$

Entropy is the uncertainty in $Y$, in bits: one fair yes or no is one bit. Mutual information compares every cell of the joint table with the product of its margins; it equals the uncertainty about $Y$ that disappears, on average, once $X$ is known, and the same amount the other way round.

Why the four properties hold

Zero at independence. If $p(x,y)=p(x)p(y)$ in every cell, every ratio is $1$ and every logarithm is $0$.

Symmetric. Swapping the roles of $x$ and $y$ leaves the double sum unchanged.

The entropy form. $\log\frac{p(x,y)}{p(x)p(y)}=\log p(y\mid x)-\log p(y)$; summing against $p(x,y)$ gives $-H(Y\mid X)+H(Y)$.

Never negative. With $\ln t\le t-1$: $-I\ln2=\sum p(x,y)\ln\frac{p(x)p(y)}{p(x,y)}\le\sum p(x)p(y)-1\le0$, the sums running over cells with $p(x,y)>0$. Equality forces every ratio to be $1$, which is independence.

At most $H(Y)$. $H(Y\mid X)\ge0$, so $I(X;Y)\le H(Y)$: no feature tells more than the label's own uncertainty.

Looks like this, but is not

A column of wafer serial numbers gets the largest possible estimate: each number appears once, so every cell holds one wafer, $H(Y\mid X)=0$ and the estimate is $H(Y)=1$ bit.

Frequencies from one wafer per cell only memorize the labels; for a new wafer the serial number predicts nothing. Mutual information belongs to the distribution, and such a table does not estimate it. The problem returns with sets of features.

band X₁humidity X₃wafersdefective

low

dry

2

0

low

humid

2

0

normal

dry

4

0

normal

humid

4

4

high

dry

2

2

high

humid

2

2

Low bands never fail and high bands always do; a normal band fails exactly when the room is humid. The shift is spread evenly, so it carries no information about defects.

Mutual information between humidity and defects, from the definition

Of 16 wafers, 8 were processed dry and 8 humid. Among the dry ones 2 are defective; among the humid ones 6 are. Compute $I(X_3;Y)$ in bits from the definition.

Find$I(X_3;Y)$.
Given
  • counts: dry and good $6$, dry and defective $2$, humid and good $2$, humid and defective $6$

  • $n=16$

Solution

Four cells with simple ratios make the definition quick here; the entropy route is kept for the check.

Joint and marginal pmf

$$\begin{aligned}&p(\text{dry},0)=\tfrac6{16},\quad p(\text{dry},1)=\tfrac2{16}\\&p(\text{humid},0)=\tfrac2{16}\\&p(\text{humid},1)=\tfrac6{16}\end{aligned}$$

Counts over $n$ are the plug-in probabilities.

$$\begin{aligned}&p(\text{dry})=p(\text{humid})=\tfrac12\\&p(Y=0)=p(Y=1)=\tfrac12\end{aligned}$$

Row and column sums of the table.

Ratios and logarithms

$$\begin{aligned}&\frac{6/16}{\tfrac12\cdot\tfrac12}=\tfrac32\ \text{(two cells)}\\&\frac{2/16}{\tfrac12\cdot\tfrac12}=\tfrac12\ \text{(two cells)}\end{aligned}$$

Every product of margins is $\frac14$; the diagonal cells are over-represented, the others under.

$$\begin{aligned}I&=2\cdot\tfrac6{16}\log\tfrac32+2\cdot\tfrac2{16}\log\tfrac12\\&=\tfrac34(0.585)-\tfrac14\end{aligned}$$

Base 2: $\log\frac32=\log3-1=0.585$ and $\log\frac12=-1$.

$$=0.439-0.25=0.189\ \text{bit}$$

The under-represented cells subtract, yet the total stays positive, as it must.

Answer $$\boxed{\begin{aligned}I(X_3;Y)&=\tfrac34\log3-1\\&=0.189\ \text{bit}\end{aligned}}$$
Check

Entropy route: $H(Y)=1$ bit, and each humidity group splits $3:1$, so $H(Y\mid X_3)=-\frac34\log\frac34-\frac14\log\frac14=0.811$ and $1-0.811=0.189$.

Plug-in mutual information is counts, margins, ratios and logs; the entropy route is the independent check.

Mutual information of the furnace band, by the entropy route

The furnace band $X_1$ is low for 4 wafers (all good), normal for 8 (4 good, 4 defective) and high for 4 (all defective). Compute $H(Y)$, $H(Y\mid X_1)$ and $I(X_1;Y)$.

Find$H(Y)$, $H(Y\mid X_1)$ and $I(X_1;Y)$.
Given
  • 16 wafers: furnace band $X_1$ low for 4 (all good), normal for 8 (4 defective), high for 4 (all defective)

  • 8 of the 16 wafers are defective

Solution

Two of the three bands are pure and one is split evenly, so every conditional entropy is $0$ or $1$ and the route needs no logarithm tables.

Uncertainty before

$$H(Y)=-\tfrac12\log\tfrac12-\tfrac12\log\tfrac12=1\ \text{bit}$$

8 of 16 defective: one fair yes or no.

Uncertainty left in each band

$$H(Y\mid\text{low})=0,\quad H(Y\mid\text{normal})=1,\quad H(Y\mid\text{high})=0$$

A pure group leaves nothing to guess; a 4:4 group leaves one bit.

$$\begin{aligned}H(Y\mid X_1)&=\tfrac4{16}\cdot0+\tfrac8{16}\cdot1+\tfrac4{16}\cdot0\\&=0.5\end{aligned}$$

Each band is weighted by its share of wafers, as in $\sum_xp(x)H(Y\mid X=x)$.

The difference

$$I(X_1;Y)=1-0.5=0.5\ \text{bit}$$

What the band removes from the one bit.

Answer $$\boxed{\begin{aligned}&H(Y)=1,\quad H(Y\mid X_1)=0.5\\&I(X_1;Y)=0.5\ \text{bit}\end{aligned}}$$
Check

Definition route: only the two pure cells contribute, each $\frac4{16}\log\frac{4/16}{(4/16)(8/16)}=\frac14\log2=\frac14$; the normal cells have ratio $1$. The total is $\frac12$.

When groups are pure or evenly split, the entropy route is mental arithmetic.

Zero correlation but 0.918 bit of information: y equals x squared

Six readings have $x=-1, \allowbreak -1, \allowbreak 0, \allowbreak 0, \allowbreak 1, \allowbreak 1$ and $y=x^2$. Compute the sample correlation and $I(X;Y)$.

Find$\hat R$ and $I(X;Y)$.
Given
  • $x=(-1, \allowbreak -1, \allowbreak 0, \allowbreak 0, \allowbreak 1, \allowbreak 1)$

  • $y=x^2=(1, \allowbreak 1, \allowbreak 0, \allowbreak 0, \allowbreak 1, \allowbreak 1)$

Solution

Computing both scores on the same six points shows what each one can see.

Correlation

$$\begin{aligned}&\bar x=0:\ S_{xy}=\sum_ix_i(y_i-\bar y)\\&\qquad=\sum_ix_i^3=0\end{aligned}$$

With $\bar x=0$ the term $\bar y\sum_ix_i$ vanishes, and the cubes of $-1$ and $1$ cancel in pairs.

$$\hat R=0$$

A zero numerator; the denominator is positive.

Mutual information

$$\begin{aligned}H(Y)&=-\tfrac13\log\tfrac13-\tfrac23\log\tfrac23\\&=0.918\end{aligned}$$

$y=0$ on 2 readings and $y=1$ on 4.

$$H(Y\mid X)=0\ \Rightarrow\ I(X;Y)=0.918\ \text{bit}$$

Each value of $x$ gives a single value of $y$, so nothing is left to guess.

Answer $$\boxed{\begin{aligned}&\hat R=0\\&I(X;Y)=H(Y)=0.918\ \text{bit}\end{aligned}}$$
Check

Definition route: the cells $(-1,1)$, $(0,0)$, $(1,1)$ each have probability $\frac13$, and $\frac13\log\frac32+\frac13\log3+\frac13\log\frac32=\log3-\frac23=0.918$.

Correlation measures straight-line trends; mutual information measures any dependence, so it is the safer screen when the shape is unknown.

Checkpoint
§11.2 — a feature that copies the label

A binary feature $X$ equals a balanced binary label $Y$ on every sample.

Find(a) What is $I(X;Y)$?
Given$p(0,0)=p(1,1)=\tfrac12$, $p(0,1)=p(1,0)=0$
Hint 1/4

Compare the uncertainty about $Y$ before and after $X$ is seen.

Hint 2/4

$I(X;Y)=H(Y)-H(Y\mid X)$.

Hint 3/4

Here $Y$ is a fair bit, so $H(Y)=1$, and $X=Y$ leaves nothing to guess, so $H(Y\mid X)=0$.

Hint 4/4

$I(X;Y)=1$ bit.

Show solution

The entropy route is one line here, because knowing $X$ leaves nothing about $Y$.

Before and after

$$H(Y)=1,\qquad H(Y\mid X)=0$$

A fair bit is one bit; a copy settles it completely.

$$I(X;Y)=1-0=1\ \text{bit}$$

The information is the uncertainty removed.

Answer $$\boxed{I(X;Y)=1\ \text{bit}}$$
Check

Definition route: two cells, each $\frac12\log\frac{1/2}{1/4}=\frac12$; the empty cells contribute nothing.

A copy of $Y$ reaches the ceiling $I(X;Y)=H(Y)$; no feature can tell more than the label's own uncertainty.

⚠ Mixing logarithm bases

Calculators default to $\ln$, and a table in bits with one value in nats still looks consistent.

wrong$$\begin{aligned}I(X_3;Y)&=\tfrac34\ln\tfrac32-\tfrac14\ln2\\&=0.131\ \text{bit}\end{aligned}$$
right$$0.131\ \text{nat}=\frac{0.131}{\ln2}=0.189\ \text{bit}$$
⚠ Averaging the groups without their weights

Three bands look like three equal parts, but they hold 4, 8 and 4 wafers.

wrong$$H(Y\mid X_1)=\tfrac13(0+1+0)=0.333$$
right$$\begin{aligned}H(Y\mid X_1)&=\tfrac4{16}\cdot0+\tfrac8{16}\cdot1+\tfrac4{16}\cdot0\\&=0.5\end{aligned}$$

11.3Maximum relevance: ranking by mutual information, and what it misses

Ranks features by $I(X_j;Y)$ and keeps the top $k$: cheap, but blind to features that repeat each other or only work together.

Put $s_j=I(X_j;Y)$ into the ranking recipe of the first block and you have the lecture's maximum relevance rule.

RuleRule 11.3: Maximum relevance
Conditions
  • $I(X_j;Y)$ estimated from $D$ for every $j$: $p$ two-variable estimates

  • ties broken by the lower index, a convention of this page

$$\boxed{\begin{aligned}&s_j=I(X_j;Y)\\&\text{keep the }k\text{ largest scores}\end{aligned}}$$

Score each feature by what it alone tells about the label, and keep the top $k$. Each score looks at one feature at a time, so it cannot see what two features share, or what they can do only together.

Why a copy adds nothing

Same groups. If $X_2=g(X_1)$ for a function $g$, knowing $X_1$ fixes $X_2$, so the pair $(X_1,X_2)$ splits the data into the same groups as $X_1$ alone.

Same uncertainty left. Then $H(Y\mid X_1,X_2)=H(Y\mid X_1)$ and $I(\{X_1,X_2\};Y)=I(X_1;Y)$, while the sum of relevances counts it twice.

Looks like this, but is not

Features with zero relevance look safe to drop. In a stairwell the lamp is on exactly when two switches disagree, and each switch alone has $I=0$ with the lamp.

Together the two switches decide the lamp: $I(\{A,B\};Y)=1$ bit. Relevance scores one feature at a time and cannot see features that work only as a team.

Maximum relevance on the four wafer sensors keeps the two thermometers

The relevances of the four sensors are $I(X_1;Y)=0.5$, $I(X_2;Y)=0.5$, $I(X_3;Y)=0.189$ and $I(X_4;Y)=0$ bit, where the backup thermometer $X_2$ shows the same band as $X_1$ on every wafer. Keep $k=2$ by maximum relevance and find how much the kept pair tells about $Y$.

FindThe kept pair and $I(\{X_1,X_2\};Y)$.
Given
  • relevances $0.5,\ \allowbreak 0.5,\ \allowbreak 0.189,\ \allowbreak 0$ bit for $X_1$ to $X_4$

  • $X_2=X_1$ on all 16 wafers

  • 16 wafers: furnace band $X_1$ low for 4 (all good), normal for 8 (4 defective), high for 4 (all defective)

Solution

The ranking needs only the four relevances; the joint value then needs only the groups the pair forms, which the copy makes easy.

Rank

$$s=(0.5,\ 0.5,\ 0.189,\ 0)\ \Rightarrow\ \text{keep }X_1,X_2$$

The two thermometers tie for the top; humidity is third.

What the pair knows

$$\begin{aligned}&(X_1,X_2)\in\{(\text{low},\text{low}),\\&(\text{normal},\text{normal}),\\&(\text{high},\text{high})\}\end{aligned}$$

The copy never disagrees, so the pair forms exactly the three groups of $X_1$.

$$H(Y\mid X_1,X_2)=H(Y\mid X_1)=0.5\ \Rightarrow\ I(\{X_1,X_2\};Y)=0.5$$

Same groups, same uncertainty left.

Answer $$\boxed{\begin{aligned}&\text{keep }X_1,X_2\\&I(\{X_1,X_2\};Y)=0.5\ \text{bit}\\&\text{not }0.5+0.5\end{aligned}}$$
Check

Humidity with $X_1$ does better: the pair $(X_1,X_3)$ leaves only pure groups, so $I(\{X_1,X_3\};Y)=H(Y)=1$ bit.

Relevances do not add, and a copy adds nothing; the next two blocks repair exactly this.

Two stairwell switches: relevance ranks the useful pair last

A stairwell lamp $Y$ is on exactly when switch $A$ at the bottom and switch $B$ at the top are in different positions. A cheap light sensor $L$ reports the lamp correctly 3 times in 4. Sixteen logged evenings show each setting of $(A,B)$ four times, with $L$ wrong once in each setting. Rank the three features by relevance with $k=2$.

Find$I(A;Y)$, $I(B;Y)$, $I(L;Y)$, the kept pair, and what the two switches tell together.
Given
  • $Y=1$ exactly when $A\ne B$; each setting of $(A,B)$ appears 4 times

  • $L=Y$ on 12 of the 16 evenings, wrong once in each setting

Solution

Every group splits evenly or $3:1$, so the only logarithm needed is $H$ of a $3:1$ split, $0.811$ bit, from the humidity example.

Each switch alone

$$A=0:\ Y=1\text{ on }4\text{ of }8;\qquad A=1:\ Y=1\text{ on }4\text{ of }8\ \Rightarrow\ I(A;Y)=0$$

Knowing one switch leaves the other a coin flip, so the lamp stays $50:50$; the same holds for $B$.

The sensor

$$L=1:\ Y=1\text{ on }6\text{ of }8;\quad L=0:\ Y=0\text{ on }6\text{ of }8\ \Rightarrow\ I(L;Y)=1-0.811=0.189$$

Given $L$, the lamp matches it $3:1$ in both groups.

Rank and compare

$$\text{keep }L\text{ and }A:\quad I(\{L,A\};Y)=I(L;Y)=0.189$$

The tie between $A$ and $B$ goes to the lower letter; $A$ is spread evenly over every $(L,Y)$ group, so it adds nothing to $L$.

$$I(\{A,B\};Y)=H(Y)-0=1\ \text{bit}$$

The two switches fix the lamp completely.

Answer $$\boxed{\begin{aligned}&I(A;Y)=I(B;Y)=0\\&I(L;Y)=0.189\\&\text{keeps }\{L,A\}:\ 0.189\ \text{bit}\\&\text{misses }\{A,B\}:\ 1\ \text{bit}\end{aligned}}$$
Check

Swap in the other switch: $\{L,B\}$ also gives $0.189$ by the same symmetry; only the two switches together reach the full bit.

A zero relevance does not prove a feature useless: features can inform only together, and a one-at-a-time score cannot see it.

Checkpoint
§11.3 — the information of a duplicated pair

A screen finds these relevances; feature $X_3$ is $X_1$ recorded in other units. With $k=2$, maximum relevance keeps $X_1$ and $X_3$.

Find(a) How much do $X_1$ and $X_3$ tell about $Y$ together?
Given
  • $I(X_1;Y)=0.42$, $I(X_2;Y)=0.10$, $I(X_3;Y)=0.42$, $I(X_4;Y)=0.31$ bit

  • $X_3$ is a one-to-one recoding of $X_1$

Hint 1/4

Ask what the second feature can add once the first is known.

Hint 2/4

If $X_3=g(X_1)$ for a one-to-one $g$, then $I(\{X_1,X_3\};Y)=I(X_1;Y)$.

Hint 3/4

Here $I(X_1;Y)=0.42$ bit and $X_3$ is $X_1$ in other units.

Hint 4/4

Together they tell $0.42$ bit.

Show solution

A recoding forms the same groups as the original, so the pair's leftover uncertainty is that of $X_1$ alone.

Same groups

$$H(Y\mid X_1,X_3)=H(Y\mid X_1)$$

Knowing $X_1$ already fixes $X_3$.

Same information

$$I(\{X_1,X_3\};Y)=H(Y)-H(Y\mid X_1)=I(X_1;Y)=0.42$$

The entropy form of mutual information, applied to the pair.

Answer $$\boxed{I(\{X_1,X_3\};Y)=0.42\ \text{bit}}$$
Check

Units cannot matter: mutual information uses only the probabilities of the groups, and a recoding only renames them.

A duplicate in new units is still a duplicate; its relevance tells you nothing about what it adds.

⚠ Adding relevances to score a set

Relevance looks like an amount, and amounts add.

wrong$$I(\{X_1,X_2\};Y)=I(X_1;Y)+I(X_2;Y)=1$$
right$$X_2=X_1:\quad I(\{X_1,X_2\};Y)=I(X_1;Y)=0.5$$
⚠ Dropping every zero-relevance feature

A score of $0$ reads like proof that the feature is useless.

wrong$$I(A;Y)=I(B;Y)=0\ \Rightarrow\ \text{drop }A\text{ and }B$$
right$$I(\{A,B\};Y)=1\ \text{bit}$$

11.4Maximum dependency, exhaustively and by incremental search

Scores whole subsets by $I(S;Y)$, which sees repeats and teamwork, at the price of $\binom pk$ subsets and $(k+1)$-variable estimates.

Both failures of maximum relevance came from scoring one feature at a time, so now the subset $S$ is scored as a whole.

RuleRule 11.4: Maximum dependency and incremental search
Conditions
  • $\mathcal A$ is the set of all $k$-element subsets of $\{X_1,\dots,X_p\}$

  • $I(S;Y)$ treats the features in $S$ as one random vector, so it needs the joint pmf or pdf of $k+1$ variables

  • incremental search starts from $S_0=\emptyset$ and never removes a feature

$$\boxed{\begin{aligned}&S^*=\arg\max_{S\in\mathcal A}I(S;Y)\\&\lvert\mathcal A\rvert=\binom pk\\&X_l^*=\arg\max_{X\notin S_{l-1}}\\&\qquad I(S_{l-1}\cup\{X\};Y)\\&S_l=S_{l-1}\cup\{X_l^*\},\quad l=1,\dots,k\\&\text{evaluations: }\sum_{l=1}^k(p-l+1)\\&\qquad=kp-\tfrac{k(k-1)}2\end{aligned}}$$

Maximum dependency tries every $k$-subset and keeps the one whose features, taken together, tell the most about $Y$. Incremental search grows the set one feature at a time, each time adding the feature that makes the enlarged set most informative, and it never undoes a step.

Counting the evaluations

Exhaustive. One joint estimate per $k$-subset: $\binom pk$ of them.

Incremental. Step $l$ tries each of the $p-l+1$ features not yet chosen, so the total is $p+(p-1)+\dots+(p-k+1)=kp-\frac{k(k-1)}2$.

What is not saved. The last step still scores sets of $k$ features with $Y$: a joint table over $k+1$ variables.

Looks like this, but is not

Incremental search looks as if it must end at the best subset, since every step takes the best step available.

In the stairwell data, step 1 must take the sensor $L$, the only feature with nonzero relevance. Every pair containing $L$ then scores $0.189$, while $\{A,B\}$, now out of reach, scores $1$ bit. A greedy first step cannot be undone.

Incremental search on the four wafer sensors finds a thermometer and humidity

Run incremental search with $k=2$ on the wafer sensors, using the relevances and the pair values listed.

Find$S_1$, $S_2$ and $I(S_2;Y)$.
Given
  • relevances $0.5,\ \allowbreak 0.5,\ \allowbreak 0.189,\ \allowbreak 0$ bit for $X_1$ to $X_4$

  • pair values $I(\{X_1,X_2\};Y)=0.5$, $I(\{X_1,X_3\};Y)=1$, $I(\{X_1,X_4\};Y)=0.5$

  • ties broken by the lower index

Solution

With $p=4$ and $k=2$ there are only $4+3=7$ evaluations, and every one is in the list.

Step 1: the most relevant feature

$$S_0=\emptyset:\quad I(X_j;Y)=(0.5,\ 0.5,\ 0.189,\ 0)\ \Rightarrow\ X_1^*=X_1$$

With $S_0$ empty the first step is maximum relevance; the tie with $X_2$ goes to the lower index.

Step 2: the best partner for $X_1$

$$I(\{X_1,X\};Y):\quad X_2\to0.5,\quad X_3\to1,\quad X_4\to0.5$$

Each candidate is scored together with $X_1$, so the copy $X_2$ gains nothing.

$$S_2=\{X_1,X_3\},\qquad I(S_2;Y)=1\ \text{bit}=H(Y)$$

The largest joint value, and it cannot be beaten, since $I(S;Y)\le H(Y)$.

Answer $$\boxed{\begin{aligned}&S_2=\{X_1,X_3\}\\&I(S_2;Y)=1\ \text{bit}\\&\text{every wafer explained}\end{aligned}}$$
Check

Exhaustive search over all $\binom42=6$ pairs agrees: the values are $0.5,\ \allowbreak 1,\ \allowbreak 0.5,\ \allowbreak 1,\ \allowbreak 0.5,\ \allowbreak 0.189$, and the maximum $1$ is reached by $\{X_1,X_3\}$ and $\{X_2,X_3\}$.

That settles the wafer puzzle from the opening: a thermometer and the hygrometer, not two thermometers. Scoring the set is what sees the copy.

Counting subsets: exhaustive search against incremental search

A sensor bank has $p=20$ features and we want $k=5$. How many joint mutual informations does each search compute? Repeat for the lecture's gene data, $p=9703$, with $k=3$.

Find$\binom pk$ and $kp-\frac{k(k-1)}2$ in both cases.
Given
  • $p=20,\ k=5$

  • $p=9703,\ k=3$

Solution

Both counts are closed forms, so no search has to be run.

Twenty features

$$\begin{aligned}\binom{20}5&=\frac{20\cdot19\cdot18\cdot17\cdot16}{5!}\\&=15504\end{aligned}$$

Ordered choices divided by the $5!$ orders of the same subset.

$$20+19+18+17+16=90$$

Step $l$ tries the $20-l+1$ features not yet chosen.

The gene data

$$\begin{aligned}\binom{9703}3&=\frac{9703\cdot9702\cdot9701}{6}\\&\approx1.52\times10^{11}\end{aligned}$$

Three factors over $3!$.

$$3\cdot9703-3=29106$$

$kp-k(k-1)/2$ with $k=3$.

Answer $$\boxed{\begin{aligned}&p=20:\ 15504\text{ against }90\\&p=9703:\ 1.52\times10^{11}\\&\qquad\text{against }29106\end{aligned}}$$
Check

For tiny problems the order flips: with $p=4$ and $k=3$ exhaustive search needs $\binom43=4$ subsets and incremental search $4+3+2=9$; the saving comes with large $p$.

Incremental search removes the combinatorial count, not the estimation problem: its last step still needs a table over $k+1$ variables.

Eight wafers and three coin-flip sensors: the estimate reaches one bit

Eight new wafers were logged with three extra sensors $b_1,b_2,b_3$ that are coin flips, unrelated to the label. On these wafers the three sensors happen to show each of the eight patterns once. Estimate $I(S;Y)$ from the counts for $S=\{b_1\}$, $\{b_1,b_2\}$ and $\{b_1,b_2,b_3\}$.

FindThe three plug-in estimates.
Given
  • $(b_1,b_2,b_3;Y)$: $(0,0,0;1)$, $(1,0,0;0)$, $(0,1,0;0)$, $(1,1,0;1)$

  • $(0,0,1;1)$, $(1,0,1;1)$, $(0,1,1;0)$, $(1,1,1;0)$

  • four of the eight wafers are defective, so $H(Y)=1$ bit

Solution

Every group is pure or split evenly, so the entropy route $H(Y)-H(Y\mid S)$ needs no logarithms.

One sensor

$$b_1=0:\ Y=1,0,1,0;\qquad b_1=1:\ Y=0,1,1,0\ \Rightarrow\ \hat I=1-1=0$$

Both groups split $2:2$, so $b_1$ alone leaves the full bit.

Two sensors

$$\begin{aligned}&00:\ Y=1,1\quad 10:\ Y=0,1\\&01:\ Y=0,0\quad 11:\ Y=1,0\\&\hat I=1-\tfrac48=0.5\end{aligned}$$

The pairs $(b_1,b_2)$ form four cells of two wafers; the two mixed cells hold half the wafers.

Three sensors

$$\text{eight cells of one wafer}\ \Rightarrow\ H(Y\mid S)=0,\quad \hat I=1\ \text{bit}$$

A cell with one wafer is pure by definition, whatever its label.

Answer $$\boxed{\begin{aligned}&\hat I=0,\ 0.5,\ 1\ \text{bit}\\&\text{true value: }I(S;Y)=0\end{aligned}}$$
Check

Relabel the wafers in any way with four defective: the three-sensor estimate stays $1$ bit, because each cell still holds one wafer. The number measures the sample size, not the sensors.

A joint estimate is only as good as the samples per cell: with more cells than samples, do not trust it.

Checkpoint
§11.4 — exhaustive or incremental within a budget

A team with $p=10$ candidate features wants $k=3$ and can afford about 50 joint mutual information estimates.

Find(a) Which search fits the budget, and how many estimates does it need?
Given
  • $p=10$, $k=3$

  • budget: about 50 estimates

Hint 1/4

Count the joint estimates of each search before comparing with the budget.

Hint 2/4

Exhaustive: $\binom pk$; incremental: $p+(p-1)+\dots+(p-k+1)$.

Hint 3/4

Here $p=10$ and $k=3$: $\binom{10}3$ against $10+9+8$.

Hint 4/4

Incremental search needs $27$ and fits; exhaustive search needs $120$.

Show solution

Two closed forms answer the question; nothing is run.

Exhaustive

$$\binom{10}3=\frac{10\cdot9\cdot8}{6}=120$$

Every 3-subset once.

Incremental

$$10+9+8=27$$

Step $l$ tries the $10-l+1$ features still out.

Answer $$\boxed{\begin{aligned}&\text{incremental: }27\text{ estimates}\\&\text{exhaustive: }120\end{aligned}}$$
Check

The formula $kp-\frac{k(k-1)}2=30-3=27$ gives the same count.

Count before you search: $\binom pk$ grows much faster than $kp$.

⚠ Counting subsets as a power

Choosing $k$ of $p$ sounds like $p$ choices made $k$ times.

wrong$$\binom{10}3=10^3=1000$$
right$$\binom{10}3=\frac{10\cdot9\cdot8}{3!}=120$$
⚠ Trusting a joint estimate from nearly empty cells

The number comes out of the same formula as a trustworthy one.

wrong$$\hat I(S;Y)=1\ \text{bit}\ \Rightarrow\ S\text{ predicts }Y\text{ perfectly}$$
right$$\text{cells}\gg n:\ \ \hat I(S;Y)\to H(Y)\ \text{even for coin flips}$$

11.5Minimum redundancy, maximum relevance (mRMR)

Adds one feature at a time by relevance minus average redundancy; only two-variable estimates, so it scales to thousands of features.

Incremental search removed the $\binom pk$ count but still needs a $(k+1)$-variable table at its last step; mRMR replaces the joint score by two-variable pieces.

RuleRule 11.5: Minimum redundancy, maximum relevance
Conditions
  • $S_0=\emptyset$; at $l=1$ there is no redundancy term, so the first pick is the most relevant feature

  • every term is a two-variable mutual information, $I(X;Y)$ or $I(X;X')$

  • a heuristic: $S_k$ need not maximize $I(S_k;Y)$

$$\boxed{\begin{aligned}X_l^*&=\arg\max_{X\notin S_{l-1}}\Big[\textcolor{#1f6feb}{I(X;Y)}\\&\quad-\textcolor{#d1690a}{\tfrac1{l-1}\textstyle\sum_{X'\in S_{l-1}}I(X;X')}\Big]\\S_l&=S_{l-1}\cup\{X_l^*\}\\&l=1,\dots,k\end{aligned}}$$

At each step a candidate earns what it tells about the label and pays the average of what it shares with the features already chosen. The best net score joins the set, and the cost per step is one new two-variable estimate for each remaining candidate.

Counting the two-variable estimates

Relevance. $p$ values $I(X_j;Y)$, computed once.

Redundancy. At step $l\ge2$ each of the $p-l+1$ candidates needs one new value, its mutual information with the feature added at step $l-1$; the older ones are reused.

Total. $p+\sum_{l=2}^k(p-l+1)$, the same order as incremental search, but no estimate involves more than two variables.

Looks like this, but is not

mRMR looks as if it should find the stairwell's two switches, since they share nothing with each other.

Pairwise terms cannot see teamwork. Step 1 takes the sensor $L$ ($0.189$); at step 2 each switch scores $0-0=0$, so mRMR ends with $\{L,A\}$ and $0.189$ bit, exactly like maximum relevance.

mRMR on the four wafer sensors

Run mRMR with $k=2$ on the wafer sensors, using the relevances and the redundancies with $X_1$ listed.

Find$S_2$ and the score of each candidate.
Given
  • relevances $0.5,\ \allowbreak 0.5,\ \allowbreak 0.189,\ \allowbreak 0$ bit for $X_1$ to $X_4$

  • $I(X_2;X_1)=1.5$, $I(X_3;X_1)=0$, $I(X_4;X_1)=0$ bit

  • ties broken by the lower index

Solution

Only two-variable values are needed and all of them are listed; no three-variable table is built.

Step 1, relevance only

$$X_1^*=X_1\quad(0.5,\ \text{tied with }X_2)$$

With $S_0$ empty the bracket is just $I(X;Y)$.

Step 2, relevance minus redundancy

$$X_2:\ 0.5-1.5=-1,\qquad X_3:\ 0.189-0=0.189,\qquad X_4:\ 0-0=0$$

At $l=2$ the average runs over one chosen feature; $I(X_2;X_1)=H(X_1)=1.5$ because $X_2$ copies $X_1$.

$$S_2=\{X_1,X_3\}$$

Humidity has the largest net score.

Answer $$\boxed{\begin{aligned}&S_2=\{X_1,X_3\}\\&I(S_2;Y)=1\ \text{bit}\end{aligned}}$$
Check

Incremental search reached the same pair from three-variable values: $I(\{X_1,X_3\};Y)=1$ against $0.5$ for $X_2$ or $X_4$ with $X_1$.

The penalty charged the copy for the $1.5$ bits it repeats, and that alone fixed the choice.

A third mRMR step: the redundancy is an average

A condition-monitoring study estimated from 40 pumps the relevances and pairwise mutual informations below. Run mRMR with $k=3$ and compare with the top three by relevance.

Find$S_3$, and the set the relevance ranking would keep.
Given
  • relevance (bit): $X_1\ 0.13$, $X_2\ 0.58$, $X_3\ 0.32$, $X_4\ 0.24$, $X_5\ 0.27$

  • $I(X_2;X_3)=0.53$, $I(X_2;X_5)=0.19$, $I(X_2;X_4)=0.10$, $I(X_3;X_5)=0.09$, $I(X_3;X_4)=0.07$

  • $I(X_4;X_5)=0.06$, $I(X_1;X_2)=0.04$, $I(X_1;X_5)=0.03$, $I(X_1;X_4)=0.02$, $I(X_1;X_3)=0.00$

Solution

The table is the whole input of mRMR; at step 3 each candidate needs two redundancy values, averaged.

Step 1: the most relevant feature

$$X_1^*=X_2\ (0.58)$$

The largest relevance.

Step 2: one overlap each

$$X_1:\ 0.13-0.04=0.09,\ \ X_3:\ 0.32-0.53=-0.21,\ \ X_4:\ 0.24-0.10=0.14,\ \ X_5:\ 0.27-0.19=0.08$$

Each redundancy is with $X_2$ alone; $X_3$, second by relevance, repeats most of $X_2$.

$$X_2^*=X_4$$

The largest net score, $0.14$.

Step 3: the average of two overlaps

$$\begin{aligned}&X_1:\ 0.13-\tfrac{0.04+0.02}2=0.10\\&X_3:\ 0.32-\tfrac{0.53+0.07}2=0.02\\&X_5:\ 0.27-\tfrac{0.19+0.06}2=0.145\end{aligned}$$

Now $l=3$: each candidate pays the average of its values with $X_2$ and $X_4$.

$$S_3=\{X_2,X_4,X_5\}$$

$0.145$ beats $0.10$.

Compare with the relevance ranking

$$\text{by relevance: }\{X_2,X_3,X_5\}$$

The top three by relevance; $X_3$ is second but repeats $0.53$ bit of $X_2$.

$$I(\{X_2,X_4,X_5\};Y)=0.81,\qquad I(\{X_2,X_3,X_5\};Y)=0.66$$

Joint values estimated from the 40 pumps: mRMR's set tells more about the fault.

Answer $$\boxed{\begin{aligned}&S_3=\{X_2,X_4,X_5\}\\&\text{by relevance: }\{X_2,X_3,X_5\}\end{aligned}}$$
Check

Each winner beats the runner-up by at least $0.045$ ($0.14$ against $0.09$, then $0.145$ against $0.10$), so two-decimal rounding of the table cannot change the path.

Five relevances and seven pairwise values, four at step 2 and three at step 3; no table over three or more variables.

Always divide by $l-1$: summing the two redundancies would give $X_5$ only $0.02$ and hand the third place to $X_1$.

Checkpoint
§11.5 — one mRMR score at step three

At step 3 of mRMR two features, $X_a$ and $X_b$, are already chosen. A candidate $X$ has relevance $0.40$ bit and shares $0.30$ bit with $X_a$ and $0.10$ bit with $X_b$.

Find(a) What is its mRMR score?
Given
  • $I(X;Y)=0.40$

  • $I(X;X_a)=0.30$, $I(X;X_b)=0.10$

Hint 1/4

The score is relevance minus a penalty; decide how the penalty combines the two shared values.

Hint 2/4

Score $=I(X;Y)-\frac1{l-1}\sum_{X'\in S_{l-1}}I(X;X')$, with $l=3$.

Hint 3/4

Here $0.40-\frac{0.30+0.10}2$.

Hint 4/4

The score is $0.20$.

Show solution

The rule is a single formula; the only choice is the divisor, $l-1=2$.

Penalty

$$\begin{aligned}&\tfrac1{l-1}\big(I(X;X_a)+I(X;X_b)\big)\\&\quad=\tfrac{0.30+0.10}2=0.20\end{aligned}$$

Two features are chosen, so the average is over two.

Score

$$0.40-0.20=0.20$$

Relevance minus the average redundancy.

Answer $$\boxed{0.20}$$
Check

Bounds check: the penalty must lie between the two redundancies, $0.10$ and $0.30$, and $0.20$ does.

The penalty is an average, so it can never exceed the largest single overlap.

⚠ Summing the redundancies

The bracket in the rule has a sum in it, and the factor in front is easy to drop.

wrong$$0.40-(0.30+0.10)=0$$
right$$0.40-\tfrac{0.30+0.10}2=0.20$$
⚠ Averaging over l instead of l minus 1

Step $l$ sounds like $l$ features, but only $l-1$ are chosen before it.

wrong$$0.40-\tfrac{0.30+0.10}3=0.27$$
right$$\text{at step }l=3:\ \ \tfrac1{l-1}=\tfrac12$$

11.6Best subset selection, with the size chosen by cross-validation

Fits all $2^p$ least squares models, keeps the lowest-RSS model of each size, and lets cross-validation pick the size.

Every score so far ignored the learner; now the learner itself judges each subset, here least squares judged by its RSS.

MethodMethod 11.6: Best subset selection
Conditions
  • least squares with an intercept; $M_0$ is the null model, $\hat y=\bar y$ for every $x$

  • there are $\binom pk$ models with exactly $k$ features, $2^p$ in all

  • $\mathrm{TSS}=\sum_i(y_i-\bar y)^2$ is the RSS of $M_0$

  • RSS only falls and $R^2$ only rises as $k$ grows, so neither may pick the size

$$\boxed{\begin{aligned}&M_k=\arg\min_{m:\ k\text{ features}}\mathrm{RSS}(m)\\&k=1,\dots,p\\&\text{choose among }M_0,M_1,\dots,M_p\\&\qquad\text{by cross-validation}\\&R^2=1-\frac{\mathrm{RSS}}{\mathrm{TSS}}\ \text{rises with }k\end{aligned}}$$

For every size, find the subset whose least squares fit leaves the smallest residual sum of squares. The $p+1$ winners cannot be compared by RSS or $R^2$, which only improve as the size grows, so cross-validation picks among them.

Why training fit cannot choose the size

Nested fits. Add one feature to $M_k$; setting its coefficient to $0$ reproduces the fit of $M_k$, so least squares on the larger set does at least as well.

So the winners only improve. $\mathrm{RSS}(M_{k+1})\le\mathrm{RSS}(M_k)$ and $R^2$ never falls: training fit always prefers $M_p$.

Within one size the comparison is fair. Models of the same size have the same number of coefficients, so their RSS values can be compared directly, as the lecture does.

Looks like this, but is not

The model with the largest $R^2$ looks like the best model: $M_3$ has $R^2=0.984$, more than any other fit.

$R^2$ can only rise as features are added. The leave-one-out error, which predicts each run from a fit that never saw it, is $1.53$ for $M_3$ against $0.93$ for $M_2$: the third feature fits noise.

runx₁ (kW)x₂ (kW)x₃ (kW)y (kWh)

1

2

3

4

10

2

3

4

5

14

3

3

6

11

18

4

1

3

5

7

5

3

3

7

13

6

0

5

3

10

7

2

4

5

12

8

2

2

2

8

The clamp meter reads the total $x_1+x_2$ with an error of 1 or 2 kW, and $y$ stays within 1 kWh of $2(x_1+x_2)$: two hours at the total load.

Best subset selection for the workshop's three meters

Eight two-hour runs of a workshop record the energy $y$ (kWh), the loads $x_1$ and $x_2$ of two presses (kW), and a clamp meter reading $x_3$ of the total load (kW). The RSS of all eight least squares fits, each with an intercept, are listed. Find $M_1$, $M_2$, $M_3$ and the number of fits.

Find$M_1$, $M_2$, $M_3$ and the number of fits.
Given
  • eight two-hour runs: $x_1$, $x_2$ loads of two presses (kW), $x_3$ a clamp meter reading of the total load (kW), $y$ energy used (kWh)

  • $\mathrm{RSS}$: none $88$; $\{x_1\}$ $47.50$; $\{x_2\}$ $42.00$; $\{x_3\}$ $27.27$

  • $\{x_1,x_2\}$ $1.50$; $\{x_1,x_3\}$ $22.15$; $\{x_2,x_3\}$ $21.27$; $\{x_1,x_2,x_3\}$ $1.43$

Solution

Within one size, RSS is a fair judge, so each $M_k$ is a minimum over one group of the list.

Size 1

$$M_1=\{x_3\}:\quad 27.27<42.00<47.50$$

The clamp meter sees the total load, so alone it predicts best.

Size 2

$$M_2=\{x_1,x_2\}:\quad 1.50<21.27<22.15$$

The two exact loads together beat any pair that includes the rough meter.

Size 3 and the count

$$M_3=\{x_1,x_2,x_3\}:\ 1.43;\qquad 2^3=8\ \text{fits}$$

Only one model has all three features; the count includes $M_0$.

Answer $$\boxed{\begin{aligned}&M_1=\{x_3\},\quad M_2=\{x_1,x_2\}\\&M_3=\{x_1,x_2,x_3\};\quad 8\ \text{fits}\end{aligned}}$$
Check

$R^2=1-\mathrm{RSS}/88$ gives $0.690$, $0.983$ and $0.984$ for $M_1$, $M_2$, $M_3$: rising with $k$, as the nesting argument says.

The best single feature need not belong to the best pair: $x_3$ wins alone and is absent from $M_2$.

Choosing the size by leave-one-out error

For the workshop data the leave-one-out errors $\mathrm{CV}(n)$ of the four winners are listed, with the least squares fit of $M_2$. Choose the model and predict the energy of a run with $x_1=2$ and $x_2=4$ kW.

FindThe chosen model and its prediction.
Given
  • $\mathrm{CV}(n)$: $M_0$ $14.37$, $M_1$ $4.74$, $M_2$ $0.93$, $M_3$ $1.53$

  • training RSS of the same models: $88$, $27.27$, $1.50$, $1.43$

  • $M_2$ fitted on all eight runs: $\hat y=-0.5+2.25x_1+2x_2$

Solution

Cross-validation compares models of different sizes on runs they were not fitted to, which RSS cannot do.

Compare the sizes

$$\min(14.37,\ 4.74,\ 0.93,\ 1.53)=0.93\ \Rightarrow\ M_2$$

The smallest estimated test error; training RSS would have picked $M_3$.

Refit and predict

$$\hat y=-0.5+2.25\cdot2+2\cdot4=12.0\ \text{kWh}$$

The chosen subset is refitted on all eight runs, and these are its coefficients.

Answer $$\boxed{\begin{aligned}&M_2=\{x_1,x_2\}\\&\hat y=12.0\ \text{kWh}\end{aligned}}$$
Check

Physical check: two hours at a total load of $2+4=6$ kW is $12$ kWh, and the coefficients $2.25$ and $2$ are close to the two hours in $y\approx2(x_1+x_2)$.

Choose the size by cross-validation, then refit the chosen subset on all the data.

Checkpoint
§11.6 — picking a size from two error lists

Best subset selection on $p=4$ features gives two lists for the winners $M_0$ to $M_4$.

Find(a) Which model should be chosen?
Given
  • training RSS of $M_0,\dots,M_4$: $120,\ \allowbreak 60,\ \allowbreak 35,\ \allowbreak 33,\ \allowbreak 32.5$

  • 5-fold CV error: $15.8,\ \allowbreak 8.1,\ \allowbreak 5.2,\ \allowbreak 5.6,\ \allowbreak 6.3$

Hint 1/4

Two lists are given; decide which one can compare models of different sizes.

Hint 2/4

Choose $\arg\min_k\mathrm{CV}(M_k)$; training RSS always favours the largest model.

Hint 3/4

Here the CV errors are $15.8,\ \allowbreak 8.1,\ \allowbreak 5.2,\ \allowbreak 5.6,\ \allowbreak 6.3$ for $M_0$ to $M_4$.

Hint 4/4

The smallest is $5.2$, at $M_2$.

Show solution

Only the CV list compares sizes fairly, so the RSS list is set aside.

Smallest CV error

$$\min(15.8,\ 8.1,\ 5.2,\ 5.6,\ 6.3)=5.2\ \Rightarrow\ M_2$$

The estimated test error is lowest with two features.

Answer $$\boxed{M_2}$$
Check

The RSS list falls at every step, $120>60>35>33>32.5$, exactly as nesting forces; it could only ever point at $M_4$.

A list that can only fall cannot pick a size.

⚠ Choosing the size by training RSS or R squared

A smaller error on the training data looks like a better model.

wrong$$\min_k\mathrm{RSS}(M_k)=\mathrm{RSS}(M_p)\ \Rightarrow\ M_p$$
right$$\arg\min_k\mathrm{CV}(M_k)=M_2\ \text{(workshop data)}$$
⚠ Leaving out the null model

A model with no features does not look like a candidate, yet sometimes no feature helps.

wrong$$\text{choose among }M_1,\dots,M_p$$
right$$\text{choose among }M_0,M_1,\dots,M_p$$

11.7Forward stepwise selection

Adds the feature with the largest RSS drop at each step: far fewer fits than $2^p$, but it can miss the best subset.

Best subset needs $2^p$ fits; forward stepwise applies the incremental search idea with RSS as the score.

MethodMethod 11.7: Forward stepwise selection
Conditions
  • $S_0=\emptyset$, and $M_0$ is the null model

  • each step adds one feature and never removes one

  • the size is again chosen by cross-validation

$$\boxed{\begin{aligned}&X^*=\arg\min_{X\notin S_k}\mathrm{RSS}(S_k\cup\{X\})\\&S_{k+1}=S_k\cup\{X^*\}\\&k=0,\dots,p-1\\&\text{size: }M_0,\dots,M_p\text{ by CV}\\&\text{fits: }1+\sum_{k=0}^{p-1}(p-k)\\&\qquad=1+\frac{p(p+1)}2\end{aligned}}$$

Start from the mean. At each step try adding every unused feature, keep the one that lowers RSS the most, and never go back. After $p$ steps there is one model per size, and cross-validation picks the size.

Counting the fits

Step $k$. With $k$ features in, $p-k$ candidates remain, and each is one least squares fit.

Sum. $p+(p-1)+\dots+1=\frac{p(p+1)}2$, plus the null model.

Compare. For $p=20$ that is $211$ fits against $2^{20}=1{,}048{,}576$.

Looks like this, but is not

Each forward step is the best step available, so the forward model of size 2 looks like the best model of size 2.

Forward commits to $x_3$ first. The best pair containing $x_3$ has RSS $21.27$, while $\{x_1,x_2\}$, which forward can no longer reach at size 2, has $1.50$.

Forward stepwise on the workshop data, and what cross-validation then picks

Run forward stepwise selection on the workshop data using the RSS list, then choose the size with the leave-one-out errors of the forward models.

FindThe forward path, the number of fits, and the chosen model.
Given
  • $\mathrm{RSS}$: $\{x_1\}$ $47.50$, $\{x_2\}$ $42.00$, $\{x_3\}$ $27.27$; $\{x_1,x_3\}$ $22.15$, $\{x_2,x_3\}$ $21.27$; $\{x_1,x_2,x_3\}$ $1.43$

  • $\mathrm{CV}(n)$ of the forward models: $M_0$ $14.37$, $\{x_3\}$ $4.74$, $\{x_2,x_3\}$ $5.39$, $\{x_1,x_2,x_3\}$ $1.53$

Solution

Forward stepwise needs only the RSS of the models on its path and of their one-feature extensions, which is exactly what the list gives.

Step 1: the best single feature

$$\{x_3\}:\quad 27.27<42.00<47.50$$

All single features are tried, so this is $M_1$ of best subset too.

Step 2: only pairs containing $x_3$

$$\{x_2,x_3\}:\quad 21.27<22.15$$

Only pairs containing $x_3$ are tried, so $\{x_1,x_2\}$ never is.

Step 3: the last feature

$$\{x_1,x_2,x_3\}:\quad 1.43$$

One feature is left, and adding it is the only move.

Count and choose

$$\begin{aligned}&1+3+2+1=7\ \text{fits}\\&\min(14.37,\ 4.74,\ 5.39,\ 1.53)\\&\quad=1.53\end{aligned}$$

$1+p(p+1)/2$ with $p=3$; cross-validation then picks the full model.

Answer $$\boxed{\begin{aligned}&\emptyset\to\{x_3\}\to\{x_2,x_3\}\\&\to\{x_1,x_2,x_3\};\ \ 7\ \text{fits}\\&\text{chosen: }\{x_1,x_2,x_3\}\end{aligned}}$$
Check

Best subset reached $\{x_1,x_2\}$ with leave-one-out error $0.93$; forward ends at $1.53$, higher, because its size-2 model is the wrong pair.

Forward stepwise is cheap because it never revisits a choice, and that is also why it can end with a worse model.

Fits needed for twenty features, and for 9703

A lab has $p=20$ candidate features. How many least squares fits do best subset and forward stepwise need? Repeat for the lecture's gene data, $p=9703$.

Find$2^p$ and $1+\frac{p(p+1)}2$ in both cases.
Given
  • $p=20$

  • $p=9703$

Solution

Both counts are closed forms; no model is fitted.

Twenty features

$$\begin{aligned}&2^{20}=1{,}048{,}576\\&1+\tfrac{20\cdot21}2=211\end{aligned}$$

Every subset once, against one pass per size.

The gene data

$$\log_{10}2^{9703}=9703\cdot0.30103=2920.9\ \Rightarrow\ 2^{9703}\approx7.8\times10^{2920}$$

Too large to write out, so we count its digits with a logarithm.

$$1+\tfrac{9703\cdot9704}2=47{,}078{,}957$$

The forward count is a quadratic in $p$.

Answer $$\boxed{\begin{aligned}&p=20:\ 1{,}048{,}576\text{ against }211\\&p=9703:\ 7.8\times10^{2920}\\&\qquad\text{against }47{,}078{,}957\end{aligned}}$$
Check

For $p=3$ the formulas give $8$ and $7$, the counts found by hand on the workshop data.

Past a few dozen features best subset is out of reach, and even forward stepwise is heavy at 9703; that is where the cheap mRMR screen earns its place.

Checkpoint
§11.7 — counting forward stepwise fits

Forward stepwise selection is run on $p=5$ candidate features.

Find(a) How many least squares fits does it make?
Given
  • $p=5$

  • the null model counts as one fit

Hint 1/4

Count the candidates tried at each step, then add the null model.

Hint 2/4

$1+\sum_{k=0}^{p-1}(p-k)=1+\frac{p(p+1)}2$.

Hint 3/4

Here $p=5$: $1+(5+4+3+2+1)$.

Hint 4/4

$16$ fits.

Show solution

Summing the candidates step by step makes the formula visible.

Step by step

$$1+(5+4+3+2+1)=1+15=16$$

The null model, then $5-k$ candidates at step $k$.

Against best subset

$$2^5=32$$

Every subset once.

Answer $$\boxed{16\ \text{fits}}$$
Check

The formula $1+\frac{p(p+1)}2=1+\frac{5\cdot6}2=16$ agrees.

For small $p$ the saving is modest; it grows fast with $p$.

⚠ Assuming the forward path holds the best model of each size

Every step is locally best, which sounds like globally best.

wrong$$M_2^{\mathrm{fwd}}=\{x_2,x_3\}=M_2$$
right$$\mathrm{RSS}(\{x_2,x_3\})=21.27>\mathrm{RSS}(\{x_1,x_2\})=1.50$$
⚠ Forgetting the null model in the count

The sum over steps is the visible part of the formula.

wrong$$\text{fits}=\tfrac{p(p+1)}2=15\quad(p=5)$$
right$$\text{fits}=1+\tfrac{p(p+1)}2=16\quad(p=5)$$
Mutual information from a table of counts

A question gives counts of a feature against a label and asks for $I(X;Y)$ in bits.

  1. Probabilities

    Divide every count by $n$; row and column sums give $p(x)$ and $p(y)$.

  2. Ratios

    For each cell with a nonzero count, $\frac{p(x,y)}{p(x)p(y)}=\frac{n\,n_{xy}}{n_x\,n_y}$.

  3. Sum

    Add $p(x,y)\log_2(\text{ratio})$ over those cells.

  4. Check

    Recompute as $H(Y)-\sum_xp(x)H(Y\mid X=x)$; pure groups give $0$, even splits $1$ bit.

Where it goes wrong
  • Natural logarithms in a table of bits: divide by $\ln2=0.693$.

  • Averaging $H(Y\mid X=x)$ without the weights $p(x)$.

  • Writing $\log0$ for an empty cell instead of dropping it.

mRMR by hand

Tables of relevance and pairwise mutual information are given, and $k$ features are asked for.

  1. Start

    Take the feature with the largest $I(X;Y)$.

  2. Penalty

    For each remaining candidate, average its $I(X;X')$ over the $l-1$ chosen features.

  3. Score

    Relevance minus penalty; add the largest.

  4. Repeat

    Until $k$ features are in; check each winner's margin over the runner-up.

Where it goes wrong
  • Summing the redundancies instead of averaging them.

  • Dividing by $l$ instead of $l-1$.

  • Letting an already chosen feature compete again.

Best subset or forward stepwise, then cross-validation

A question gives the RSS of candidate models and their cross-validation errors, and asks for the selected model.

  1. Winners by size

    Within each size, the smallest RSS; forward stepwise only looks at extensions of its current set.

  2. Cross-validate

    Compare $M_0,\dots,M_p$ by CV error, never by RSS or $R^2$.

  3. Refit

    Refit the chosen subset on all the data and report its coefficients.

  4. Count

    Best subset needs $2^p$ fits, forward stepwise $1+p(p+1)/2$.

Where it goes wrong
  • Picking the size with the lowest training RSS.

  • Assuming the best pair contains the best single feature.

  • Dropping $M_0$ from the comparison.

Two copies: the pair tells less than the sum

Two thermometers show the same band on every wafer, each with $I(X;Y)=0.5$ bit.

Find$I(\{X_1,X_2\};Y)$ against the sum of the two relevances.
Given
  • $X_2=X_1$

  • $I(X_1;Y)=I(X_2;Y)=0.5$ bit

Solution

A copy forms the same groups, so the pair's leftover uncertainty is known at once.

The pair

$$I(\{X_1,X_2\};Y)=I(X_1;Y)=0.5$$

The same groups as $X_1$ alone.

The sum

$$0.5+0.5=1.0>0.5$$

The sum counts the shared half bit twice.

Answer $$\boxed{I(\{X_1,X_2\};Y)=0.5<1.0}$$
Check

The two thermometers share $I(X_1;X_2)=1.5$ bits, the whole of $H(X_1)$.

Overlap makes a pair worth less than its parts.

Two valves: the pair tells more than the sum

An alarm $Y$ fires only when valves $A$ and $B$ are both open; each valve is open half the time, independently of the other.

Find$I(A;Y)$, $I(B;Y)$ and $I(\{A,B\};Y)$.
Given
  • $Y=1$ exactly when $A=B=1$

  • $P(A=1)=P(B=1)=\tfrac12$, independent

Solution

Every conditional entropy is $0$ or $1$ bit, so the entropy route is short.

One valve

$$\begin{aligned}H(Y)&=-\tfrac14\log\tfrac14-\tfrac34\log\tfrac34\\&=0.811\end{aligned}$$

The alarm fires in one case out of four.

$$\begin{aligned}&H(Y\mid A)=\tfrac12\cdot0+\tfrac12\cdot1=0.5\\&I(A;Y)=I(B;Y)=0.311\end{aligned}$$

A closed valve settles $Y=0$; an open one leaves $B$ as a coin.

Both valves

$$I(\{A,B\};Y)=0.811>0.311+0.311=0.622$$

The two valves fix $Y$ completely.

Answer $$\boxed{I(\{A,B\};Y)=0.811>0.622}$$
Check

The valves share nothing, $I(A;B)=0$, since they open independently; the extra comes from working together.

Teamwork makes a pair worth more than its parts.

Relevances do not add: two copies tell less than the sum, two team-mates can tell more.

How to tell them apart

Compare the pair's joint information with the sum of the two relevances: below the sum means overlap, above it means the features work together.

Workshop data: the best pair leaves out the best single feature

The workshop's least squares RSS values for single features and pairs are listed.

FindThe size-2 model of best subset and of forward stepwise.
Given
  • singles: $\{x_1\}$ $47.50$, $\{x_2\}$ $42.00$, $\{x_3\}$ $27.27$

  • pairs: $\{x_1,x_2\}$ $1.50$, $\{x_1,x_3\}$ $22.15$, $\{x_2,x_3\}$ $21.27$

Solution

Both methods agree on the best single feature, so only the pairs need comparing.

Best single

$$\{x_3\}\ (27.27)$$

Both methods pick it at size 1.

Pairs

$$\begin{aligned}&\text{best subset: }\{x_1,x_2\}\ (1.50)\\&\text{forward: }\{x_2,x_3\}\ (21.27)\end{aligned}$$

Forward stepwise compares only the pairs that contain $x_3$.

Answer $$\boxed{\text{they differ at size 2}}$$
Check

$M_2=\{x_1,x_2\}$ does not contain $M_1=\{x_3\}$, which is exactly when a greedy path must miss.

A proxy that sums two exact features wins alone and loses in pairs.

Lab data: the best pair contains the best single feature

Ten batches of a second process give these least squares RSS values for single features and pairs.

FindThe size-2 model of best subset and of forward stepwise.
Given
  • singles: $\{x_1\}$ $16.099$, $\{x_2\}$ $616.000$, $\{x_3\}$ $535.752$

  • pairs: $\{x_1,x_2\}$ $15.440$, $\{x_1,x_3\}$ $16.097$, $\{x_2,x_3\}$ $505.750$

Solution

The same two comparisons as in A, on data where one feature dominates.

Best single

$$\{x_1\}\ (16.099)$$

Both methods pick it at size 1.

Pairs

$$\begin{aligned}&\text{best subset: }\{x_1,x_2\}\ (15.440)\\&\text{forward: }\{x_1,x_2\}\\&\quad(15.440<16.097)\end{aligned}$$

The best pair contains $x_1$, so forward stepwise sees it.

Answer $$\boxed{\text{they agree at size 2}}$$
Check

$M_2=\{x_1,x_2\}$ contains $M_1=\{x_1\}$; when every winner contains the one before, forward stepwise finds all of them.

Nested winners are what make the greedy path safe.

Forward stepwise matches best subset when each best model contains the one before it, and misses when it does not.

How to tell them apart

Check whether best subset's $M_{k+1}$ contains $M_k$; if every step nests, forward stepwise finds the same models with far fewer fits.

Scaffolding comes off
The common skeleton
  1. List the relevance $I(X_j;Y)$ of every candidate, computing in bits any value given only as counts.

  2. Take the most relevant feature as $X_1^*$.

  3. For each remaining candidate, average its mutual information with the features already chosen.

  4. Score = relevance minus that average; add the largest score.

  5. Repeat the last two steps until $k$ features are in.

1 · fully worked

mRMR by hand on five motor sensors

A maintenance team estimated from 40 motors the table below. $X_1$ and $X_2$ are two vibration sensors on the same bearing, $X_3$ and $X_4$ two temperature probes on the same housing, and $X_5$ an acoustic sensor. Select $k=3$ features by mRMR.

Find$S_3$, with the score of every candidate at every step.
Given
  • relevance (bit): $X_1\ 0.37$, $X_2\ 0.32$, $X_3\ 0.31$, $X_4\ 0.22$, $X_5\ 0.20$

  • $I(X_1;X_2)=0.83$, $I(X_3;X_4)=0.53$, $I(X_2;X_3)=0.11$, $I(X_1;X_3)=0.10$, $I(X_2;X_4)=0.10$

  • $I(X_2;X_5)=0.09$, $I(X_1;X_4)=0.08$, $I(X_1;X_5)=0.07$, $I(X_4;X_5)=0.07$, $I(X_3;X_5)=0.05$

Solution

The table holds every two-variable value mRMR needs, so no joint estimate is required.

Step 1: relevance only

$$X_1^*=X_1\ (0.37)$$

With nothing chosen yet, the score is relevance alone.

Step 2: one redundancy each

$$X_2:\ 0.32-0.83=-0.51,\qquad X_3:\ 0.31-0.10=0.21$$

$X_2$ sits on the same bearing as $X_1$ and repeats most of it.

$$X_4:\ 0.22-0.08=0.14,\qquad X_5:\ 0.20-0.07=0.13\ \Rightarrow\ X_3$$

$X_3$ has the largest net score.

Step 3: the average of two

$$\begin{aligned}&X_2:\ 0.32-\tfrac{0.83+0.11}2=-0.15\\&X_4:\ 0.22-\tfrac{0.08+0.53}2=-0.085\end{aligned}$$

$X_4$ now pays for its twin $X_3$.

$$\begin{aligned}&X_5:\ 0.20-\tfrac{0.07+0.05}2=0.14\\&S_3=\{X_1,X_3,X_5\}\end{aligned}$$

The acoustic sensor shares little with either chosen feature.

Answer $$\boxed{S_3=\{X_1,X_3,X_5\}}$$
Check

Joint values estimated from the motors: $I(\{X_1,X_3,X_5\};Y)=0.67$ bit against $0.60$ for the top three by relevance, $\{X_1,X_2,X_3\}$.

One feature from each near-copy pair plus the independent sensor: that is what mRMR is built to find.

2 · you write the reasoning

Easier, and this time you write the reasons. From 32 recordings: relevances $X_1\ 0.36$, $X_2\ 0.29$, $X_3\ 0.19$, $X_4\ 0.13$ bit; $I(X_1;X_2)=0.80$, $I(X_1;X_3)=0.07$, $I(X_1;X_4)=0.16$. Select $k=2$ by mRMR, and for each line write why it is allowed.

  1. $X_1^*=X_1\ (0.36)$

    reasoning

    With nothing chosen yet, the score is relevance alone, and $0.36$ is the largest.

  2. $X_2:\ 0.29-0.80=-0.51$

    reasoning

    At $l=2$ the average runs over one chosen feature, $X_1$, and $X_2$ repeats most of it.

  3. $X_3:\ 0.19-0.07=0.12$

    reasoning

    $X_3$ shares only $0.07$ bit with $X_1$, so it keeps most of its relevance.

  4. $X_4:\ 0.13-0.16=-0.03$

    reasoning

    $X_4$ shares more with $X_1$ than it tells about the label.

  5. $S_2=\{X_1,X_3\}$

    reasoning

    $0.12$ is the only positive score.

3 · find the buried error

Harder, with two errors buried in the solution. A student selects $k=3$ by mRMR from 40 recordings. Which two steps are wrong?

  • relevances: $X_2\ 0.23$, $X_3\ 0.59$, $X_4\ 0.00$, $X_5\ 0.41$ bit
  • $X_1$ only as counts: when $X_1=0$, 21 recordings have $Y=0$ and 3 have $Y=1$; when $X_1=1$, 4 have $Y=0$ and 12 have $Y=1$
  • pairwise: $I(X_3;X_5)=0.72$, $I(X_2;X_3)=0.18$, $I(X_1;X_3)=0.17$, $I(X_1;X_2)=I(X_2;X_5)=0.11$, $I(X_1;X_5)=0.10$, $I(X_2;X_4)=0.01$, and $0.00$ for $X_4$ with $X_1$, $X_3$ and $X_5$
  1. Step 1. From the counts, $I(X_1;Y)=0.525\ln1.4+0.075\ln\frac13+0.1\ln0.4+0.3\ln2=0.21$.

  2. Step 2. The largest relevance is $0.59$, so $X_3$ is chosen first.

  3. Step 3. With $X_3$ chosen: $X_1$ scores $0.21-0.17=0.04$, $X_2$ scores $0.23-0.18=0.05$, $X_4$ scores $0$, $X_5$ scores $0.41-0.72=-0.31$. $X_2$ joins.

  4. Step 4. With $X_3$ and $X_2$ chosen: $X_1$ scores $0.21-(0.17+0.11)=-0.07$, $X_4$ scores $0-(0+0.01)=-0.01$, $X_5$ scores $0.41-(0.72+0.11)=-0.42$. $X_4$ joins.

  5. Step 5. $S_3=\{X_3,X_2,X_4\}$.

the two buried errors (2)
⚠ step 1

The logarithms are natural, so $0.21$ is in nats while every other value in the table is in bits.

Calculators default to $\ln$, and a table with one value in nats still looks consistent.

right

In bits, $I(X_1;Y)=0.21/\ln2=0.30$; with it, Step 3 gives $X_1$ the score $0.30-0.17=0.13$, and $X_1$ joins instead of $X_2$.

⚠ step 4

At step $l=3$ the two redundancies are added, not averaged: each candidate should pay half of the sum.

The factor $\frac1{l-1}$ equals $1$ at step 2, so it is easy to forget that it matters at step 3.

right

With both errors fixed, $S_2=\{X_3,X_1\}$ and step 3 gives $X_2:\ 0.23-\frac{0.18+0.11}2=0.085$, $X_4:\ 0.00$, $X_5:\ 0.41-\frac{0.72+0.10}2=0.00$, so $S_3=\{X_3,X_1,X_2\}$.

4 · the bare problem
§11.5 — mRMR on five wind turbine features

From 40 wind turbines, five features were scored against a gearbox fault label, and their pairwise mutual informations were estimated.

Find
  1. (a) Select $k=3$ features by mRMR.

  2. (b) Which three would maximum relevance keep?

Given
  • relevance (bit): $X_1\ 0.46$, $X_2\ 0.02$, $X_3\ 0.22$, $X_4\ 0.30$, $X_5\ 0.23$

  • $I(X_1;X_4)=0.48$, $I(X_3;X_5)=0.11$, $I(X_4;X_5)=0.10$, $I(X_1;X_5)=I(X_2;X_5)=0.07$

  • $I(X_3;X_4)=0.06$, $I(X_1;X_3)=I(X_2;X_3)=0.03$, $I(X_2;X_4)=0.02$, $I(X_1;X_2)=0.00$

Hint 1/4

Start from relevance alone, then charge each candidate for what it shares with the features already in.

Hint 2/4

Score $=I(X;Y)-\frac1{l-1}\sum_{X'\in S_{l-1}}I(X;X')$.

Hint 3/4

Here $X_1$ comes first ($0.46$); its overlaps are $0.00$, $0.03$, $0.48$ and $0.07$ with $X_2$, $X_3$, $X_4$ and $X_5$.

Hint 4/4

$S_3=\{X_1,X_3,X_5\}$; maximum relevance keeps $\{X_1,X_4,X_5\}$.

Show solution

All inputs are two-variable values from the table, so each step is a list of subtractions.

Step 1: the most relevant feature

$$X_1^*=X_1\ (0.46)$$

The largest relevance.

Step 2: one overlap each

$$X_2:\ 0.02-0=0.02,\ \ X_3:\ 0.22-0.03=0.19,\ \ X_4:\ 0.30-0.48=-0.18,\ \ X_5:\ 0.23-0.07=0.16$$

Overlaps with $X_1$ only; $X_4$ repeats most of $X_1$.

$$X_2^*=X_3$$

$0.19$ beats $0.16$.

Step 3: the average of two overlaps

$$\begin{aligned}&X_2:\ 0.02-\tfrac{0+0.03}2=0.005\\&X_4:\ 0.30-\tfrac{0.48+0.06}2=0.03\\&X_5:\ 0.23-\tfrac{0.07+0.11}2=0.14\end{aligned}$$

Averages over $X_1$ and $X_3$.

$$S_3=\{X_1,X_3,X_5\}$$

$0.14$ is the largest score.

Maximum relevance

$$\{X_1,X_4,X_5\}:\ 0.46,\ 0.30,\ 0.23$$

The three largest relevances, echo of $X_1$ included.

Answer $$\boxed{\begin{aligned}&S_3=\{X_1,X_3,X_5\}\\&\text{by relevance: }\{X_1,X_4,X_5\}\end{aligned}}$$
Check

Joint values estimated from the turbines: $I(\{X_1,X_3,X_5\};Y)=0.83$ bit against $0.70$ for $\{X_1,X_4,X_5\}$, where $X_4$ repeats $0.48$ bit of $X_1$.

The second most relevant feature is often the first one's echo; check its overlap before keeping it.

Full exam-style question

Three signals for transformer overheating: relevance, redundancy and the pair to keepexam format

A utility logged 32 overload events on distribution transformers. For each it recorded the load level $A$ (low, medium or high), an older meter's flag $B$ ($1$ when the load is not low), and whether the cooling fan had failed, $C$. $Y=1$ if the transformer overheated.

  • Low load: 8 events, fan failed in 4, none overheated.
  • Medium load: 16 events, fan failed in 8; overheated exactly when the fan failed.
  • High load: 8 events, fan failed in 4, all overheated.
  • (a) Compute $I(A;Y)$, $I(B;Y)$ and $I(C;Y)$ in bits.
  • (b) Which two signals does maximum relevance keep, and what is their joint information with $Y$?
  • (c) Compute $I(A;B)$ and $I(A;C)$, and run mRMR with $k=2$.
  • (d) Which pair maximizes $I(S;Y)$?
  • (e) With $p=120$ binary signals and $k=4$, how many joint estimates would exhaustive and incremental search need, and why would either be doubtful with 32 events?
FindThree relevances; maximum relevance's pair and its value; $I(A;B)$, $I(A;C)$ and mRMR's pair; the best pair; two counts and a verdict.
Given
  • low load: 8 events, fan failed in 4, none overheated

  • medium load: 16 events, fan failed in 8, overheated exactly when the fan failed

  • high load: 8 events, fan failed in 4, all overheated

  • $B=1$ exactly when the load is medium or high

Solution

Every group is pure, evenly split, or split $1:2$ or $1:3$, so the entropy route with $H(Y)=1$ bit handles every part and needs only two logarithm values, $0.918$ and $0.811$.

(a) Three relevances

$$\begin{aligned}&H(Y)=1\\&H(Y\mid A)=\tfrac{16}{32}\cdot1=0.5\\&I(A;Y)=0.5\end{aligned}$$

16 of 32 overheated; only the medium group is mixed, $8:8$.

$$\begin{aligned}&H(Y\mid B)=\tfrac{24}{32}\cdot0.918=0.689\\&I(B;Y)=0.311\end{aligned}$$

$B=0$ holds 8 events, none overheated; $B=1$ holds 24, with 16 overheated, a $1:2$ split of entropy $0.918$.

$$H(Y\mid C)=0.811\ \Rightarrow\ I(C;Y)=0.189$$

With a working fan 4 of 16 overheated, with a failed fan 12 of 16: two $3:1$ splits.

(b) Maximum relevance

$$\text{keep }A\ (0.5)\text{ and }B\ (0.311):\quad I(\{A,B\};Y)=I(A;Y)=0.5$$

$B$ is a function of $A$, so the pair forms the groups of $A$.

(c) Redundancy and mRMR

$$I(A;B)=H(B)-H(B\mid A)=0.811-0=0.811,\qquad I(A;C)=0$$

$A$ fixes $B$, which splits $8:24$; the fan failed in half of every load group.

$$\text{step 2: }B:\ 0.311-0.811=-0.5,\quad C:\ 0.189-0=0.189\ \Rightarrow\ \{A,C\}$$

$A$ comes first, and $C$ repeats nothing of it.

(d) The best pair

$$I(\{A,B\};Y)=0.5,\quad I(\{A,C\};Y)=1,\quad I(\{B,C\};Y)=0.656$$

Load and fan together fix $Y$; $\{B,C\}$ leaves the 12 events with $B=1$ and a working fan split $1:2$.

(e) Counts and caution

$$\begin{aligned}&\binom{120}4=8{,}214{,}570\\&120+119+118+117=474\end{aligned}$$

Exhaustive against incremental search.

$$\text{four binary signals and }Y:\ 2^5=32\ \text{cells for }32\ \text{events}$$

About one event per cell, so the joint estimates drift toward $H(Y)$ whatever the signals are.

Answer $$\boxed{\begin{aligned}&\text{(a) }0.5,\ 0.311,\ 0.189\\&\text{(b) }\{A,B\},\ 0.5\ \text{bit}\\&\text{(c) }0.811,\ 0;\ \{A,C\}\\&\text{(d) }\{A,C\},\ 1\ \text{bit}\\&\text{(e) }8{,}214{,}570\text{ against }474\end{aligned}}$$
Check

The pair $\{A,C\}$ predicts every event: low load never overheats, high load always does, and medium load overheats exactly when the fan failed. A perfect rule means $H(Y\mid A,C)=0$ and $I=H(Y)=1$ bit.

Score the pair, not the signals one by one: the coarse copy $B$ looked second best and added nothing.

Practice

A · concept 4 questions
1§11.1 — zero correlation and usefulness

A correlation screen reports $\hat R_j=0$ for one feature, and a teammate proposes to drop it because it can carry no information about $y$.

Find(a) True or false: if $\hat R_j=0$, feature $j$ carries no information about $y$.
Given$\hat R_j=0$ on the training data
Hint 1/4

Ask what kind of relation a correlation can detect.

Hint 2/4

$\hat R_j$ measures the straight-line trend; information is any dependence.

Hint 3/4

Here try $x=-1, \allowbreak -1, \allowbreak 0, \allowbreak 0, \allowbreak 1, \allowbreak 1$ with $y=x^2$: the cross-product $\sum_ix_i(y_i-\bar y)=\sum_ix_i^3$ is $0$.

Hint 4/4

So $\hat R=0$ while $x$ determines $y$: the statement is false.

Show solution

One counterexample settles a claim about every feature.

Correlation

$$S_{xy}=\sum_ix_i^3=0\ \Rightarrow\ \hat R=0$$

$\bar x=0$ and the cubes cancel in pairs.

Information

$$H(Y\mid X)=0\ \Rightarrow\ I(X;Y)=H(Y)=0.918$$

Each $x$ gives a single $y$.

Answer $$\boxed{\text{False}}$$
Check

A straight-line fit of $y$ on $x$ has slope $0$ and explains none of the spread, while a fit of $y$ on $x^2$ explains all of it.

Before dropping a zero-correlation feature, ask whether the relation could be curved.

2§11.2 — can mutual information be negative?

A feature $X$ is $1$ exactly when a binary label $Y$ is $0$: it moves opposite to the label, and its correlation with $Y$ is $-1$.

Find(a) True or false: $I(X;Y)$ is negative for such a feature.
Given
  • $X=1-Y$ on every sample

  • $Y$ is a fair bit

Hint 1/4

Ask what mutual information measures: a direction or an amount.

Hint 2/4

$I(X;Y)=H(Y)-H(Y\mid X)\ge0$.

Hint 3/4

Here $Y$ is a fair bit, so $H(Y)=1$, and $X=1-Y$ settles $Y$, so $H(Y\mid X)=0$.

Hint 4/4

$I(X;Y)=1$ bit, the largest possible value: false.

Show solution

The entropy route needs two facts: $H(Y)$, and whether $X$ settles $Y$.

Before and after

$$H(Y)=1,\qquad H(Y\mid X)=0$$

Knowing $X$ gives $Y=1-X$.

Difference

$$I(X;Y)=1-0=1\ \text{bit}$$

The uncertainty removed.

Answer $$\boxed{\text{False: }I(X;Y)=1\ \text{bit}}$$
Check

Definition route: the two nonzero cells $(1,0)$ and $(0,1)$ each give $\frac12\log\frac{1/2}{1/4}=\frac12$.

Correlation has a sign; mutual information does not, because it measures how much, not which way.

3§11.3 — when the top two by relevance make a poor pair

Maximum relevance keeps the two features with the largest $I(X_j;Y)$. The pair it keeps can still be a poor choice.

Find(a) In which situation is the kept pair poor?
Given$k=2$, score $s_j=I(X_j;Y)$
Hint 1/4

Ask what the second feature adds once the first one is known.

Hint 2/4

$I(\{X_1,X_2\};Y)=I(X_1;Y)$ when $X_2$ is a function of $X_1$.

Hint 3/4

Here the pair is the top two by relevance; if $X_2$ is close to a copy of $X_1$, the pair tells about as much as $X_1$ alone.

Hint 4/4

The pair is poor when the two features are near copies.

Show solution

Each option is tested against the question the score answers: one feature at a time.

What the score sees

$$\begin{aligned}&s_j=I(X_j;Y)\\&\text{one feature at a time}\end{aligned}$$

Overlap between features never enters it.

When the overlap is total

$$X_2=g(X_1):\quad I(\{X_1,X_2\};Y)=I(X_1;Y)$$

The second feature adds nothing.

Answer $$\boxed{\text{near copies}}$$
Check

The wafer data: the two thermometers score $0.5$ bit each, and together they still give $0.5$ bit.

High relevance and low overlap are two separate requirements; mRMR asks for both.

4§11.7 — does forward stepwise find the best pair?

A classmate says that forward stepwise and best subset selection always give the same model of size 2, since both pick the smallest RSS.

Find(a) True or false: forward stepwise always finds the same size-2 model as best subset selection.
Given
  • least squares with an intercept

  • any data set with $p\ge3$ features

Hint 1/4

Ask which pairs each method actually compares.

Hint 2/4

Best subset compares all $\binom p2$ pairs; forward stepwise only the $p-1$ pairs that contain its first pick.

Hint 3/4

Here, on the workshop data, the best single is $\{x_3\}$ ($27.27$), and the pairs have RSS $\{x_1,x_2\}$ $1.50$, $\{x_2,x_3\}$ $21.27$, $\{x_1,x_3\}$ $22.15$.

Hint 4/4

Forward reaches $\{x_2,x_3\}$, not $\{x_1,x_2\}$: false.

Show solution

One data set where the two differ refutes "always".

Forward stepwise

$$\{x_3\}\ \to\ \{x_2,x_3\}\quad(21.27<22.15)$$

Only pairs containing $x_3$ are compared.

Best subset

$$\{x_1,x_2\}:\ 1.50$$

All three pairs are compared.

Answer $$\boxed{\text{False}}$$
Check

The two agree whenever the best pair contains the best single feature; here $x_3$ is not in $\{x_1,x_2\}$, so they cannot agree.

A greedy path is fast and often good, but "always" is exactly what it cannot promise.

B · computation 7 questions
1§11.1 — correlation scores from five raw days

Two candidate features were logged with an output $y$ on five days. Only one feature can be kept.

Find
  1. (a) Compute $\hat R_1$ and $\hat R_2$.

  2. (b) Which feature does the correlation score keep for $k=1$?

Given
  • $x_1=(5,4,3,2,1)$

  • $x_2=(2,2,3,4,4)$

  • $y=(1,3,2,5,4)$

Hint 1/4

Each correlation needs three centered sums; each score then needs one square.

Hint 2/4

$\hat R_j=S_{jy}/\sqrt{S_{jj}S_{yy}}$ and $s_j=\hat R_j^2$.

Hint 3/4

Here $\bar x_1=\bar x_2=\bar y=3$, with deviations $x_1:(2, \allowbreak 1, \allowbreak 0, \allowbreak -1, \allowbreak -2)$, $x_2:(-1, \allowbreak -1, \allowbreak 0, \allowbreak 1, \allowbreak 1)$ and $y:(-2, \allowbreak 0, \allowbreak -1, \allowbreak 2, \allowbreak 1)$.

Hint 4/4

$\hat R_1=-0.8$ and $\hat R_2=0.791$; the scores $0.64>0.625$ keep $x_1$.

Show solution

All three means are $3$, so centering first keeps every product a small integer.

Deviations

$$x_1-3=(2,1,0,-1,-2),\quad x_2-3=(-1,-1,0,1,1),\quad y-3=(-2,0,-1,2,1)$$

Each column minus its mean.

Sums

$$S_{1y}=-4+0+0-2-2=-8,\qquad S_{11}=10$$

Products of paired deviations, then squares.

$$S_{2y}=2+0+0+2+1=5,\qquad S_{22}=4,\qquad S_{yy}=10$$

The same for the second feature and for the output.

Correlations and scores

$$\begin{aligned}&\hat R_1=\frac{-8}{\sqrt{10\cdot10}}=-0.8\\&\hat R_2=\frac{5}{\sqrt{4\cdot10}}=0.791\end{aligned}$$

Each cross-sum over the square root of its two spreads.

$$s_1=0.64>s_2=0.625\ \Rightarrow\ \text{keep }x_1$$

The score ignores the sign, and $x_1$ wins narrowly.

Answer $$\boxed{\begin{aligned}&\hat R_1=-0.8,\quad \hat R_2=0.791\\&\text{keep }x_1\end{aligned}}$$
Check

One-feature fits agree: $\mathrm{RSS}_1=10-64/10=3.6$ and $\mathrm{RSS}_2=10-25/4=3.75$, so $x_1$ leaves less unexplained.

A close call between a negative and a positive correlation is decided by the squares alone.

2§11.2 — mutual information of a three-level feature

A battery lab tested 24 cells. Each was stored cool, warm or hot, and $Y=1$ if it failed the capacity test.

Find
  1. (a) Compute $H(Y)$ and $H(Y\mid X)$.

  2. (b) Compute $I(X;Y)$ in bits.

Given
  • cool: 8 cells, 2 failed

  • warm: 8 cells, 4 failed

  • hot: 8 cells, 6 failed

Hint 1/4

The information is the uncertainty about failure before storage is known, minus the average uncertainty after.

Hint 2/4

$I(X;Y)=H(Y)-\sum_xp(x)H(Y\mid X=x)$, where a split $q:(1-q)$ has $H=-q\log q-(1-q)\log(1-q)$.

Hint 3/4

Here 12 of the 24 cells failed; the groups split $2:6$, $4:4$ and $6:2$, each holding 8 cells.

Hint 4/4

$H(Y)=1$, $H(Y\mid X)=0.874$ and $I(X;Y)=0.126$ bit.

Show solution

Two of the three groups have the same $3:1$ split, so the route needs one logarithm value, $0.811$.

Before

$$H(Y)=1\ \text{bit}$$

12 of 24 failed: an even split.

After, group by group

$$\begin{aligned}&H(Y\mid\text{cool})=H(Y\mid\text{hot})\\&\quad=-\tfrac14\log\tfrac14-\tfrac34\log\tfrac34=0.811\end{aligned}$$

$2:6$ and $6:2$ are both $3:1$ splits.

$$\begin{aligned}&H(Y\mid\text{warm})=1\\&H(Y\mid X)=\tfrac8{24}(0.811+1+0.811)\\&\qquad=0.874\end{aligned}$$

$4:4$ is even; each group weighs $\frac8{24}$.

Difference

$$I(X;Y)=1-0.874=0.126\ \text{bit}$$

The uncertainty that knowing the storage removes.

Answer $$\boxed{\begin{aligned}&H(Y)=1\\&H(Y\mid X)=0.874\\&I(X;Y)=0.126\ \text{bit}\end{aligned}}$$
Check

Definition route: the cell ratios are $\frac12$, $1$ and $\frac32$ with their mirror images, and $2\cdot\frac2{24}\log\frac12+2\cdot\frac6{24}\log\frac32=-0.167+0.292=0.126$.

A feature whose groups are only mildly tilted carries little information, however steady the tilt.

3§11.2 — the two entropy routes give the same number

A traffic camera labels vehicles as car, van or truck, with probabilities $\tfrac12$, $\tfrac14$ and $\tfrac14$. A length sensor gives $X=1$ for every van and truck and $X=0$ for every car.

Find
  1. (a) Compute $H(Y)$ and $H(Y\mid X)$, and from them $I(X;Y)$.

  2. (b) Compute $H(X)$ and $H(X\mid Y)$, and check that they give the same $I(X;Y)$.

Given
  • $P(\text{car})=\tfrac12$, $P(\text{van})=P(\text{truck})=\tfrac14$

  • $X=0$ for cars, $X=1$ for vans and trucks

Hint 1/4

Mutual information can be computed from either side; each side needs one entropy and one conditional entropy.

Hint 2/4

$I(X;Y)=H(Y)-H(Y\mid X)=H(X)-H(X\mid Y)$.

Hint 3/4

Here $Y$ has probabilities $\frac12$, $\frac14$, $\frac14$; given $X=1$, van and truck are equally likely; and the vehicle type fixes $X$.

Hint 4/4

$1.5-0.5=1$ and $1-0=1$: $I(X;Y)=1$ bit.

Show solution

Every probability is a power of $\frac12$, so each logarithm is a whole number of bits.

From the label's side

$$H(Y)=\tfrac12\cdot1+\tfrac14\cdot2+\tfrac14\cdot2=1.5$$

$-\log\frac12=1$ and $-\log\frac14=2$.

$$\begin{aligned}&H(Y\mid X)=\tfrac12\cdot0+\tfrac12\cdot1=0.5\\&I=1.5-0.5=1\end{aligned}$$

A car is certain when $X=0$; van or truck is a fair bit when $X=1$.

From the feature's side

$$H(X)=1,\qquad H(X\mid Y)=0\ \Rightarrow\ I=1-0=1$$

$X$ is a fair bit, and the vehicle type fixes $X$.

Answer $$\boxed{\begin{aligned}I(X;Y)&=1.5-0.5\\&=1-0=1\ \text{bit}\end{aligned}}$$
Check

$I(X;Y)\le\min(H(X),H(Y))=1$, and the bound is reached because $X$ is a function of $Y$.

Pick the side whose conditional entropy is easiest; here $H(X\mid Y)=0$ made the second route one line.

4§11.4 — incremental search from a table of joint values

From 32 recordings, joint mutual informations with the label were estimated for the sets incremental search visits and for every triple.

Find
  1. (a) Run incremental search with $k=3$.

  2. (b) Which three features would maximum relevance keep, and what is their joint value?

  3. (c) Count the evaluations of incremental search and of exhaustive search.

Given
  • singles (bit): $X_1\ 0.46$, $X_2\ 0.28$, $X_3\ 0.03$, $X_4\ 0.13$

  • pairs with $X_1$: $\{X_1,X_2\}\ 0.55$, $\{X_1,X_3\}\ 0.51$, $\{X_1,X_4\}\ 0.62$

  • triples: $\{X_1,X_3,X_4\}\ 0.71$, $\{X_1,X_2,X_4\}\ 0.62$, $\{X_1,X_2,X_3\}\ 0.60$, $\{X_2,X_3,X_4\}\ 0.37$

Hint 1/4

Incremental search always scores the current set plus one candidate; start from the empty set.

Hint 2/4

$X_l^*=\arg\max_{X\notin S_{l-1}}I(S_{l-1}\cup\{X\};Y)$, with $p+(p-1)+\dots+(p-k+1)$ evaluations.

Hint 3/4

Here the singles are $0.46$, $0.28$, $0.03$, $0.13$; the pairs with $X_1$ give $0.55$, $0.51$, $0.62$ for $X_2$, $X_3$, $X_4$; the triples with $\{X_1,X_4\}$ give $0.71$ with $X_3$ and $0.62$ with $X_2$.

Hint 4/4

$S_3=\{X_1,X_3,X_4\}$ with $0.71$; maximum relevance keeps $\{X_1,X_2,X_4\}$ with $0.62$; $9$ evaluations against $4$.

Show solution

Each step needs only the values of the current set plus one feature, all of which the table lists.

Step 1: the best single feature

$$X_1^*=X_1\ (0.46)$$

The largest single value.

Step 2: the best partner for $X_1$

$$I(\{X_1,X\};Y):\ X_2\ 0.55,\ \ X_3\ 0.51,\ \ X_4\ 0.62\ \Rightarrow\ X_4$$

$X_4$ adds the most to $X_1$, although $X_2$ has the larger relevance.

Step 3: the best third feature

$$\{X_1,X_4\}\text{ with }X_3:\ 0.71,\quad \text{with }X_2:\ 0.62\ \Rightarrow\ X_3$$

$X_2$ adds almost nothing once $X_4$ is in; $X_3$, nearly useless alone, adds $0.09$.

Relevance ranking and counts

$$\text{top three: }\{X_1,X_2,X_4\}:\ 0.62$$

The three largest singles; their joint value is in the list of triples.

$$4+3+2=9,\qquad \binom43=4$$

With only four features exhaustive search is the cheaper one.

Answer $$\boxed{\begin{aligned}&S_3=\{X_1,X_3,X_4\}:\ 0.71\\&\text{relevance: }\{X_1,X_2,X_4\}:\ 0.62\\&9\text{ evaluations against }4\end{aligned}}$$
Check

The largest of the four triples is $0.71$, reached by $\{X_1,X_3,X_4\}$, so incremental search found the best triple here.

A feature that is nearly useless alone can be the best third member; only a score on the whole set sees it.

5§11.5 — mRMR with a cluster of look-alike features

From 48 ECG recordings, six features were scored against an arrhythmia label. $X_1$, $X_3$ and $X_4$ are three ways of measuring the heart rate.

Find
  1. (a) Run mRMR with $k=3$.

  2. (b) Compare with the top three by relevance.

Given
  • relevance (bit): $X_1\ 0.40$, $X_2\ 0.01$, $X_3\ 0.30$, $X_4\ 0.27$, $X_5\ 0.08$, $X_6\ 0.23$

  • $I(X_1;X_3)=0.75$, $I(X_1;X_4)=0.72$, $I(X_3;X_4)=0.54$, $I(X_1;X_6)=I(X_3;X_6)=I(X_4;X_6)=0.12$

  • $I(X_1;X_5)=I(X_2;X_4)=I(X_2;X_5)=I(X_2;X_6)=I(X_5;X_6)=0.01$, $I(X_2;X_3)=0.02$

  • $I(X_1;X_2)=I(X_3;X_5)=I(X_4;X_5)=0.00$

Hint 1/4

The first pick is fixed by relevance; after that every candidate pays for what it shares with the chosen ones.

Hint 2/4

Score $=I(X;Y)-\frac1{l-1}\sum_{X'\in S_{l-1}}I(X;X')$.

Hint 3/4

Here $X_1$ comes first ($0.40$); at step 2, $X_3$ and $X_4$ share $0.75$ and $0.72$ with it, $X_6$ shares $0.12$, $X_5$ $0.01$ and $X_2$ $0.00$.

Hint 4/4

$S_3=\{X_1,X_6,X_5\}$; the top three by relevance are $\{X_1,X_3,X_4\}$.

Show solution

The table holds every two-variable value mRMR needs, so the work is three rounds of subtraction.

Step 1: the most relevant feature

$$X_1^*=X_1\ (0.40)$$

The largest relevance.

Step 2: one overlap each

$$X_3:\ 0.30-0.75=-0.45,\qquad X_4:\ 0.27-0.72=-0.45$$

Each candidate pays its overlap with $X_1$; the two other heart-rate features pay heavily.

$$X_2:\ 0.01-0=0.01,\qquad X_5:\ 0.08-0.01=0.07,\qquad X_6:\ 0.23-0.12=0.11$$

The features that measure something else pay almost nothing.

$$X_2^*=X_6$$

The largest net score, $0.11$.

Step 3: the average of two overlaps

$$\begin{aligned}&X_2:\ 0.01-\tfrac{0+0.01}2=0.005\\&X_3:\ 0.30-\tfrac{0.75+0.12}2=-0.135\\&X_4:\ 0.27-\tfrac{0.72+0.12}2=-0.15\\&X_5:\ 0.08-\tfrac{0.01+0.01}2=0.07\end{aligned}$$

Averages over the two chosen features, $X_1$ and $X_6$.

$$S_3=\{X_1,X_6,X_5\}$$

$0.07$ is the largest score.

Relevance ranking

$$\text{top three: }\{X_1,X_3,X_4\}$$

All three measure the heart rate.

Answer $$\boxed{\begin{aligned}&S_3=\{X_1,X_5,X_6\}\\&\text{by relevance: }\{X_1,X_3,X_4\}\end{aligned}}$$
Check

Joint values estimated from the recordings: $I(\{X_1,X_5,X_6\};Y)=0.65$ bit against $0.43$ for $\{X_1,X_3,X_4\}$.

When several top features measure the same thing, relevance ranking fills the set with them; mRMR takes one and moves on.

6§11.6 — when one feature is enough

A chemistry lab predicts the yield $y$ (g) of 10 batches from the catalyst mass $x_1$ (g), the stirring setting $x_2$ and a room humidity reading $x_3$. Least squares fits with an intercept gave these values.

Find
  1. (a) Find $M_1$, $M_2$ and $M_3$.

  2. (b) Compute $R^2$ for each and say which model is chosen.

Given
  • RSS: none $968$; $\{x_1\}$ $7.00$; $\{x_2\}$ $784.25$; $\{x_3\}$ $964.96$

  • $\{x_1,x_2\}$ $6.94$; $\{x_1,x_3\}$ $6.56$; $\{x_2,x_3\}$ $758.91$; $\{x_1,x_2,x_3\}$ $6.37$

  • $\mathrm{CV}(n)$ of the best model of each size: $119.51$, $1.07$, $1.43$, $1.96$ for $k=0,1,2,3$

Hint 1/4

Pick the winner of each size first; compare sizes only at the end, and with the right list.

Hint 2/4

$M_k$ has the smallest RSS among size-$k$ fits; $R^2=1-\mathrm{RSS}/\mathrm{TSS}$ with $\mathrm{TSS}=\mathrm{RSS}(M_0)$; the size is chosen by CV.

Hint 3/4

Here $\mathrm{TSS}=968$; size 1: $7.00$, $784.25$, $964.96$; size 2: $6.94$, $6.56$, $758.91$; size 3: $6.37$; CV: $119.51$, $1.07$, $1.43$, $1.96$.

Hint 4/4

$M_1=\{x_1\}$, $M_2=\{x_1,x_3\}$, $M_3$ all three; $R^2=0.9928$, $0.9932$, $0.9934$; CV chooses $M_1$.

Show solution

Within a size RSS decides; across sizes only the CV list may decide.

Winners by size

$$M_1=\{x_1\}\ (7.00),\quad M_2=\{x_1,x_3\}\ (6.56),\quad M_3=\{x_1,x_2,x_3\}\ (6.37)$$

The smallest RSS in each group.

R squared

$$\begin{aligned}&M_1:\ 1-\tfrac{7.00}{968}=0.9928\\&M_2:\ 1-\tfrac{6.56}{968}=0.9932\\&M_3:\ 1-\tfrac{6.37}{968}=0.9934\end{aligned}$$

$\mathrm{TSS}$ is the RSS of the null model.

Choose the size

$$\min(119.51,\ 1.07,\ 1.43,\ 1.96)=1.07\ \Rightarrow\ M_1$$

The smallest estimated test error.

Answer $$\boxed{\begin{aligned}&M_1=\{x_1\}\ \text{chosen}\\&R^2=0.9928,\ 0.9932,\ 0.9934\end{aligned}}$$
Check

Each added feature buys less than $0.001$ of $R^2$ while the leave-one-out error grows by a third or more at each step, $1.07\to1.43\to1.96$.

When one feature carries almost all the signal, cross-validation keeps the model small although $R^2$ keeps creeping up.

7§11.7 — forward stepwise with four features

Ten production runs record an output $y$, two machine settings $x_1$ and $x_2$, a combined gauge $x_3$ and the ambient temperature $x_4$. Forward stepwise selection is run with least squares (intercept included); the RSS values it needs are listed.

Find
  1. (a) Find the forward path and count its fits, the null model included.

  2. (b) Is the forward model of size 2 the best pair?

Given
  • size 1: $\{x_1\}$ $127.60$, $\{x_2\}$ $63.75$, $\{x_3\}$ $44.09$, $\{x_4\}$ $196.51$

  • size 2 with $x_3$: $\{x_1,x_3\}$ $43.28$, $\{x_2,x_3\}$ $23.91$, $\{x_3,x_4\}$ $43.16$

  • size 3 with $x_2,x_3$: $\{x_1,x_2,x_3\}$ $3.38$, $\{x_2,x_3,x_4\}$ $23.53$; all four $3.32$

  • for comparison: $\mathrm{RSS}(\{x_1,x_2\})=3.40$

Hint 1/4

Forward stepwise keeps its choices; at each step only the current set plus one feature is tried.

Hint 2/4

At step $k$, $X^*=\arg\min_{X\notin S_k}\mathrm{RSS}(S_k\cup\{X\})$; the fits number $1+p(p+1)/2$.

Hint 3/4

Here size 1: $127.60$, $63.75$, $44.09$, $196.51$; size 2 with $x_3$: $43.28$, $23.91$, $43.16$; size 3 with $x_2,x_3$: $3.38$, $23.53$.

Hint 4/4

$\{x_3\}\to\{x_2,x_3\}\to\{x_1,x_2,x_3\}\to$ all four, with $11$ fits; no, $\{x_1,x_2\}$ has RSS $3.40<23.91$.

Show solution

Each step is a minimum over the listed extensions of the current set; nothing else is needed.

Step 1: the best single feature

$$\{x_3\}:\ 44.09<63.75<127.60<196.51$$

The combined gauge is the best single feature.

Step 2: only pairs containing $x_3$

$$\{x_2,x_3\}:\ 23.91<43.16<43.28$$

Only pairs containing $x_3$ are tried.

Steps 3 and 4: the last two additions

$$\{x_1,x_2,x_3\}:\ 3.38<23.53;\qquad \text{then all four: }3.32$$

The size-3 step adds $x_1$, the last step adds $x_4$.

Count and compare

$$1+4+3+2+1=11;\qquad 3.40<23.91$$

The null model plus the candidates at each step; the best pair beats the forward pair.

Answer $$\boxed{\begin{aligned}&\emptyset\to\{x_3\}\to\{x_2,x_3\}\\&\to\{x_1,x_2,x_3\}\to\text{all four}\\&11\ \text{fits; not the best pair}\end{aligned}}$$
Check

Formula check: $1+\frac{4\cdot5}2=11$, against $2^4=16$ fits for best subset.

A gauge that summarizes two settings is a typical first pick that later locks the settings themselves out.

C · exam level 4 questions
1§11.5 — a method for 9703 genes and 60 samples

A cancer study has $n=60$ tissue samples, $p=9703$ gene expression features and 9 tumour classes, the size of the lecture's example, and it needs about 50 genes for a classifier.

Find(a) Which selection method is feasible and gives trustworthy scores?
Given
  • $n=60$, $p=9703$, 9 classes

  • target: about 50 genes

Hint 1/4

Check two things for each method: how many scores it computes, and how many variables each score involves.

Hint 2/4

Exhaustive: $\binom pk$ scores of $k+1$ variables; incremental: about $kp$ scores of up to $k+1$ variables; mRMR: about $kp$ scores of two variables; best subset: $2^p$ fits.

Hint 3/4

Here $p=9703$, $k=50$ and $n=60$: $\binom{9703}{50}\approx10^{135}$, $2^{9703}\approx10^{2921}$, and late incremental steps need tables over dozens of variables from 60 samples.

Hint 4/4

Only mRMR is both feasible and built from small tables.

Show solution

Two quick counts per method, the number of scores and the variables per score, decide the question without running anything.

How many scores

$$\begin{aligned}&\binom{9703}{50}\approx10^{135}\\&2^{9703}\approx7.8\times10^{2920}\\&50\cdot9703-\tfrac{50\cdot49}2=483925\end{aligned}$$

Exhaustive search and best subset are out; incremental search and mRMR need about $4.8\times10^5$ scores.

Variables per score

$$\begin{aligned}&\text{incremental: up to }51\\&\text{mRMR: }2\end{aligned}$$

With 60 samples only small tables can be estimated.

Answer $$\boxed{\text{mRMR}}$$
Check

The lecture's comparison on data of this size points the same way: mRMR selects features faster, and with many selected features it classifies more accurately than maximum dependency.

At large $p$ and small $n$, prefer scores built from small tables, even when they are only heuristics.

2§11.6 — two wrong steps in a best subset solution

A student applied best subset selection to eight runs with three meters; the data are listed under Given. Two of the four steps are wrong.

  1. $M_1=\{x_3\}$, the smallest single RSS, $23.50$.
  2. The best pair must contain $x_3$, so $M_2=\{x_2,x_3\}$, since $21.48<21.71$.
  3. $M_3=\{x_1,x_2,x_3\}$, the only model of size 3.
  4. $M_3$ has the smallest RSS of the four winners, so $M_3$ is chosen.
Find(a) Which two steps are wrong?
Given
  • RSS: none $146$; $\{x_1\}$ $79.33$; $\{x_2\}$ $99.45$; $\{x_3\}$ $23.50$

  • $\{x_1,x_2\}$ $1.714$; $\{x_1,x_3\}$ $21.71$; $\{x_2,x_3\}$ $21.48$; $\{x_1,x_2,x_3\}$ $1.705$

  • $\mathrm{CV}(n)$: none $23.84$; $\{x_3\}$ $4.43$; $\{x_1,x_2\}$ $1.12$; $\{x_1,x_2,x_3\}$ $4.47$

Hint 1/4

Check each step against the rule it claims to apply, not against the final answer.

Hint 2/4

Within a size, $M_k$ is the smallest RSS over all models of that size; across sizes, the choice is by CV error.

Hint 3/4

Here the pairs have RSS $1.714$, $21.71$ and $21.48$ for $\{x_1,x_2\}$, $\{x_1,x_3\}$ and $\{x_2,x_3\}$; the CV errors are $23.84$, $4.43$, $1.12$ and $4.47$.

Hint 4/4

Steps 2 and 4 are wrong: $M_2=\{x_1,x_2\}$, and CV chooses it.

Show solution

Only the two faulty steps need redoing; Steps 1 and 3 follow the rule.

The best pair

$$M_2=\{x_1,x_2\}:\ 1.714<21.48<21.71$$

All three pairs compete; nothing forces the best single feature into the best pair.

The size

$$\min(23.84,\ 4.43,\ 1.12,\ 4.47)=1.12\ \Rightarrow\ M_2$$

Sizes are compared by cross-validation, not by training RSS.

Answer $$\boxed{\begin{aligned}&\text{Steps 2 and 4}\\&\text{chosen: }M_2=\{x_1,x_2\}\end{aligned}}$$
Check

$M_3$'s RSS, $1.705$, is only $0.009$ below $M_2$'s, while its leave-one-out error is four times larger, $4.47$ against $1.12$.

Two classic slips: assuming the winners are nested, and letting training error compare sizes.

3§11.4 — a joint estimate with more cells than samples

Twelve patients, six with the disease ($Y=1$), were tested with three yes or no markers that, in truth, are unrelated to the disease. The 12 patients fall into 8 marker patterns.

Find
  1. (a) Compute the plug-in $H(Y\mid S)$ and $\hat I(S;Y)$ for the three markers.

  2. (b) Suppose more coin-flip markers are added until every patient has a pattern of their own. What is the estimate then, and what is the true value?

Given
  • $n=12$, six with $Y=1$

  • 4 patterns hold one patient each; 2 patterns hold two patients with different labels; 2 patterns hold two patients with the same label

Hint 1/4

Only patterns that contain both labels leave any uncertainty; count the patients in them.

Hint 2/4

$\hat I=H(Y)-\sum_sp(s)H(Y\mid S=s)$, where a cell with one patient, or with one label only, has $H=0$.

Hint 3/4

Here $H(Y)=1$ bit, and the mixed patterns hold $2+2=4$ of the 12 patients, each with $H=1$.

Hint 4/4

$H(Y\mid S)=\frac4{12}$ and $\hat I=0.667$ bit; one patient per pattern would give $1$ bit, while the truth is $0$.

Show solution

Cells with one label contribute nothing, so only the two mixed cells need counting.

Leftover uncertainty

$$\begin{aligned}H(Y\mid S)&=\tfrac2{12}\cdot1+\tfrac2{12}\cdot1\\&=\tfrac4{12}=0.333\end{aligned}$$

Each mixed cell holds two of the 12 patients and one bit.

The estimate

$$\hat I=1-0.333=0.667\ \text{bit}$$

Plug-in mutual information.

One patient per pattern

$$H(Y\mid S)=0\ \Rightarrow\ \hat I=1\ \text{bit};\qquad I_{\text{true}}=0$$

Twelve pure cells of one patient; the markers were generated independently of the disease.

Answer $$\boxed{\begin{aligned}&\hat I=0.667\ \text{bit}\\&\text{one per pattern: }1\ \text{bit}\\&\text{true value: }0\end{aligned}}$$
Check

Bound check: the estimate can never exceed $H(Y)=1$ bit, reached when every cell holds one patient; $0.667$ sits two thirds of the way there with 12 patients in 8 cells.

Before trusting a joint estimate, compare the number of cells with the number of samples.

4§11.4 — incremental search against mRMR on 40 pumps

The pump study estimated joint mutual informations as well as pairwise ones; mRMR with $k=3$ chose $\{X_2,X_4,X_5\}$, whose joint value is $0.81$ bit.

Find
  1. (a) Run incremental search with $k=3$.

  2. (b) Compare its set with mRMR's. How many cells does a three-feature score use, and what does that say about the difference?

Given
  • relevance (bit): $X_1\ 0.13$, $X_2\ 0.58$, $X_3\ 0.32$, $X_4\ 0.24$, $X_5\ 0.27$

  • pairs with $X_2$: $X_1\ 0.71$, $X_3\ 0.58$, $X_4\ 0.74$, $X_5\ 0.66$

  • triples with $X_2$ and $X_4$: $X_1\ 0.85$, $X_3\ 0.74$, $X_5\ 0.81$

  • 40 pumps; features and fault label are binary

Hint 1/4

Run the search on the joint values first; then ask how reliable a table over four binary variables is when 40 pumps fill it.

Hint 2/4

$X_l^*=\arg\max_{X\notin S_{l-1}}I(S_{l-1}\cup\{X\};Y)$; three binary features with a binary label form $2^3\cdot2=16$ cells.

Hint 3/4

Here step 1 compares $0.13$, $0.58$, $0.32$, $0.24$, $0.27$; step 2 the pairs with $X_2$, $0.71$, $0.58$, $0.74$, $0.66$; step 3 the triples with $X_2,X_4$, $0.85$, $0.74$, $0.81$.

Hint 4/4

$S_3=\{X_2,X_4,X_1\}$ with $0.85$ against mRMR's $0.81$. Both are read from the same thin 16-cell tables, so a shared upward bias shifts both and cannot explain the $0.04$ gap; sampling noise can, and with 2.5 pumps per cell it is of that size.

Show solution

The search itself is three maxima over listed values; the judgement needs one count of cells.

Step 1: the best single feature

$$X_1^*=X_2\ (0.58)$$

The largest single value.

Step 2: the best partner for $X_2$

$$\{X_2,X_4\}\ (0.74)>\{X_2,X_1\}\ (0.71)>\{X_2,X_5\}\ (0.66)>\{X_2,X_3\}\ (0.58)$$

$X_3$ overlaps with $X_2$ and adds least.

Step 3: the best partner for the pair

$$\{X_2,X_4,X_1\}\ (0.85)>\{X_2,X_4,X_5\}\ (0.81)>\{X_2,X_4,X_3\}\ (0.74)$$

$X_1$, weak alone, adds most to the pair.

How far to trust the gap

$$\begin{aligned}&2^3\cdot2=16\ \text{cells}\\&\tfrac{40}{16}=2.5\ \text{pumps per cell}\end{aligned}$$

Both scores come from tables this thin, so a shared upward bias cancels in their difference; what remains is sampling noise, and with 2.5 pumps per cell it is several hundredths of a bit.

Answer $$\boxed{\begin{aligned}&S_3=\{X_2,X_4,X_1\}:\ 0.85\\&\text{mRMR set: }0.81\\&\text{a gap within the sampling noise}\end{aligned}}$$
Check

A separate size check: a three-feature table has $2^3=8$ feature cells for 40 pumps, 5 per cell, so moving one pump to another cell changes a joint estimate by about $0.03$ to $0.05$ bit, the size of the gap itself.

A small edge in an estimated joint information is not evidence when the tables are thin; mRMR trades a little of that edge for estimates you can trust.

D · interleaved 4 questions
1§11.6 — four uncorrelated inputs, keep two

Four standardized features are uncorrelated on the training set, with $X^TX=nI$ and $n=50$; $y$ is centered. Least squares and lasso are both available.

Find
  1. (a) Which two features give the smallest training RSS among all two-feature models, and with which coefficients?

  2. (b) Which coefficients does the penalized rule in the data return with $\lambda=100$, and which feature does it drop?

  3. (c) By how much does the RSS of the pair in (a) exceed that of the full model?

Given
  • $\hat\beta^{\mathrm{LS}}=(3.0,\ -1.2,\ 0.5,\ 2.0)$

  • $X^TX=50\,I$

  • lasso rule for this design: $\hat\beta^L_j=\operatorname{sign}(b_j)\,\big(\lvert b_j\rvert-\tfrac{\lambda}{2n}\big)_+$ with $b_j=\hat\beta^{\mathrm{LS}}_j$

  • $\lambda=100$

Hint 1/4

With orthogonal features each coefficient can be handled on its own, for both methods.

Hint 2/4

$\mathrm{RSS}(S)=\lVert y\rVert^2-n\sum_{j\in S}(\hat\beta^{\mathrm{LS}}_j)^2$, and lasso soft-thresholds each coefficient by $\frac{\lambda}{2n}$.

Hint 3/4

Here $n=50$, $\hat\beta^{\mathrm{LS}}=(3.0,\ -1.2,\ 0.5,\ 2.0)$ and $\frac{\lambda}{2n}=\frac{100}{100}=1$.

Hint 4/4

Best pair $x_1,x_4$ at $(3.0,\ 2.0)$; lasso $(2.0,\ -0.2,\ 0,\ 1.0)$; the RSS gap is $84.5$.

Show solution

Orthogonality splits both problems into one-coefficient problems, so no matrix has to be inverted.

Why each coefficient stands alone

$$X^TX=nI:\quad \hat\beta^{\mathrm{LS}}_S=(\hat\beta^{\mathrm{LS}}_j)_{j\in S}$$

Orthogonal columns share no part of the fit, so dropping one leaves the others unchanged.

$$\mathrm{RSS}(S)=\lVert y\rVert^2-50\sum_{j\in S}(\hat\beta^{\mathrm{LS}}_j)^2$$

The fitted part has squared length $\hat\beta^TX^TX\hat\beta=n\sum_j\hat\beta_j^2$.

Best pair

$$\begin{aligned}&\text{largest squares: }9\ (x_1),\ 4\ (x_4)\\&\Rightarrow\ \{x_1,x_4\}\text{ at }(3.0,\ 2.0)\end{aligned}$$

The two largest $\lvert\hat\beta_j\rvert$ remove the most RSS.

Lasso

$$(3.0-1,\ -(1.2-1),\ 0,\ 2.0-1)=(2.0,\ -0.2,\ 0,\ 1.0)$$

$0.5<1$ is set to $0$; the others shrink by $1$ toward $0$.

RSS gap

$$50\,(1.44+0.25)=84.5$$

The share of the fit carried by the two dropped coefficients.

Answer $$\boxed{\begin{aligned}&\{x_1,x_4\}\text{ at }(3.0,\ 2.0)\\&\hat\beta^L=(2.0,\ -0.2,\ 0,\ 1.0)\\&\text{RSS gap: }84.5\end{aligned}}$$
Check

Both methods drop $x_3$ first; lasso keeps $x_2$ with a small coefficient where best subset of size 2 drops it, and best subset keeps full-size coefficients where lasso shrinks them.

With orthogonal features best subset is hard thresholding and lasso is soft thresholding of the same least squares coefficients.

2§11.1 — four points, keep one direction

Four centered points have two features and a label. The first feature spreads widely but has nothing to do with the label.

Find
  1. (a) Which single direction in the feature plane keeps the most spread of the features, and what fraction of the total variance does it keep?

  2. (b) How strongly is each feature correlated with $y$, and which one feature would you keep to predict $y$?

  3. (c) Regress $y$ on the points' coordinates along the direction from (a), then on the feature from (b). Compare the two RSS values.

Given
  • $x_1=(-3,-3,3,3)$

  • $x_2=(-1,1,-1,1)$

  • $y=(4,6,4,6)$

  • $\Sigma=\frac14X^TX$

Hint 1/4

PCA looks only at the features; the correlation score looks at the label. Compute each and compare what they keep.

Hint 2/4

PCA: the top eigenvector of $\Sigma$, with $\mathrm{PVE}=\lambda_1/(\lambda_1+\lambda_2)$. Ranking: $s_j=\hat R_j^2$. One-feature fit: $\mathrm{RSS}=S_{yy}(1-\hat R^2)$.

Hint 3/4

Here $\Sigma=\frac14\begin{bmatrix}36&0\\0&4\end{bmatrix}$, and the deviations of $y$ from its mean $5$ are $(-1,1,-1,1)$, equal to $x_2$.

Hint 4/4

The first component is $(1,0)$ with $\mathrm{PVE}=0.9$; $\hat R_1=0$ and $\hat R_2=1$; RSS $4$ on the component, $0$ on $x_2$.

Show solution

$\Sigma$ turns out diagonal, so both methods reduce to reading off numbers.

PCA

$$\begin{aligned}&\Sigma=\begin{bmatrix}9&0\\0&1\end{bmatrix}\\&u_1=(1,0),\quad \mathrm{PVE}=\tfrac9{10}=0.9\end{aligned}$$

A diagonal matrix has the axes as eigenvectors; the larger variance comes first.

Correlations

$$\begin{aligned}&S_{1y}=3-3-3+3=0\\&S_{2y}=1+1+1+1=4\\&\sqrt{S_{22}S_{yy}}=\sqrt{4\cdot4}=4\end{aligned}$$

Deviations of $y$ are $(-1,1,-1,1)$, exactly $x_2$.

$$\hat R_1=0,\quad \hat R_2=1\ \Rightarrow\ \text{keep }x_2$$

The label moves with $x_2$ and not at all with $x_1$.

Two fits

$$\mathrm{RSS}(z_1)=S_{yy}(1-0)=4,\qquad \mathrm{RSS}(x_2)=S_{yy}(1-1)=0$$

The first score is $x_1$ itself.

Answer $$\boxed{\begin{aligned}&u_1=(1,0),\quad \mathrm{PVE}=0.9\\&\text{keep }x_2\\&\mathrm{RSS}:\ 4\text{ against }0\end{aligned}}$$
Check

The component keeps 9 of the 10 units of feature variance and none of the label's; $x_2$ keeps 1 unit of feature variance and all of the label's.

PCA keeps what varies; selection with the label keeps what predicts. They agree only when the large directions happen to be the useful ones.

3§11.6 — fifty images and five thousand pixels

A student has $n=50$ labelled images and $p=5000$ pixel features that, in truth, are unrelated to the label. She ranks the features by $\hat R_j^2$ on all 50 images, keeps the top 20, and then runs 5-fold cross-validation of least squares on those 20.

Find(a) What will the CV error look like, and what should she do instead?
Given
  • $n=50$; $p=5000$ features unrelated to $y$

  • ranking done once, on all 50 images

  • then 5-fold CV on the 20 kept features

Hint 1/4

Ask whether the held-out images in each fold were really unseen by everything that used the labels.

Hint 2/4

Every step that looks at the labels, feature selection included, must be done on the training part of each fold only.

Hint 3/4

Here the ranking used all 50 labels, so in every fold the 20 kept features were chosen partly for how well they fit the held-out images.

Hint 4/4

The error is too low; the ranking must be repeated inside every fold.

Show solution

The question is not arithmetic but which data each step has seen; following one held-out image through the steps answers it.

Follow one held-out image

$$\text{its label helped rank the features}$$

The ranking of all 5000 features ran before the folds were formed.

$$\text{the kept }20\text{ fit it too well}$$

Out of 5000 unrelated features, the top 20 are the ones that happen to match all 50 labels, this one included.

Consequence and fix

$$\begin{aligned}&\mathrm{CV}\ \text{too low}\\&\text{rank again inside each fold}\end{aligned}$$

Then the held-out images play no part in choosing the features.

Answer $$\boxed{\begin{aligned}&\text{too low: redo the ranking}\\&\text{inside every fold}\end{aligned}}$$
Check

Truth check: the features are unrelated to the label, so no model can beat predicting the mean; a CV error clearly below the null model's error exposes the leak.

Whatever uses the labels belongs inside the cross-validation loop.

4§11.2 — an alarm that never misses

A fault occurs in 1 of every 4 units. A test always fires on a faulty unit, and it also fires on 1 in 3 good units.

Find
  1. (a) How often does the test fire, and when it fires, how likely is a fault?

  2. (b) How many bits does one test result tell about the fault?

Given
  • $P(Y=1)=\tfrac14$

  • $P(X=1\mid Y=1)=1$, $P(X=1\mid Y=0)=\tfrac13$

Hint 1/4

Build the joint table of test and fault first; the information then follows by the entropy route.

Hint 2/4

$P(X=1)=\sum_yP(X=1\mid y)P(y)$; $P(Y=1\mid X=1)=P(X=1\mid Y=1)P(Y=1)/P(X=1)$; $I=H(Y)-H(Y\mid X)$.

Hint 3/4

Here $P(X=1)=1\cdot\frac14+\frac13\cdot\frac34$, and a unit on which the test stays silent is surely good.

Hint 4/4

$P(X=1)=\frac12$, $P(Y=1\mid X=1)=\frac12$ and $I=0.811-0.5=0.311$ bit.

Show solution

The joint table has one empty cell, so the entropy route needs only $H$ of a $1:3$ split.

Joint table

$$\begin{aligned}&P(Y=1,X=1)=\tfrac14\\&P(Y=0,X=1)=\tfrac34\cdot\tfrac13=\tfrac14\\&P(Y=0,X=0)=\tfrac12\\&P(Y=1,X=0)=0\end{aligned}$$

Each cell is a prior times a test probability.

Total probability and Bayes

$$\begin{aligned}&P(X=1)=\tfrac14+\tfrac14=\tfrac12\\&P(Y=1\mid X=1)=\frac{1/4}{1/2}=\tfrac12\end{aligned}$$

Half of the alarms are false.

Mutual information

$$\begin{aligned}H(Y)&=-\tfrac14\log\tfrac14-\tfrac34\log\tfrac34\\&=0.811\end{aligned}$$

One faulty unit in four.

$$\begin{aligned}&H(Y\mid X)=\tfrac12\cdot1+\tfrac12\cdot0=0.5\\&I=0.811-0.5=0.311\ \text{bit}\end{aligned}$$

An alarm leaves a fair coin; silence leaves no doubt.

Answer $$\boxed{\begin{aligned}&P(X=1)=\tfrac12\\&P(Y=1\mid X=1)=\tfrac12\\&I(X;Y)=0.311\ \text{bit}\end{aligned}}$$
Check

Definition route on the table: $\frac14\log2+\frac14\log\frac23+\frac12\log\frac43=0.25-0.146+0.208=0.311$.

A test that never misses a fault can still carry well under the label's $0.811$ bit, because half of its alarms are false.

Mistake ledger (14 entries)
⚠ Ranking by the signed correlation

The largest number looks like the best feature, and negative numbers look small.

wrong$$s_j=\hat R_j:\quad \text{keep }x_3\ (0.6)\text{ and }x_2\ (0.3)$$
right$$s_j=\hat R_j^2:\quad \text{keep }x_1\ (0.81)\text{ and }x_3\ (0.36)$$
⚠ Reading zero correlation as no relation

Zero covariance sounds like independence, but it only rules out a straight-line trend.

wrong$$\hat R_j=0\ \Rightarrow\ X_j\text{ tells nothing about }Y$$
right$$y=x^2,\ x\in\{-1,0,1\}:\quad \hat R=0,\ \text{yet }x\text{ fixes }y$$
⚠ Mixing logarithm bases

Calculators default to $\ln$, and a table in bits with one value in nats still looks consistent.

wrong$$\begin{aligned}I(X_3;Y)&=\tfrac34\ln\tfrac32-\tfrac14\ln2\\&=0.131\ \text{bit}\end{aligned}$$
right$$0.131\ \text{nat}=\frac{0.131}{\ln2}=0.189\ \text{bit}$$
⚠ Averaging the groups without their weights

Three bands look like three equal parts, but they hold 4, 8 and 4 wafers.

wrong$$H(Y\mid X_1)=\tfrac13(0+1+0)=0.333$$
right$$\begin{aligned}H(Y\mid X_1)&=\tfrac4{16}\cdot0+\tfrac8{16}\cdot1+\tfrac4{16}\cdot0\\&=0.5\end{aligned}$$
⚠ Adding relevances to score a set

Relevance looks like an amount, and amounts add.

wrong$$I(\{X_1,X_2\};Y)=I(X_1;Y)+I(X_2;Y)=1$$
right$$X_2=X_1:\quad I(\{X_1,X_2\};Y)=I(X_1;Y)=0.5$$
⚠ Dropping every zero-relevance feature

A score of $0$ reads like proof that the feature is useless.

wrong$$I(A;Y)=I(B;Y)=0\ \Rightarrow\ \text{drop }A\text{ and }B$$
right$$I(\{A,B\};Y)=1\ \text{bit}$$
⚠ Counting subsets as a power

Choosing $k$ of $p$ sounds like $p$ choices made $k$ times.

wrong$$\binom{10}3=10^3=1000$$
right$$\binom{10}3=\frac{10\cdot9\cdot8}{3!}=120$$
⚠ Trusting a joint estimate from nearly empty cells

The number comes out of the same formula as a trustworthy one.

wrong$$\hat I(S;Y)=1\ \text{bit}\ \Rightarrow\ S\text{ predicts }Y\text{ perfectly}$$
right$$\text{cells}\gg n:\ \ \hat I(S;Y)\to H(Y)\ \text{even for coin flips}$$
⚠ Summing the redundancies

The bracket in the rule has a sum in it, and the factor in front is easy to drop.

wrong$$0.40-(0.30+0.10)=0$$
right$$0.40-\tfrac{0.30+0.10}2=0.20$$
⚠ Averaging over l instead of l minus 1

Step $l$ sounds like $l$ features, but only $l-1$ are chosen before it.

wrong$$0.40-\tfrac{0.30+0.10}3=0.27$$
right$$\text{at step }l=3:\ \ \tfrac1{l-1}=\tfrac12$$
⚠ Choosing the size by training RSS or R squared

A smaller error on the training data looks like a better model.

wrong$$\min_k\mathrm{RSS}(M_k)=\mathrm{RSS}(M_p)\ \Rightarrow\ M_p$$
right$$\arg\min_k\mathrm{CV}(M_k)=M_2\ \text{(workshop data)}$$
⚠ Leaving out the null model

A model with no features does not look like a candidate, yet sometimes no feature helps.

wrong$$\text{choose among }M_1,\dots,M_p$$
right$$\text{choose among }M_0,M_1,\dots,M_p$$
⚠ Assuming the forward path holds the best model of each size

Every step is locally best, which sounds like globally best.

wrong$$M_2^{\mathrm{fwd}}=\{x_2,x_3\}=M_2$$
right$$\mathrm{RSS}(\{x_2,x_3\})=21.27>\mathrm{RSS}(\{x_1,x_2\})=1.50$$
⚠ Forgetting the null model in the count

The sum over steps is the visible part of the formula.

wrong$$\text{fits}=\tfrac{p(p+1)}2=15\quad(p=5)$$
right$$\text{fits}=1+\tfrac{p(p+1)}2=16\quad(p=5)$$
Formula card
Feature ranking and the correlation score
$$\begin{aligned}&\hat R_j=\frac{S_{jy}}{\sqrt{S_{jj}S_{yy}}},\quad s_j=\hat R_j^2\\&\text{keep }(1),\dots,(k)\end{aligned}$$

sums of deviations from the sample means

One-feature fit
$$\mathrm{RSS}_j=S_{yy}\,(1-\hat R_j^2)$$

least squares on feature $j$ alone

Mutual information
$$\begin{aligned}I(X;Y)&=\sum_{x,y}p(x,y)\log\tfrac{p(x,y)}{p(x)p(y)}\\&=H(Y)-H(Y\mid X)\end{aligned}$$

base 2, in bits; $0\le I(X;Y)\le\min(H(X),H(Y))$

Entropy and conditional entropy
$$\begin{aligned}&H(Y)=-\sum_yp(y)\log p(y)\\&H(Y\mid X)=\textstyle\sum_xp(x)H(Y\mid X=x)\end{aligned}$$

weights $p(x)$ in the average

Maximum relevance
$$s_j=I(X_j;Y);\qquad X_2=g(X_1)\ \Rightarrow\ I(\{X_1,X_2\};Y)=I(X_1;Y)$$

one feature at a time

Maximum dependency and incremental search
$$\begin{aligned}&S^*=\arg\max_{\lvert S\rvert=k}I(S;Y)\\&\text{evaluations: }\binom pk\\&\text{or }kp-\tfrac{k(k-1)}2\text{ (incremental)}\end{aligned}$$

joint tables over $k+1$ variables

mRMR step
$$\begin{aligned}X_l^*&=\arg\max_{X\notin S_{l-1}}\Big[I(X;Y)\\&\quad-\tfrac1{l-1}\textstyle\sum_{X'\in S_{l-1}}I(X;X')\Big]\end{aligned}$$

two-variable estimates only; a heuristic

Best subset selection
$$\begin{aligned}&M_k=\arg\min_{\lvert S\rvert=k}\mathrm{RSS}(S)\\&\text{size by cross-validation};\quad 2^p\ \text{fits}\end{aligned}$$

never compare sizes by RSS or $R^2$

R squared
$$\begin{aligned}&R^2=1-\frac{\mathrm{RSS}}{\mathrm{TSS}}\\&\mathrm{TSS}=\sum_i(y_i-\bar y)^2\end{aligned}$$

rises with every added feature

Forward stepwise selection
$$\begin{aligned}&X^*=\arg\min_{X\notin S_k}\mathrm{RSS}(S_k\cup\{X\})\\&S_{k+1}=S_k\cup\{X^*\}\\&1+\tfrac{p(p+1)}2\ \text{fits}\end{aligned}$$

greedy; the size is chosen by cross-validation

Check yourself

Close the page and write down from memory:

  • the steps of feature ranking and the correlation score;
  • the definition of mutual information and its entropy form;
  • the two things maximum relevance cannot see;
  • the maximum dependency rule, its incremental version and both counts;
  • the mRMR step;
  • best subset selection, and why RSS cannot choose the size;
  • forward stepwise selection and its number of fits.

Then reopen the page and compare; whatever is missing is your reread list.

  • Compute $\hat R_j$ from data, score by $\hat R_j^2$ and build $\tilde D$?

    c-ranking

  • Compute $I(X;Y)$ from a table of counts by both routes, in bits?

    c-mutual-info

  • Show with numbers why two copies or two team-mates fool maximum relevance?

    c-max-relevance

  • Run incremental search from a table, count its evaluations, and say when a joint estimate is not to be trusted?

    c-max-dependency

  • Run mRMR for three steps, averaging the redundancies correctly?

    c-mrmr

  • Find $M_0,\dots,M_p$ from an RSS table and choose the size by cross-validation?

    c-best-subset

  • Trace forward stepwise, count its fits, and spot when it misses the best subset?

    c-forward

Glossary (20 terms)
feature selectionöznitelik seçimi

Keeping a subset of the original features, instead of building new ones as PCA does.

feature rankingöznitelik sıralama

Scoring every feature from the data, sorting the scores and keeping the top $k$.

Pearson korelasyon katsayısı

$\operatorname{Cov}(X_j,Y)/\sqrt{\operatorname{Var}(X_j)\operatorname{Var}(Y)}$, between $-1$ and $1$; it measures straight-line association.

entropyentropi

$H(Y)=-\sum_yp(y)\log p(y)$: the uncertainty about $Y$, in bits with base-2 logarithms.

conditional entropykoşullu entropi

$H(Y\mid X)=\sum_xp(x)H(Y\mid X=x)$: the uncertainty about $Y$ left once $X$ is seen.

mutual informationkarşılıklı bilgi

$I(X;Y)=H(Y)-H(Y\mid X)$: how much knowing $X$ reduces the uncertainty about $Y$; zero exactly when they are independent.

relevance

In feature selection, $I(X;Y)$: how much a feature alone tells about the label.

redundancy

In mRMR, the average mutual information between a candidate and the features already chosen.

maximum relevance

Keeping the $k$ features with the largest $I(X_j;Y)$.

maximum dependency

Keeping the $k$-subset $S$ with the largest joint $I(S;Y)$.

incremental search

Growing a feature set one feature at a time, each time adding the feature that most increases the score of the enlarged set.

açgözlü algoritma

An algorithm that takes the best-looking step each time and never revisits it: fast, but it can miss the overall best answer.

mRMR

Minimum redundancy maximum relevance: add the feature with the largest relevance minus average redundancy.

boyut laneti

The number of cells, and of samples needed to fill them, grows exponentially with the number of variables.

plug-in estimate

An estimate that replaces probabilities by relative frequencies from the data.

best subset selectionen iyi alt küme seçimi

Fitting all $2^p$ models, keeping the lowest-RSS model of each size, and choosing the size by cross-validation.

forward stepwise selectionileriye doğru seçim

Adding one feature at a time, the one that lowers RSS most, and choosing the size by cross-validation.

null model

The model with no features, which predicts $\bar y$ for every input.

belirlilik katsayısı

$R^2=1-\mathrm{RSS}/\mathrm{TSS}$: the share of the label's variation a fit explains on the training data.

toplam kareler toplamı

$\mathrm{TSS}=\sum_i(y_i-\bar y)^2$, the RSS of the null model.

What comes next
§12 · Probabilistic graphical models

Here the question was which variables to keep. Next, many variables are kept together, and the dependence between them is drawn as a graph.

Sources
  • textbookT. Hastie, R. Tibshirani, J. Friedman, The Elements of Statistical Learning, Springer (course textbook) The weekly line names no chapter of the book, so no section numbers are cited here.
  • course materialEEE 485 lecture slides and lecture notes, chapter 11: Feature selection Scope, order of topics and notation (D, the scores and the ranked indices, the reduced data set, R and its estimate, I, H, S, the set of k-subsets, S*, S_l, the added feature, M_0, M_k, RSS) follow these materials; the explanations, data sets, figures and exercises here are original.
  • course materialEEE 485 syllabus page on STARS, Fall 2026-27, printed 21 September 2026 Assessment weights and the weekly topic list.
  • standard resultEntropy, mutual information, least squares and cross-validation Standard results used in the derivations. The data sets, numbers and figures were made or computed for this page; the gene data sizes quoted are the lecture's.

Spotted something missing or wrong? tell us · share your own notes or an old exam.

Last updated .