Skip to content

Boruta wrapper

fyt.wrappers.boruta_wrapper

BorutaPyWrapped

Bases: BorutaPy

A wrapper around BorutaPy to handle polars/pandas DataFrame input and output.

This wrapper extends BorutaPy to be compatible with scikit-learn pipelines and provides additional utility methods. Accepts polars DataFrames as input, converts internally to numpy for BorutaPy, and returns polars DataFrames as output.

The include_weak flag controls whether tentative (weak) features are kept, and is honored consistently by transform, get_support and get_feature_names_out so that they always agree.

__init__(estimator, n_estimators=1000, perc=100, alpha=0.05, two_step=True, max_iter=100, random_state=None, verbose=0, early_stopping=False, n_iter_no_change=20, include_weak=True)

Initialize the BorutaPyWrapped selector.

Parameters:

Name Type Description Default
estimator BaseEstimator

Supervised estimator with a feature_importances_ attribute.

required
n_estimators int | str

Number of estimators, or "auto" to determine automatically.

1000
perc int

Percentile of shadow feature importances used as threshold.

100
alpha float

Significance level for the two-sided tests.

0.05
two_step bool

Whether to use the two-step correction for multiple testing.

True
max_iter int

Maximum number of iterations to perform.

100
random_state int | RandomState | None

Random state for reproducibility.

None
verbose int

Verbosity level.

0
early_stopping bool

Whether to enable early stopping.

False
n_iter_no_change int

Iterations without change before early stopping.

20
include_weak bool

Whether tentative (weak) features are included by transform, get_support and get_feature_names_out.

True

get_feature_names_out(input_features=None)

Get the names of the selected features.

Honors self.include_weak via get_support so the returned names always match the columns produced by transform.

Parameters:

Name Type Description Default
input_features Sequence[str] | ndarray | None

Input feature names. If None, the names recorded at fit time are used, falling back to generated names ("x0", "x1", ...).

None

Returns:

Type Description
ndarray

Array of selected feature names.

get_support(indices=False)

Get a boolean mask or integer indices of the selected features.

Honors self.include_weak: when True, tentative (weak) features are reported as selected, matching the default transform behavior.

Parameters:

Name Type Description Default
indices bool

If True, return integer indices of selected features. If False, return boolean mask.

False

Returns:

Type Description
ndarray

Boolean mask or integer indices of selected features.

Raises:

Type Description
RuntimeError

If the selector has not been fitted yet.

set_output(*, transform=None)

Set output configuration for compatibility with sklearn pipelines.

Parameters:

Name Type Description Default
transform str | None

Output format for transform method. Not used in this wrapper.

None

Returns:

Name Type Description
BorutaPyWrapped BorutaPyWrapped

The selector itself.