Concepts / Model-Based Selection

Model-Based Selection

RFE depends on the selecting model being able to determine feature importance, the same requirement seen in model-based selection.

  • Programming

A Feature Choice That Depends on Who Decides

Suppose you have a table with many candidate columns and you want to train a model on only the most useful ones. Some columns carry real signal about the target, while others add noise, cost time, or make the model harder to interpret. Choosing which columns to keep is called feature selection. This article focuses on one family of approaches, model-based selection, and on a particular kind of it that repeats the process many times. The central idea is that the decision about which features matter is handed to a model, and the model's own view of feature importance guides the choice.

What do you think happens?

In recursive feature elimination, which feature is discarded at each round?

  • The feature with the highest importance score

  • The feature with the least importance score

  • A feature chosen at random

  • The feature with the largest number of missing values

Reveal answer
Answer:

The feature with the least importance score

RFE starts with all features, builds a model, discards the least important feature, and rebuilds. The importance scores come from the model itself, so the model's ranking decides what gets removed.

Three Ways to Pick Features

Earlier methods for choosing features took one of two shapes. Univariate testing looks at each feature on its own, without using any model. Model-based selection trains one model and uses it to decide which features to keep. In both cases, the selection decision comes from a single pass over the data. Iterative feature selection asks a different question. Instead of making one decision, it builds a whole series of models, and each model in the series uses a different number of features. The selection process moves through that series, using what each model reveals to guide the next step.

Each feature scoredaloneNo model usedOne model trainedImportance used onceSeries of modelsEach round guides thenext
How the three approaches differ in what they evaluate: each feature alone, one model's output once, or repeated models on changing subsets of features

The practical difference is in what the final choice is based on. A univariate test judges each column in isolation, so it cannot see how two columns work together inside a model. A single model-based selection uses one model's view of importance, but that view is taken once, from one set of inputs. An iterative method revisits the question several times, each time with a smaller or larger set of features, so the final subset reflects what the model reveals as the feature set changes.

Two Directions of Iterative Selection

Iterative feature selection has two basic methods. They start from opposite ends of the feature set and move toward a smaller or larger subset, depending on the method. Both continue building models until a stopping criterion is reached. The choice between them determines where the search begins. The diagram below shows how the feature set changes at each step in each direction.

No featuresOne feature addedTwo features addedStopping criterionmetAll featuresOne feature removedTwo features removedStopping criterionmetadd a featureadd a featurestopremove a featureremove a featurestop
How the feature set changes at each step in forward selection compared with backward elimination, and where each process starts and stops

Tracing Recursive Feature Elimination

RFE is easiest to understand by following a single run. The loop below shows one round: the current features are used to train a model, the model's importance scores are used to choose a feature to discard, and the reduced set becomes the input to the next round. The output of each model is not the end of the process. Its importance scores feed a decision that changes the feature set, and the changed set feeds the next model.

Current feature setTrain model on setImportance scoresDiscard leastimportantTarget count reached?Final feature setfeatures inmodel ranks inputslowest scoresmaller setno, repeatyes
What happens in each round of RFE: which features the model trains on, which one is removed, and how the set shrinks until the target count remains
Worked example

Removing features from five down to two

A dataset has five features: Age, Income, Zip, Tenure, and Clicks. Run RFE with a target of two remaining features. The importance values below are illustrative numbers invented for this example, not output from a real model.

  1. 1
    Round 1: start with all five features

    Train a model on Age, Income, Zip, Tenure, and Clicks. Suppose its importance scores are Age 0.10, Income 0.35, Zip 0.05, Tenure 0.30, and Clicks 0.20. The least important feature is Zip at 0.05, so Zip is discarded. Four features remain.

  2. 2
    Round 2: rebuild on the four remaining features

    RFE does not reuse the old scores. It trains a fresh model on Age, Income, Tenure, and Clicks. Suppose the new scores are Age 0.15, Income 0.40, Tenure 0.25, and Clicks 0.20. Age, which scored 0.10 with five companions, now scores 0.15, but it is still the least important, so Age is discarded. Three features remain.

  3. 3
    Round 3: check the target and decide

    Three features remain and the target is two, so another round is needed. Train on Income, Tenure, and Clicks. Suppose the scores are Income 0.45, Tenure 0.35, and Clicks 0.20. Clicks is the least important and is discarded. Two features remain, which equals the target, so the loop stops.

  4. 4
    Result: the selected subset

    The final feature set is Income and Tenure. Notice that the removal order was Zip, then Age, then Clicks. Each removal came from a model trained on the set that existed at that moment.

