You've got five candidate columns to predict a student's test score. One is a perfect predictor, one never changes at all, and the rest are somewhere in between. Which ones do you actually feed the model — and how do you decide without just guessing?
Toggle features on and off. Each one has a fixed score of its own — a rough measure of "how much does this feature, alone, explain the target" — and the total is just whatever you've switched on. Notice that classroom number contributes nothing no matter how many times you toggle it: every student sits in the same room, so it can't possibly explain who scores higher.
Two filter-method ideas, applied before any model ever sees the data:
- — one candidate feature (a column).
- — the variance of that feature across all rows; zero means the column is constant.
- — the target being predicted.
- — the Pearson correlation between the feature and the target, a number between and .
- score — the squared correlation (), a single-feature "how much does this explain" number that's always .
- Variance threshold: the free first pass
Before computing anything about the target, throw out any feature with zero (or near-zero) variance. A column that never changes literally cannot correlate with anything — there's nothing to compute.
- Correlation score: rank what's left
For every surviving feature, square its correlation with the target. Squaring does two things at once: it makes the score comparable across features regardless of whether the relationship is positive or negative, and it guarantees the score is never negative.
- Wrapper and embedded methods go further
Filter methods like these score each feature alone, one at a time. Wrapper methods (like recursive feature elimination) instead retrain a real model on different subsets and measure the subset's performance directly — slower, but it can catch redundancy that a per-feature score misses entirely.
The formula is now doing the counting: selectionScore sums over whatever's toggled on. Switch classroom number off — its variance is , so its score was always anyway, and the total doesn't move an inch. That's the variance-threshold filter paying for itself before you even look at the target.
Six students, target — deliberately exactly hoursStudied:
- A perfect predictor scores 1.0
hoursStudiedtracks exactly, so and — the maximum possible. - A useless feature scores 0, by definition
classroomNumberis the constant . Its variance is , so correlation is undefined by the usual formula — defined here as rather than left as an error, since a feature with no variance carries no information to score in the first place. - Everything else lands in between
shoeSizecorrelates weakly: , scoresleepHourscorrelates moderately: , scoreluckyNumberhappens to correlate negatively: , but squaring turns that into a positive score anyway, since a strong negative relationship is just as useful to a model as a strong positive one
- Summing every real feature gives the ceiling
Add up every feature except the useless one: . That's the highest total this toy score can reach — and it's exactly what the checkpoint below asks you to find.
Toggle features on and off until the total score reaches its maximum, 1.538. Hint: TARGET = 2 × hoursStudied exactly — one feature is worthless, four carry real signal.
Feature selection starts with the free wins — drop anything that never varies — then ranks what's left by how much it actually explains the target. This additive toy score ignores one real complication: two features that duplicate each other's information don't each deserve full credit, which is exactly what wrapper and embedded methods (recursive feature elimination, tree-based importance) are built to catch. The next chapter turns from which features to keep to how to search a model's own settings for the best configuration.