rodrigo-arenas / Sklearn-genetic-opt

ML hyperparameters tuning and features selection, using evolutionary algorithms.
https://sklearn-genetic-opt.readthedocs.io
MIT License
289 stars 73 forks source link

[Enhancement] Base class for Callbacks #10

Closed rodrigo-arenas closed 3 years ago

rodrigo-arenas commented 3 years ago

Is your feature request related to a problem? Please describe. Currently the .fit method of GASearchCV accepts a callbacks argument, this is used to stop the training process when a condition is met. All the callbacks implements the same methods: .on_step and __call__ which are used while the optimization routine is running. Currently, each callback does not have any kind of inheritance from a base class that ensures that all the objects have the minimun required methods. At this point, is only checked that is a callable

Describe the solution you'd like Implemente a BaseCallback class in the sklearn_genetic.callbacks module, all the current callbacks should be updated to be a child class of that base class. It must force that there is a on_step and call methods in the class, otherwise, raise a NotImplementError. In the check_callback function, it should be checked that the callback is an instance of that base class

Describe alternatives you've considered Create a base class that controlls all the callbacks that are created fot GASearchCV

Additional context If possible, update the documentation on the docs/tutorials/custom_callbacks, which explains how to create a callback. Here should put the BaseCallback on the exampled used.

rodrigo-arenas commented 3 years ago

Close this issue as implemented in PR #23