liveBook · Manning

Boruta

As explained in Machine Learning for Tabular Data: XGBoost, Deep Learning, and AI

Boruta is a feature-selection algorithm that identifies features relevant to a prediction task by comparing them with randomized shadow features.

Boruta selects features by comparing each feature’s model importance with the highest importance achieved by randomized shadow features. A feature earns a hit whenever it beats that shadow benchmark; a binomial significance test then supports retaining or rejecting it. section 6.2.2

Use Boruta when feature selection must identify all features that outperform random variation:

  • Choose a decision-tree ensemble, such as random forests, gradient boosting, XGBoost, or LightGBM, as the estimator. section 6.2.2
  • Transform the dataset first when using BorutaPy, because this implementation cannot work directly with pipelines. section 6.2.2
  • Fit Boruta, inspect its support mask, and map selected positions back to the transformed feature names. section 6.2.2

Airbnb NYC feature selection

For an Airbnb NYC classification task, BorutaPy with an XGBoost tree estimator selected transformed variables including room type, neighbourhood, minimum nights, reviews, host-listing count, and availability. A LightGBM run produced a smaller selected set, illustrating that selected features depend on the tree ensemble used. section 6.2.2

Listing 6.10 Boruta selection
from XGBoost import XGBClassifier
from boruta import BorutaPy
 
xgb = XGBClassifier(booster='gbtree', 
                    objective='reg:logistic', 
                    n_estimators=300, 
                    max_depth=4,
                    min_child_weight=3)
 
X = column_transform.fit_transform(data, target_median)                   #1
boruta_selector = BorutaPy(estimator=xgb, n_estimators='auto', verbose=2) #2
boruta_selector.fit(X, target_median)                                     #3
selected_features = boruta_selector.support_                              #4
selected_data = column_transform.get_feature_names_out()[selected_features]
print(selected_data)

Inspect the runnable BorutaPy workflow for transforming data, fitting an XGBoost estimator, reading the support mask, and printing selected feature names. section 6.2.2

How Machine Learning for Tabular Data: XGBoost, Deep Learning, and AI covers it

How deep it goes
Explains hits, binomial significance, fitting, and feature-name recovery, but stops short of broader implementation details.
Examples
Uses Airbnb NYC classification with XGBoost and contrasts its selected features with a LightGBM run.
What it assumes
Assumes model-importance awareness and tree-ensemble familiarity while defining shadow features and hits directly.
What you can do after
Apply BorutaPy to transformed tabular data and recover the feature names selected by a tree-based estimator.
How it connects
Connects feature selection with stability selection, feature importance, decision trees, gradient boosting, and pipelines.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Machine Learning for Tabular Data: XGBoost, Deep Learning, and AI. The section links point to the parts of the book it draws on.