Feature selection
More features are not better. Filters rank them cheaply; wrappers search for the combination that actually helps.
Adding a feature can never make a model more wrong on the training set — at worst an unhelpful coordinate gets weight near zero, and at worst it gets weight that happens to fit noise. The damage is on unseen data: irrelevant and redundant features inflate variance, slow training, and make the model harder to explain. Feature selection is the deliberate removal of that tax.
The workbench below makes the distinction concrete. A filter scores each feature independently against the target and takes the top — fast, but blind to redundancy, so it happily keeps three collinear charge variables. A wrapper evaluates subsets using the model's own score, so it notices that the third correlated feature adds nothing once its siblings are in.
Rank features by relevance (filter) or let a greedy search choose them (wrapper)
Filter
Ignore interactions — take the top-k by target correlation.
score = 0.769
Wrapper
Greedily add whichever feature most improves the redundancy-penalised score.
score = 0.000 · 0 features
The filter happily keeps three collinear charge variables; the wrapper tends to drop one of them because it adds little once a sibling is in. The relevance and correlation numbers are illustrative — on real data you would compute them and, for the wrapper, score with cross-validation rather than a closed-form proxy.
Relevance is not usefulness
A feature can be highly relevant on its own and still useless in a set, because another feature already carries the same information. Selection is therefore not ranking — it is choosing a combination, and the best combination depends on what is already chosen. That is why filter rankings and wrapper searches disagree, and why the disagreement is informative.
Filters: fast, model-free scores
A filter computes a statistic per feature and ranks. Common choices:
- Correlation for a numeric target, .
- Mutual information, which catches non-linear dependence that correlation misses:
- Variance / near-zero-constant filters that drop columns carrying almost no information on their own.
- or ANOVA F-scores for classification with categorical or continuous inputs respectively.
Filters are or and scale to millions of columns, which is why they are the first pass. Their limitation is structural: they never see a combination, so they cannot remove a feature that is redundant given others.
Wrappers: search, paying for it
A wrapper treats selection as a search problem over subsets and scores each candidate with cross-validated model performance. The three standard moves:
- Forward selection — start empty, greedily add the feature that improves the score most, stop when no addition helps.
- Backward elimination — start with everything, greedily remove the least useful feature.
- Recursive feature elimination (RFE) — repeatedly fit the model, drop the weakest features, refit.
With features the search space is , so exact best-subset is intractable; greedy methods are heuristics that are good enough in practice. Wrappers are expensive — each evaluation is a model fit — and they overfit the validation score if you are not careful about the split.
Embedded methods: selection during training
The third family lets the model decide as it fits. Lasso adds an penalty that drives coefficients exactly to zero, so the surviving non-zeros are a selection:
Tree ensembles give impurity- or permutation-based importance; dropout acts as a stochastic form of regularisation that discourages reliance on any single input. Embedded methods sit between filters and wrappers in cost and usually beat both in accuracy per unit of compute.
Careful
Select features using only the training data, inside the cross-validation loop. Ranking features on the full dataset and then cross-validating the selected model leaks the test rows into the choice and produces scores that do not survive contact with new data. The correct pattern is nested selection: choose features within each outer training fold.
Illustrative vs real
The relevance and correlation numbers in the artifact are hand-set to make redundancy visible; they are not estimated from data. The scoring function is a defined proxy, not a real cross-validated accuracy, and no learning algorithm is trained. Treat it as a demonstration of how filter and wrapper reasoning differ, not as a benchmark of either method.
Check yourself
Eduspheria wiki · Data, MLOps & Deployment, Features & recommenders
0 / 4 answered
From the exam paper
Modeled on NITJ AI-505, End-Sem December 2024
0 / 4 answered
Where next: recommendation systems — feature engineering and similarity combined to fill in the blanks of a ratings matrix.