scikit-learn-contrib / boruta_py

Python implementations of the Boruta all-relevant feature selection method.
BSD 3-Clause "New" or "Revised" License
1.46k stars 252 forks source link

Error when using BorutaPy with LogisticRegression #119

Open codewithawr opened 9 months ago

codewithawr commented 9 months ago

I encountered an error while using BorutaPy with a LogisticRegression model. The issue arises when setting the n_estimators parameter to 'auto' in BorutaPy. The LogisticRegression model does not have the n_estimators parameter, which causes a ValueError. My understanding is that BorutaPy is trying to provide specific arguments to the estimator model that are not present in the LogisticRegression model.

Steps to Reproduce: Install the necessary libraries:

Bash

pip install Boruta==0.3 scikit-learn==1.3.0 pandas==2.1.0

Python

from BorutaPy import BorutaPy
from sklearn.linear_model import LogisticRegression

# Assuming you have x_train_rfe and y_train defined
bl_model_ob = LogisticRegression(random_state=1)
boruta_selection = BorutaPy(bl_model_ob, n_estimators='auto', verbose=2, random_state=1)
boruta_selection.fit(x_train_rfe, y_train)

Behavior: Errore

--> 372     depth = self.estimator.get_params()['max_depth']
    373     if depth == None:
    374         depth = 10

KeyError: 'max_depth'

Additional Information:

Python Version: 3.9.12 Operating System: Windows