With p=10 candidate features, how many models does best-subset selection have to consider, and how many model fits does forward stepwise selection need? What changes for p=30, and why might forward stepwise still give a worse model than best subset?

Supervised learning, Subset selection
Level L2 Elementary. Length Short. Nature Th+Mat Both.

What's being asked

Whether you know the cost of best subset (exponential) against the greedy search (quadratic), and the price paid for being greedy.

Key idea

Best subset has 2p candidate models. Forward stepwise considers p+(p−1)+⋯+1=p(p+1)/2 candidates (plus the null model), but never revisits a choice.

Steps

  1. Each feature is in or out of the model, so best subset considers 2p subsets: 210=1024 and 230≈1.07×109.
  2. Forward stepwise starts from the intercept-only model. At step k it tries each of the p−k+1 unused features and adds the best. Total fits =10+9+⋯+1=55 (56 with the null model). For p=30 it is 465 (466).
  3. So forward stepwise scales as O(p2) against O(2p), and is usable when p is in the hundreds or thousands. Backward elimination needs n>p to fit the full model first.
  4. Greedy can be worse: a feature that is weak alone but strong together with another (for example two features whose difference matters) is never added first. Best subset finds such pairs.
  5. Always choose the model size by cross-validation or an information criterion, not by training RSS, which always falls as features are added.

Common mistakes

How long your answer should be

4–6 sentences with the three counts.

Last checked on 4 December 2026.

Read this

Previous in Supervised learning: An Adaline has two weights, no bias, starting at w=(0,0), with learning rate η=0.1 and the delta rule w←w+η(t−w⊤x) x. Apply it to the sample x=(1,2) with target t=3, then to x=(2,1) with target t=1. What are the weights after each step? For what range of η is a single repeated sample x=(1,2) stable?
Next in Supervised learning: A three-class softmax model produces scores (logits) z=(2,1,0) for an input. Compute the class probabilities. If the true class is class 2, what is the cross-entropy loss, and what is the gradient of the loss with respect to z?