Commits


Lukas Pfannschmidt authored and GitHub committed cf0a992eda6
[python] handle RandomState object in Scikit-learn Api (#2904) * Add handling of RandomState object, which is standard for sklearn methods. LightGBM expects an integer seed instead of an object. If passed object is RandomState, we choose random integer based on its state to seed the underlying low level code. While chosen random integer is only in the range between 1 and 1e10 I expect it to have enough entropy (?) to not matter in practice. * Add RandomState object to random_state docstring. * remove blank line * Use property to handle setting random_state. This enables setting cloned estimators with the set_params method in sklearn. * Add docstring to attribute. * Fix and simplify docstring. * Add test case. * Use maximal int for datatype in seed derivation. * Replace random_state property with interfacing in fit method. Derives int seed for C code only when fitting and keeps RandomState object as param. * Adapt unit test to property change. * Extended test case and docstring Co-Authored-By: Nikita Titov <nekit94-08@mail.ru> * Add more equality checks (feature importance, best iteration/score). * Add equality comparison of boosters represented by strings. Remove useless best_iteration_ comparison (we do not use early_stopping). * fix whitespace * Test if two subsequent fits produce different models * Apply suggestions from code review Co-Authored-By: Nikita Titov <nekit94-08@mail.ru> Co-authored-by: Nikita Titov <nekit94-08@mail.ru>