You have 50,000 features and 100,000 rows. How do you choose features with filter, wrapper, and embedded methods, and when does feature selection itself leak?

The Problem: A 100,000 by 50,000 training matrix with a label column, a block of near-copy columns, and a holdout band. Most columns are noise, and whatever procedure picks the columns must still be scored honestly.
Answer
With 50,000 features and 100,000 rows, no single method fits, so run a cost-ordered funnel in which each stage only scores what the cheaper stage kept. Filter scores such as mutual information, chi-squared, or correlation with a false-discovery cutoff cut 50,000 columns to a few thousand in minutes, but they judge each feature alone. Embedded methods such as an L1 path or gradient-boosted importance, repeated under stability selection, then choose a few hundred features jointly. A wrapper such as RFE with cross-validation is affordable only on that short list, because forward selection over all 50,000 columns would need millions of model fits. Selection leaks whenever a label-reading step sees rows that later score the model, so the whole funnel must be refit inside every training fold and the holdout must never touch it.
(1) Filter First: Univariate scores (MI, chi-squared, ANOVA F, correlation) cost and parallelize across columns, but they miss interactions and keep redundant copies. At
, 50,000 tests produce about 2,500 false hits by chance, so cut with Benjamini-Hochberg.
(2) Embedded Second: L1-penalized models and tree importances select features jointly for roughly the price of one model fit. The lasso keeps an arbitrary member of a correlated group, and impurity importance favors high-cardinality columns.
(3) Wrapper Last: RFE and forward or backward search score the real model, so they catch interactions, but cost grows with features times refits. Dropping 10% per round takes 300 features to 80 in about 13 refits.
(4) Stability Beats a Single Ranking: Refitting on 100 random half-samples and keeping features chosen at least 80% of the time puts a hard bound on the expected number of false selections.
(5) Permutation Beats Impurity: Measure importance as the held-out score drop when a column is shuffled, and shuffle near-duplicates together so credit is not split between them.
(6) Selection Is Training: Any step that reads belongs inside the cross-validation pipeline, and choosing
with the same CV that reports the score requires nested CV.

Figure 1: The selection funnel. Label-free hygiene runs once, while the filter, embedded, and wrapper stages sit inside the dashed box and are refit on every training fold. Counts are typical for a wide tabular dataset, and the untouched holdout scores the finished funnel exactly once.
The funnel shape follows from cost. Label-free hygiene (constant columns, exact duplicates, columns over 95% missing) never reads the label, so running it once on all rows is nearly harmless, and on wide tabular data it often trims the 50,000 columns to roughly 38,000. Every stage after that reads , which makes it a fitted transform exactly like a model: fit it on the training fold, apply it to the validation fold. In scikit-learn terms the selector lives inside the
Pipeline handed to the cross-validator, not in a preprocessing script that runs before the split. With the problem is wide but not hopeless, so a regularized model could train on everything; selection here is mostly about serving cost, interpretability, and stability, which is why the funnel should optimize recall early and precision late.
Mathematical Formulation:
Where:
is the mutual information between feature
and label
, with joint
and marginals
,
. It is zero only under independence, so unlike correlation it also detects nonlinear dependence.
are the coefficients of an L1-penalized model over
rows
,
is the log-loss, and
sets sparsity: a larger
drives more coefficients to exactly zero.
is the permutation importance of feature
: the score
(for example AUC) of fitted model
on held-out data
, minus the average score after shuffling column
, written
.
is the selection frequency of feature
across
random half-samples
, and
is the set selected on subsample
at penalty
.
is the number of noise features that survive,
is the average number selected per subsample,
is the frequency threshold, and
is the total feature count; the bound assumes noise features are exchangeable.
Worked Leakage Example:
Make every one of the 50,000 features pure noise, rank them by absolute correlation with on all 100,000 rows, keep the top
, and only then run 5-fold CV with OLS. A kept feature has
, so its expected squared correlation is about
, and because selection used every row, the validation folds share that spurious correlation.
Here is the selected set,
the full-data correlation of feature
, and
the training-fold size. The leaky pipeline reports an
of about 0.036 on a target nothing can predict, while selecting inside each fold reports about
, the honest answer.
| Property | Filter | Embedded | Wrapper |
|---|---|---|---|
| What it scores | Each feature alone against the label (MI, chi-squared, F, correlation) | Features jointly, as a side effect of fitting (L1 zeros, tree gain) | Candidate subsets by the real model’s validation score |
| Cost at 50,000 features | One pass per column; seconds to minutes | About one model fit, times B under stability selection | Infeasible on all columns; forward search needs millions of fits |
| Interactions and redundancy | Blind to both; keeps every copy of a duplicated signal | Trees see interactions; lasso drops redundant copies arbitrarily | Sees both, through the model it wraps |
| Main bias or risk | Multiple testing: thousands of chance hits without FDR control | Unstable on correlated groups; impurity importance favors high cardinality | Overfits the validation score after searching many subsets |
| Role in the funnel | First: generous threshold, optimize recall | Second: joint pruning to a few hundred, stabilized | Last: fine pruning on the short list |
Leave a Reply