Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Build up, or strip down
You can pack for a trip by starting with an empty bag and adding the most useful item each time, or by starting with everything and removing the least useful item each time. Sequential forward selection and sequential backward selection do this with features, scoring each choice by how well a model performs with the resulting set.
When a model can only use a few inputs, because of sensor cost, bandwidth or certification effort, a wrapper search finds the subset that works best for that model. It also shows clearly how combinations of measurements matter, and how easily a search can fool itself with small data.
- 1. Forward selection starts with…
- 2. Sequential selection scores subsets using…
- 3. Two features useful only together are more likely kept by…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.The algorithms by hand
Forward (SFS). Start with S = ∅. At each step, add the feature j not yet in S that maximises the CV score of S with j added. Stop at a chosen size, or when the score stops improving. If S contains feature 2 and adding feature 0, 1 or 3 gives scores 0.61, 0.74 or 0.69, add feature 1.
Backward (SBS). Start with all features. At each step, remove the feature j whose removal leaves the best score. For scores-after-removal (0.55, 0.56, 0.79, 0.81), remove feature 3.
Cost. Choosing k of p features forward takes p + (p − 1) + … + (p − k + 1) evaluations: 14 + 13 + 12 + 11 = 50 for 4 of 14. Backward from p down to k takes p + (p − 1) + … + (k + 1) evaluations, many more when k is small. Exhaustive search over all 4-subsets of 14 needs C(14, 4) = 1001 evaluations, and over all 10-subsets of 50 more than 10 billion. Each evaluation is itself a full cross-validation.
k-NN as the model. In this lesson the model is k-nearest neighbours. It can use feature interactions (such as XOR) without being told about them, but it is sensitive to irrelevant features, which dilute the distances. That makes selection matter.
- 1. Evaluations to choose 3 of 10 forward?
- 2. Exhaustive 3-subsets of 10?
- 3. Irrelevant features hurt k-NN because…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 30 minUndergraduate students and practising engineers.Greedy search and interactions
Why forward selection misses XOR. If y = sign(ab), then a alone and b alone carry no information, so adding either one to the current set scores no better than adding a noise feature. Forward selection only finds the pair if it happens to add one half for another reason, and then the other half brings a big jump.
Why backward selection keeps it. With all features present, removing a or b destroys the interaction, so the score drops sharply, and the pair is never the cheapest thing to remove (until only the pair is left).
Exercise 1 (14 features: XOR pair 0–1, mean shifts 2–3, 10 noise features; n = 300; choose 4 features with 15-NN and 5-fold CV; 6 datasets).
| forward | backward | |
|---|---|---|
| XOR pair found | 1 of 6 | 6 of 6 |
| noise features chosen | 1.7 | 0.7 |
| test accuracy | 0.706 | 0.798 |
The true 4 features gave 0.818 and all 14 features 0.716. Forward selection usually took both shift features, then noise. Its one success came when it added half of the pair as a weak third feature. Its 4-feature model was no better than using everything.
Floating search. Sequential forward floating selection (SFFS; Pudil, Novovičová and Kittler, 1994) adds the best feature, then repeatedly removes a feature while that beats the best subset found so far of the smaller size. It corrects some greedy mistakes at a higher cost.
from sklearn.feature_selection import SequentialFeatureSelector
SequentialFeatureSelector(KNeighborsClassifier(15), n_features_to_select=4, direction="backward", cv=5)- 1. In exercise 1, forward selection found the XOR pair in…
- 2. Backward selection's test accuracy was…
- 3. SFFS improves greedy search by…
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.Theory and pitfalls
Greedy is not optimal. Cover and Van Campenhout (1977) showed that, for general distributions, the order of feature-subset quality can be arbitrary: the best pair need not contain the best single feature, and no sequential method is guaranteed to find the optimum. With a monotone criterion, branch and bound can find the exact optimum (Narendra and Fukunaga, 1977).
Overfitting the criterion. A wrapper compares many subsets with the same noisy CV estimate, so the subset it chooses is partly chosen for favourable noise. The reported CV score is then optimistic, and the effect grows with the number of candidates and shrinks with n (Reunanen, 2003). Nested cross-validation, or an untouched test set, gives the honest number.
Choosing between methods.
- Forward is cheaper for small target sizes and works when p > n.
- Backward handles interactions better but needs a model that can be fitted on all features.
- Both are expensive with slow models.
- Embedded methods (next topic) are often a cheaper alternative.
Interview questions.
- Why might backward selection fail when p > n? The full model may be unfittable or meaningless, and its CV scores are noisy, so early removals are poorly informed.
- How would you stop forward selection? Stop when the CV gain falls below a threshold, or within one standard error of the best score (the one-standard-error rule), choosing the smaller set.
- 1. Cover and Van Campenhout showed that…
- 2. A wrapper's own CV score is optimistic because…
- 3. The one-standard-error rule picks…
Level 4: Expert
★★★★★ Expert⏱ 25 minResearchers: original papers and open problems.How much does the wrapper fool itself?
History.
- T. Marill and D. Green (1963) introduced sequential backward elimination for pattern recognition.
- A. W. Whitney (1971) introduced forward selection.
- T. Cover and J. Van Campenhout (1977) proved that greedy selection has no general guarantee.
- P. Pudil, J. Novovičová and J. Kittler (1994) introduced floating search.
- R. Kohavi and G. John (1997) introduced the wrapper framework.
- J. Reunanen (2003) studied wrapper overfitting.
Exercise 2. Forward selection up to 6 features with 15-NN; the size with the best CV score is chosen. 4 datasets per setting.
| n | noise features | size chosen | CV accuracy | accuracy on fresh data | optimism | noise chosen | XOR pair found | true 4 features |
|---|---|---|---|---|---|---|---|---|
| 100 | 5 | 3.8 | 0.783 | 0.726 | +0.057 | 0.5 | 50% | 0.761 |
| 100 | 30 | 5.0 | 0.792 | 0.655 | +0.137 | 3.2 | 0% | 0.757 |
| 300 | 5 | 4.5 | 0.784 | 0.751 | +0.033 | 1.0 | 75% | 0.808 |
| 300 | 30 | 4.5 | 0.746 | 0.701 | +0.045 | 2.0 | 25% | 0.818 |
- The wrapper fooled itself badly with few samples and many candidates. At n = 100 with 30 noise features, its CV score (0.792) was higher than the true-feature model ever achieved, while its real accuracy was 0.655. It chose 3.2 noise features on average.
- More candidates made the XOR pair harder to find, because more noise features compete for the lucky early steps.
- More data reduced the optimism (from +0.137 to +0.045 with 30 noise features).
- With only 4 datasets per setting these figures are rough, but the direction matched the theory in every setting.
Sequential selection in AI, robotics and aerospace
- Sensor placement: choose which few accelerometers or thermocouples a model needs, evaluating each candidate set by validated predictive accuracy.
- Fault-signature design: pick a small set of features for an onboard classifier with strict compute limits.
- Lesson: always report a nested or held-out estimate. A wrapper’s own score on small flight-test datasets can be badly inflated.
References
- R. Kohavi, G. H. John (1997). “Wrappers for feature subset selection.” Artificial Intelligence 97.
- P. Pudil, J. Novovičová, J. Kittler (1994). “Floating search methods in feature selection.” Pattern Recognition Letters 15.
- T. M. Cover, J. M. Van Campenhout (1977). “On the possible orderings in the measurement selection problem.” IEEE Trans. SMC 7(9).
- J. Reunanen (2003). “Overfitting in making comparisons between variable selection methods.” JMLR 3.
- P. M. Narendra, K. Fukunaga (1977). “A branch and bound algorithm for feature subset selection.” IEEE Trans. Computers 26(9).