boruta-fru api¶
- class boruta_fru.boruta.Boruta(max_runs=100, trees=500, tries=None, impute=True, seed=None, threads=None)[source]¶
Bases:
objectBoruta [1] model used for the feature selection.
- Parameters:
max_runs (int) – Maximum number of model iterations. If all features are resolved as confirmed or rejected, the model will stop early. If there are tentative features remaining, consider increasing this parameter. Defaults to 100.
trees (int) – Number of trees to grow in the forest (often called
ntreein other software). Must be greater than zero. The value should be large enough to provide stable results (prediction accuracy or importance). Larger datasets typically require more trees. Computation time grows linearly with the number of trees. Defaults to 500.tries (int | None) – Number of features to try at each split (often called
mtry). Must be greater than zero and less than or equal to the number of features. By default, it is set to the rounded square root of the number of features. Higher values increase correlation between trees. In most cases, the default setting is recommended.impute (bool) – Controls how missing values are handled. If
True, missing values are imputed by randomly sampling (with replacement) from the non-null values in the same column. Imputation is performed before each run of the forest, so sampled values may differ between runs. IfFalse, the presence of any missing values will raise an error. An all-null column will be converted to a boolean column with false values, which should be ok as a totally non-informative value with most methods, but it is not universally correct. Ideally, one should avoid having such features in input altogether.seed (int | None) – Seed used by the algorithm. Set to
Noneto use a random seed.threads (int | None) – Number of threads to use. Must be greater than zero. If
None, all available CPU cores are used. Defaults toNone.
Notes
Boruta iteratively compares importances of attributes with importances of shadow attributes, created by shuffling original ones. Attributes that have significantly worst importance than shadow ones are being consecutively dropped. On the other hand, attributes that are significantly better than shadows are admitted to be Confirmed. Shadows are re-created in each iteration. Algorithm stops when only Confirmed attributes are left, or when it reaches max_runs importance source runs. If the second scenario occurs, some attributes may be left without a decision. They are claimed Tentative.
References
- final_decision(to_pycapsule=False)[source]¶
Final decision of the model. For each feature can be either:
Confirmed,Rejected, orTentative.- Parameters:
to_pycapsule (bool) – If
True, results are returned as an Arrow PyCapsule. IfFalse, results are returned as NumPy arrays, similar to scikit-learn. Defaults toFalse.
- fit(X, y)[source]¶
Runs Boruta feature selection.
- Parameters:
X (Arrow PyCapsule) – A DataFrame-like object supporting the Arrow PyCapsule interface. Any library supporting this interface can be used (e.g., pandas, polars). Columns can be boolean, numerical, or categorical. Mixed column types are allowed. Other data types are not supported and will raise an exception.
NaNvalues are not allowed.y (Arrow PyCapsule) – A Series-like object supporting the Arrow PyCapsule interface. Any library supporting this interface can be used. For classification,
ymust be categorical, otherwise an exception is raised.NaNvalues are not allowed. The length ofymust match the number of rows inX.