Boruta-Py is a Python implementation of the Boruta all-relevant feature selection algorithm, originally developed in R. It helps identify all features that are relevant to a prediction task, rather than just a minimal optimal subset. The library follows a scikit-learn-like interface, allowing seamless integration into existing machine learning workflows. As of version 0.4.3, the library is actively maintained with periodic releases addressing community-reported issues.
pip install BorutaVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to use `BorutaPy` for feature selection with a `RandomForestClassifier`. It loads the breast cancer dataset, initializes a classifier and `BorutaPy` selector, fits the selector to the data, and then prints the selected features and the transformed dataset. It explicitly converts data to NumPy arrays as required by `BorutaPy`.
Always convert Pandas DataFrames to NumPy arrays before passing them to `BorutaPy.fit()` or `transform()`: `X.values`, `y.values`.
Upgrade to Boruta-Py version 0.4.0 or newer. If issues persist, consider downgrading NumPy to <1.24 (e.g., 1.23.1) or Python to <3.11, though this is less ideal than upgrading Boruta-Py itself.
Ensure your base estimator is tree-based (e.g., `RandomForestClassifier`, `ExtraTreesClassifier`) when using `n_estimators='auto'`. For non-tree estimators, explicitly set `n_estimators` to an integer value in `BorutaPy` and consider if Boruta is the appropriate method.
Start with a smaller subset of data, consider reducing `max_iter`, or tune the base estimator's parameters (e.g., `max_depth` between 3-7 for `RandomForestClassifier` as recommended by the author) for faster execution during prototyping.
Convert DataFrames to NumPy arrays using the `.values` attribute: `feat_selector.fit(X.values, y.values)`.
Upgrade Boruta-Py to version 0.4.0 or higher. If the problem persists, temporarily downgrade NumPy to a compatible version (e.g., `pip install numpy==1.23.1`).
Ensure the `estimator` passed to `BorutaPy` is a tree-based model (e.g., `RandomForestClassifier`, `ExtraTreesClassifier`). If using a non-tree model, provide an integer value for `n_estimators` instead of `'auto'`.