Recursive Feature Elimination (RFE) and Feature Importance

In machine learning, feature selection plays a crucial role in improving model performance, reducing overfitting, and enhancing interpretability. Two popular techniques for feature selection are Recursive Feature Elimination (RFE) and Feature Importance.

Recursive Feature Elimination (RFE)

Recursive Feature Elimination is a recursive technique that aims to identify the most important features by recursively eliminating or ranking less important features based on the model's performance. RFE starts by training a model on the entire feature set and ranks the features based on their importance. Then, it removes the least important feature, retrains the model, and continues this process until a specified number of features remains.

The primary benefit of RFE is that it considers the interactions between features while selecting them. By recursively eliminating features, RFE helps in finding a subset of features that individually and collectively contribute the most to the model's predictive power.

To apply RFE, one needs to follow these steps:

  1. Choose a machine learning model to use for feature selection.
  2. Specify the desired number of features to select.
  3. Instantiate the RFE object, providing the chosen model and desired number of features.
  4. Fit the RFE object to the training data using the fit() method.
  5. Extract the selected features using the support_ attribute of the RFE object.

RFE is implemented in the popular Python library Scikit-Learn, providing an easy and efficient way to perform feature selection.

Feature Importance

Feature Importance is another technique for feature selection, which quantifies the importance or relevance of each feature in the target variable prediction. This technique provides a numerical score representing each feature's importance, allowing you to filter out less relevant features.

The feature importance scores can be obtained through various algorithms such as decision trees, random forests, or gradient boosting. These algorithms provide a measure of how much each feature contributes to reducing the impurity or error metric in the model.

Once the feature importance scores are obtained, you can select the top-k features based on their scores or set a threshold to include only the features with scores above a certain value. This way, you retain the most important features and discard the less influential ones.

The Scikit-Learn library provides a unified interface to calculate feature importance for different algorithms. For example, in Random Forests, you can use the feature_importances_ attribute to access the feature importance scores.


Recursive Feature Elimination (RFE) and Feature Importance are powerful techniques for feature selection in machine learning. They help in identifying the most relevant features, improving model performance, and reducing overfitting.

RFE takes into account feature interactions while recursively eliminating less important features. On the other hand, Feature Importance assigns a numerical score to each feature, allowing you to filter out the less important ones.

Both techniques are readily implemented in the Scikit-Learn library, providing a user-friendly and efficient way to perform feature selection. By utilizing these techniques, you can enhance your models' efficiency, interpretability, and generalization capabilities.

noob to master © copyleft