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

HistGradientBoostingClassifier not working #84

Open ciberger opened 3 years ago

ciberger commented 3 years ago

Hi 👋

in the documentation says boruta implements all scikit-learn ensemble methods, but it doesn't work with HistGradientBoostingClassifier. Other methods described on the ensemble documentation (such as adaboost and gradient tree boosting) work as expected.

Thanks

Reprex

from boruta import BorutaPy

from sklearn.experimental import enable_hist_gradient_boosting
from sklearn.ensemble import HistGradientBoostingClassifier

clf = HistGradientBoostingClassifier()

boruta = BorutaPy(
   estimator=clf, 
   n_estimators='auto',
   max_iter=10)

boruta.fit(np.array(X_train), np.array(y_train))

Error message

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
 in 
---> 18 boruta.fit(np.array(X_train), np.array(y_train))

~/.pyenv/versions/python-3.7.4/lib/python3.7/site-packages/boruta/boruta_py.py in fit(self, X, y)
    199         """
    200 
--> 201         return self._fit(X, y)
    202 
    203     def transform(self, X, weak=False):

~/.pyenv/versions/python-3.7.4/lib/python3.7/site-packages/boruta/boruta_py.py in _fit(self, X, y)
    268         # set n_estimators
    269         if self.n_estimators != 'auto':
--> 270             self.estimator.set_params(n_estimators=self.n_estimators)
    271 
    272         # main feature selection loop

~/.pyenv/versions/python-3.7.4/lib/python3.7/site-packages/sklearn/base.py in set_params(self, **params)
    250                                  'Check the list of available parameters '
    251                                  'with `estimator.get_params().keys()`.' %
--> 252                                  (key, self))
    253 
    254             if delim:

ValueError: Invalid parameter n_estimators for estimator HistGradientBoostingClassifier(). Check the list of available parameters with `estimator.get_params().keys()`.
WhiteLedAnn commented 1 year ago

Also 'HistGradientBoostingClassifier' object has no attribute 'tree_'

WhiteLedAnn commented 1 year ago

Also they say : "we use max_iter instead n_estimators" but i dont get how can I receive my list of trees by int number of iterations