boruta_py icon indicating copy to clipboard operation
boruta_py copied to clipboard

Overwrites model's random state

Open MichaelRFox opened this issue 5 years ago • 2 comments

It seems that boruta passes RandomState(MT19937) to the model it is fitting regardless of the model's parameters. This doesn't bother a random forest model, but causes an xgBoost model to fail with the following error:

ValueError: Please check your X and y variable. The provided estimator cannot be fitted to your data. Invalid Parameter format for seed expect int but value='RandomState(MT19937)'

MichaelRFox avatar Nov 13 '19 19:11 MichaelRFox

Try changing line 283 in boruta/boruta_py.py to something like:

self.estimator.set_params(random_state=self.random_state.random_integers(1e9))

If you are concerned with the seed you could pass something nicer.. this is just a hack.

I'm not sure if this is the best way to do it but maybe boruta should instead of passing the seed object it should take a seeded integer like this so it's compatible with more models (xgboost). I would suggest it taking either a seed integer, or if it's a seed object to generate the first integer from that object.

DreHar avatar Nov 14 '19 22:11 DreHar

I kept wondering what I was doing wrong with using xgboost & boruta. I hope there is a fix soon.

sskarkhanis avatar Mar 26 '20 08:03 sskarkhanis