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

[FEATURE] Add in CTRL + C Early Stopping! #75

Closed windowshopr closed 2 years ago

windowshopr commented 2 years ago

Is your feature request related to a problem? Please describe. Nope.

Describe the solution you'd expect See above

Additional context Love the tool! Would be cool to see this implemented :D

rodrigo-arenas commented 2 years ago

Hi @windowshopr thanks for your message, I'm glad you are enjoying the package! This seems like a nice feature, I'll look for in more detail how to implement it

Greetings

windowshopr commented 2 years ago

Thanks! I think it would be a cool feature to add I think! Psedo-ish code might look something like:

try:
    while True:
        # All the training stuff here

except KeyboardInterrupt:
        # Return the best model here/perform any final steps in the .fit() function
    print('Manually stopped training!')
rodrigo-arenas commented 2 years ago

Yea, I see that in TPOT, I'll look further how to get this like callback or something that doesn't requires a big try/except block, thanks for the tip!

rodrigo-arenas commented 2 years ago

Hi @windowshopr, this is now implemented in PR #86.

Training gracefully stops if interrupted by some of these exceptions: KeyboardInterrupt (ctrl+c), SystemExit, StopIteration. When one of these exceptions is raised, the model finishes the current generation and saves the current best model. It only works if at least one generation has been completed.

stopping

windowshopr commented 2 years ago

Awesome! Thanks!!!