Foundations to Frontier
Tests
D. Classical Machine Learning › D16 Feature Selection Algorithms

Boruta

Boruta (Kursa and Rudnicki, 2010) is an all-relevant feature selection method built around random forests. It asks of each feature: is it more important than it would be by chance? To answer, it appends a shuffled copy, or shadow, of every feature, whose link to the target has been destroyed, fits a forest, and counts a hit for each real feature whose importance beats the best shadow. Repeating this many times and applying a binomial test sorts features into confirmed, rejected and tentative. Unlike minimal-optimal methods (RFE, lasso), Boruta keeps every feature that carries information, including redundant copies, which suits scientific questions about which variables matter. It inherits the biases of the importance measure it uses, and its decisions depend on the number of iterations and the multiple-testing correction. This page covers shadow features, the hit test and its Bonferroni threshold, all-relevant versus minimal-optimal selection, practical settings, and failure modes. In the exercises you implement Boruta on a numpy random forest, then show how fully grown trees make it reject a genuine binary feature.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Beat your own shadow

To test whether a candidate really knows the answers, compare them with someone guessing at random. Boruta builds a random guesser for every feature: a shadow copy with its values shuffled, so it has the same distribution but no link to the target. A feature that cannot reliably beat the best shadow is no better than chance.

Boruta: is each feature better than its own shuffled shadow?
strong linear20/20 hitsconfirmed
weak linear18/20 hitsconfirmed
|x| signal10/20 hitstentative
copy of strong20/20 hitsconfirmed
binary signal19/20 hitsconfirmed
noise 12/20 hitsrejected
noise 21/20 hitsrejected
noise 31/20 hitsrejected
The thin vertical line is the best shadow's importance in iteration 20. Strong signals beat it every time and are soon confirmed, and so is the redundant copy: Boruta looks for all relevant features, not a minimal set. Noise features rarely win and are rejected. Weak effects stay tentative until enough iterations accumulate. With leaf size 1, the shuffled continuous shadows collect lucky splits, and the genuine binary feature loses hits, often ending tentative or rejected. Larger leaves give it a fairer contest.
Why engineers care

In failure investigations and scientific studies the question is often “which variables matter at all?”, not “what is the smallest set that predicts well?”. Boruta answers the first question, keeping correlated measurements that all carry signal. It also gives an explicit rejection decision, with a statistical test, for variables that look no better than noise.

📝 Quick check (Level 0)
0/3 answered
  1. 1. A shadow feature is…
  2. 2. A real feature gets a hit when its importance…
  3. 3. Boruta aims to find…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

The algorithm by hand

One iteration.

  1. For each feature, make a shadow by shuffling its column.
  2. Fit a random forest on the real and shadow features together, and compute importances.
  3. Give each real feature a hit if its importance exceeds the maximum shadow importance. For real importances (0.30, 0.05, 0.12) and shadows (0.02, 0.10, 0.04), the max shadow is 0.10, so the hits are (1, 0, 1).

The test. If a feature were irrelevant, its chance of a hit in each iteration would be at most about ½. After N iterations the hit count is compared with Binomial(N, ½):

  • confirm if P(X ≥ hits) is below α/p;
  • reject if P(X ≤ hits) is below α/p;
  • otherwise the feature is tentative.

Dividing α by the number of features p is the Bonferroni correction.

Worked numbers. P(X ≥ 4) for N = 5 is 6/32. With p = 15 features and α = 0.05, the threshold is 0.0033, so confirmation needs 14 of 15 hits, 17 of 20, or 64 of 100. Few iterations leave many features tentative.

📝 Quick check (Level 1)
0/3 answered
  1. 1. Real (0.2, 0.08), shadows (0.05, 0.09): hits are…
  2. 2. Why compare with the maximum shadow?
  3. 3. More iterations make decisions…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 30 minUndergraduate students and practising engineers.

All-relevant, not minimal

Two goals.

  • Minimal-optimal selection (RFE, lasso) seeks the smallest set that predicts best. It drops a redundant copy once the original is in.
  • All-relevant selection (Boruta) keeps every feature that carries information about the target, including copies.

Exercise 1 (15 features: strong linear, weak linear, |x| signal, noisy copy of the strong feature, binary signal, 10 noise; n = 300; 20 iterations; forests of 20 trees with leaf size 5; 3 datasets).

feature hits (of 20) decision
strong linear 20, 20, 20 confirmed ×3
weak linear 13, 10, 12 tentative ×3
abs-value signal 19, 19, 17 confirmed ×3
copy of strong 20, 20, 20 confirmed ×3
binary signal 9, 16, 10 tentative ×3
noise (10 per dataset) at most 4 27 rejected, 3 tentative, 0 confirmed
  • The redundant copy was confirmed every time, which is the all-relevant behaviour.
  • The nonlinear signal was confirmed, because the forest captures it, unlike the lasso.
  • No noise feature was confirmed.
  • Weaker signals stayed tentative after 20 iterations. Their hit rates (50–80%) need more iterations to pass the strict corrected threshold.
