Inferensys

Glossary

Recursive Feature Elimination (RFE)

A wrapper method that recursively removes the least important features based on a model's coefficient weights or feature importance scores to find the optimal subset.
Data engineer managing feature store on laptop, feature definitions visible, casual data engineering session.
WRAPPER METHOD

What is Recursive Feature Elimination (RFE)?

A backward feature selection algorithm that iteratively trains a model, ranks features by importance, and prunes the least significant ones to find an optimal predictive subset.

Recursive Feature Elimination (RFE) is a wrapper-based feature selection algorithm that searches for an optimal subset of features by recursively considering smaller and smaller sets. The process begins by training an estimator on the initial set of features, obtaining a measure of importance for each one—either through coef_ or feature_importances_ attributes. The least important features are then pruned from the current set, and the procedure is recursively repeated on the remaining features until the desired number is reached.

The estimator used within the RFE core must expose feature importance scores; support vector machines with linear kernels and random forests are common choices. A critical variant, RFECV, integrates cross-validation into the loop to automatically determine the optimal number of features by selecting the subset size that minimizes the validation error, eliminating the need to manually specify the final feature count.

WRAPPER METHOD

Key Characteristics of RFE

Recursive Feature Elimination (RFE) is a greedy optimization algorithm that searches for the optimal subset of features by iteratively training a model and pruning the weakest performers.

01

Backward Elimination Core Loop

RFE operates through a recursive pruning process that systematically removes the least informative features. The algorithm:

  • Trains the chosen estimator on the current feature set
  • Ranks features by importance via coefficient weights or feature importance scores
  • Eliminates the lowest-ranked feature or a specified step size of features
  • Repeats on the reduced set until the desired number of features remains This wrapper approach evaluates feature subsets in the context of the specific model, capturing feature interactions that filter methods miss.
02

Model-Dependent Ranking Criterion

The elimination order depends entirely on the base estimator's intrinsic importance metric:

  • Linear models: Absolute coefficient magnitudes (|w_i|) from coef_
  • Tree-based models: Gini importance or mean decrease in impurity from feature_importances_
  • SVM with linear kernel: Squared coefficient weights from the separating hyperplane
  • Any model with a coef_ or feature_importances_ attribute can serve as the RFE estimator This tight coupling means RFE inherits the biases of the underlying model—a linear estimator will miss non-linear relationships.
03

Cross-Validated Variant (RFECV)

RFECV extends standard RFE by automatically determining the optimal number of features through cross-validation:

  • Performs RFE to generate ranked feature subsets of all possible sizes
  • Evaluates each subset size using k-fold cross-validation on the training data
  • Selects the smallest feature set within one standard error of the peak performance score
  • Eliminates the need to manually specify n_features_to_select This variant guards against overfitting by balancing predictive performance with model parsimony, making it essential for high-dimensional biomarker discovery.
04

Step Size and Computational Trade-offs

The step parameter controls how many features are removed per iteration, creating a speed-accuracy trade-off:

  • step=1: Exhaustive search removing one feature at a time—most precise but computationally expensive for high-dimensional data (O(n_features²) model fits)
  • step > 1: Removes multiple features per iteration—faster but risks eliminating correlated features that are individually weak but jointly informative
  • step as float (0.0–1.0): Removes a percentage of remaining features per iteration, accelerating convergence on wide datasets For genomic datasets with 10,000+ features, a larger step size or a pre-filtering stage is often necessary.
05

Correlated Feature Instability

RFE exhibits selection instability when features are highly correlated, a common scenario in biomarker identification:

  • Two perfectly correlated predictors will have arbitrary ranking order, as removing one leaves the other to capture the full effect
  • Small data perturbations can cause dramatic reordering of correlated feature groups
  • The final subset may exclude biologically relevant markers simply because a correlated proxy was retained Mitigation strategies include using stability selection wrappers, applying RFECV with multiple random seeds, or pre-clustering correlated features before elimination.
06

Practical Implementation in scikit-learn

The sklearn.feature_selection module provides two primary classes:

  • RFE(estimator, n_features_to_select): Basic recursive elimination with manual specification of the target feature count
  • RFECV(estimator, cv, scoring): Cross-validated variant that automatically selects the optimal subset size Key attributes after fitting include:
  • ranking_: Integer rank for each feature (1 = selected, higher = eliminated earlier)
  • support_: Boolean mask of selected features
  • grid_scores_ (RFECV only): Cross-validation scores for each subset size For biomarker discovery workflows, RFECV with a linear SVM or random forest is a common starting point.
RECURSIVE FEATURE ELIMINATION

Frequently Asked Questions

Clear, technically precise answers to the most common questions about implementing and interpreting Recursive Feature Elimination for high-dimensional biomarker discovery.

Recursive Feature Elimination (RFE) is a wrapper-type feature selection algorithm that iteratively removes the least important features from a dataset to identify the optimal subset for a given predictive model. The algorithm operates by first training an estimator—such as a support vector machine, random forest, or logistic regression model—on the full feature set. It then ranks features by their importance scores, which are derived from coefficient magnitudes in linear models or Gini importance in tree-based models. At each iteration, the least important feature or a predefined step size of features is pruned. The model is retrained on the reduced feature set, and the process repeats recursively until the desired number of features remains. The final output is a ranked list of all features and a selected subset that maximizes cross-validated performance. Unlike filter methods that evaluate features independently of the model, RFE's wrapper approach captures feature interactions and multivariate effects, making it particularly effective for biomarker panels where synergistic relationships between analytes matter. However, this model-dependence also means RFE is computationally expensive, scaling with O(n_features * model_training_time), and the selected subset is specific to the estimator used.

COMPARATIVE ANALYSIS

RFE vs. Other Feature Selection Methods

A systematic comparison of Recursive Feature Elimination against widely used alternative feature selection techniques for high-dimensional biomarker data.

FeatureRFELASSO (L1)BorutamRMR

Selection Approach

Wrapper (model-dependent)

Embedded (regularization)

Wrapper (ensemble-based)

Filter (information theory)

Handles Multicollinearity

Moderate (ranks correlated features)

Selects one, zeros others

Explicitly minimizes redundancy

Provides Feature Rankings

By coefficient magnitude

By relevance-redundancy score

Computational Cost (p=10,000)

High (O(p²) worst case)

Low (convex optimization)

Very High (shadow features)

Low (pairwise mutual info)

Optimal Subset Guarantee

Sparse solution (convex)

All-relevant set

Ranked list, no subset

Model Agnostic

Yes (any importance scorer)

Linear models only

Random forest only

Typical Use Case

Small-n, large-p biomarker discovery

Sparse linear biomarker panels

Confirming all relevant biomarkers

Pre-filtering for downstream models

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.