Result

RFE returned Income and Tenure after three rounds, discarding Zip, Age, and Clicks in that order.

The example also shows why RFE rebuilds the model at every round instead of ranking everything once. Each round built a fresh model on a smaller set, so importance scores can change as features are removed. A feature that looked weak with five companions may look different once others are gone.

Why the Selecting Model Must Rank Features

RFE can discard the least important feature only if the model can say which features are important. The source states that RFE depends on the selecting model being able to determine feature importance, which is the same requirement seen in model-based selection. A model that cannot rank its inputs gives RFE nothing to act on. The choice of model is therefore part of designing the method. The source's example uses a random forest model, the same model used earlier in the discussion of model-based selection. The selection is only as informed as the importance measure the model provides.

Why Iterative Methods Cost More

Because iterative methods build a series of models, they are much more computationally expensive than the methods discussed earlier. A univariate test may examine each feature once. A single model-based selection trains one model. An iterative method trains many models, and each one must be fit before the search can decide what to do next. The total work grows with the number of models in the series, not with a single training run.

In the five-feature example above, RFE trained three models: one on five features, one on four, and one on three. A method that removes one feature per round and stops at two remaining features needs a model fit for each size between the starting count and the target. As the feature count and the number of rounds grow, the number of fits grows with them, and each fit must finish before the next decision can be made.

Mistakes With Iterative Selection

  • Common mistake

    Treating RFE as a single ranking

    Why it fails

    RFE rebuilds the model each round on the smaller set, so importance scores can change as features are removed.

    Do this instead

    Think of RFE as a sequence of rankings, one per round, each computed on the set that remains.

  • Common mistake

    Using a model that cannot rank features

    Why it fails

    RFE needs importance scores to choose what to discard. Without them, the removal step has nothing to act on.

    Do this instead

    Confirm that the selecting model provides a way to determine feature importance before building the loop.

  • Common mistake

    Assuming the two directions always give the same answer

    Why it fails

    Forward selection starts from no features and grows the set, while backward elimination starts from all features and shrinks it. Each direction explores a different path through the series of models.

    Do this instead

    Pick a direction deliberately and recognize that the starting point shapes the search.

  • Common mistake

    Ignoring the cost of repeated model fits when the feature count is large

Tracing a Round on Your Own

EASY

A dataset has four features: Height, Weight, Shoe size, and Hours of sleep. You run RFE with a target of two remaining features. In round 1, a model trained on all four gives these importance scores: Height 0.30, Weight 0.40, Shoe size 0.05, Hours of sleep 0.25. Which feature is discarded in round 1, and how many features remain? Then describe what round 2 must do before deciding what to discard next.

Hints
  • RFE discards the feature with the least importance score in each round.
  • Count how many features remain after one discard and compare that to the target of two.
  • Round 2 uses a freshly trained model on the features that remain, not the old scores.

Key Takeaways

  • Iterative feature selection builds a series of models with different numbers of features, rather than making one decision from a single pass as univariate testing and single-model selection do.
  • The two basic directions start from opposite ends: forward selection adds features from none, and backward elimination removes them from all, each until a stopping criterion is reached.
  • Recursive feature elimination starts with all features, trains a model, discards the least important feature, and rebuilds until a prespecified number of features remain.
  • RFE needs the selecting model to determine feature importance, so the model choice is part of the method and the selection is only as informed as that importance measure.
  • Iterative methods are more expensive because they train many models, and total work grows with the number of models in the series.

Related concepts

More concepts starting with M