Skip to content

Commit 855c4c9

Browse files
authored
Unknown type of parameter:random_state, got:RandomState (#78)
* Update boruta_py.py remove check_random_state function for LightGBM and XGBoost to work * Update boruta_py.py additional control for random_state * Update boruta_py.py restoring original self.random_state = check_random_state(self.random_state) * Update boruta_py.py final fix for random_state problem with XGBoost and LightGBM * Update boruta_py.py fixed error message to original * adding __version__ method * updating estimator if a lightgbm, otherwise leaving it as it is * removing _is_lightgbm function
1 parent 6383ca3 commit 855c4c9

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

boruta/boruta_py.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ def __init__(self, estimator, n_estimators=1000, perc=100, alpha=0.05,
184184
self.max_iter = max_iter
185185
self.random_state = random_state
186186
self.verbose = verbose
187+
self.__version__ = '0.3'
188+
self._is_lightgbm = 'lightgbm' in str(type(self.estimator))
187189

188190
def fit(self, X, y):
189191
"""
@@ -301,7 +303,10 @@ def _fit(self, X, y):
301303
self.estimator.set_params(n_estimators=n_tree)
302304

303305
# make sure we start with a new tree in each iteration
304-
self.estimator.set_params(random_state=self.random_state)
306+
if self.is_lgb:
307+
self.estimator.set_params(random_state=self.random_state.randint(0, 10000))
308+
else:
309+
self.estimator.set_params(random_state=self.random_state)
305310

306311
# add shadow attributes, shuffle them and train estimator, get imps
307312
cur_imp = self._add_shadows_get_imps(X, y, dec_reg)

0 commit comments

Comments
 (0)