from boruta import BorutaPy   # pip install Boruta
BorutaPy(RandomForestClassifier(max_depth=5), n_estimators="auto", max_iter=100).fit(X, y)
🐍 Exercise 1: Boruta
Implement Boruta: shadow features, forest impurity importance, hits against the best shadow, and a Bonferroni-corrected binomial test; check that it confirms a redundant copy and rejects noise.
📝 Quick check (Level 2)
0/3 answered
  1. 1. Boruta confirmed the redundant copy because it is…
  2. 2. In exercise 1, how many noise features were confirmed?
  3. 3. Weak signals stayed tentative mainly because…

Level 3: Advanced

★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.

Theory and caveats

Why shadows? Importance values have no natural scale: “0.03” may be large or small depending on the data and the forest. Shadows provide a reference distribution from the same data, for features with the same marginal distributions but no relation to the target.

Inherited biases. Boruta is only as fair as its importance measure.

  • With impurity (MDI) importance, continuous shadows find lucky splits in deep trees, so the max-shadow bar is high, and features with few split points (binary, low-cardinality) are disadvantaged.
  • With permutation importance (the original R package uses the forest’s mean decrease in accuracy), this bias is smaller.
  • Correlated relevant features share importance and may each fall below the bar.

Statistics. Hits in different iterations are not independent: the real feature’s data never change, so a noise feature that happens to correlate with y in this sample keeps winning. Boruta tests relevance in the sample, not in the population. The Bonferroni correction is conservative. BorutaPy also offers a two-step correction (Benjamini–Hochberg, then Bonferroni) and a percentile instead of the maximum shadow.

Interview questions.

  • Boruta or RFE? Boruta when you want every informative variable (science, root-cause analysis). RFE or lasso when you want a compact predictive model.
  • How do you handle tentative features? Run more iterations, use the rough fix (compare median importance with the median of the max shadow), or treat them as “possibly relevant” and investigate.
📝 Quick check (Level 3)
0/3 answered
  1. 1. Shadows supply…
  2. 2. Boruta with impurity importance disadvantages…
  3. 3. Hits across iterations are not independent because…

Level 4: Expert

★★★★★ Expert⏱ 25 minResearchers: original papers and open problems.

When Boruta rejects a real feature

History.

  • E. Tuv, A. Borisov, G. Runger and K. Torkkola (2009) used artificial contrast features for selection with tree ensembles.
  • M. Kursa and W. Rudnicki (2010) published Boruta for R.
  • D. Homola (2016) wrote BorutaPy for scikit-learn.

Exercise 2. Same features, n = 250, 15 iterations, forests of 20 trees, 3 datasets. Share of runs in which each feature was confirmed, then rejected:

feature leaf size 1 leaf size 20
strong linear 100%, 0% 100%, 0%
weak linear 33%, 0% 0%, 0%
abs-value signal 0%, 0% 0%, 0%
copy of strong 100%, 0% 100%, 0%
binary signal 33%, 67% 33%, 0%
noise (10 columns) 0%, 80% 0%, 77%
  • Fully grown trees made Boruta reject the real binary feature in 2 of 3 datasets: it was declared no better than noise. Its continuous shadows won the impurity contest through lucky small splits.
  • With leaf size 20 it was never rejected.
  • With only 15 iterations, the nonlinear and weak signals were never confirmed, since confirmation needs 14 of 15 hits. That is a matter of statistical power, not of irrelevance.
  • No noise feature was ever confirmed, so the test itself was conservative.
  • With 3 datasets these shares are coarse. The binary-feature effect matched the impurity bias seen in the previous topic.
🐍 Exercise 2 (research): leaf size and Boruta's verdicts
Run Boruta with forests of leaf size 1 and 20 and record how often each feature is confirmed or rejected, especially the binary signal.

Boruta in AI, robotics and aerospace

  • Root-cause analysis: find every process or environmental variable associated with a failure mode, not just a compact predictor.
  • Biomarker and materials discovery: list all measured properties related to an outcome, for follow-up experiments.
  • Guard rails: use permutation importance or limited tree depth, and check binary indicators by hand before dismissing them.

References

  1. M. B. Kursa, W. R. Rudnicki (2010). “Feature selection with the Boruta package.” Journal of Statistical Software 36(11).
  2. E. Tuv, A. Borisov, G. Runger, K. Torkkola (2009). “Feature selection with ensembles, artificial variables, and redundancy elimination.” JMLR 10.
  3. A.-C. Haury, P. Gestraud, J.-P. Vert (2011). “The influence of feature selection methods on accuracy, stability and interpretability of molecular signatures.” PLoS ONE 6(12).
  4. C. Strobl, A.-L. Boulesteix, A. Zeileis, T. Hothorn (2007). “Bias in random forest variable importance measures.” BMC Bioinformatics 8.