trevorstephens / gplearn

Genetic Programming in Python, with a scikit-learn inspired API
http://gplearn.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
1.56k stars 274 forks source link

Auto-Save function #279

Open c0def0x01 opened 1 year ago

c0def0x01 commented 1 year ago

I find myself frequently in the situation to train e.g. a symbolic Regressor on my local pc. With higher number of generations this can take several hours. If, for some reason, the process is interrupted I loose all the previously calculated generations.

Would it be possible for you to add an option that allows to auto-save the model during the ‚fit()‘ operation in training, e.g. every number of n generations?

trevorstephens commented 1 year ago

You could generate this functionality within a simple loop by combining warm starting with pickling

c0def0x01 commented 1 year ago

Thank you. Yes you are right. Could have had the idea myself….

However one question: if I reload a previously trained SybolicRegressor and evolve with warm_start further generations, I observed that it displays very high ‚population average fitness’ values (>10^20), whereas the best individual values for fitness continue around where the previous training round finished. Is it just a matter of display, or because the old population averages are not saved with the model …. ? Please excuse if my question is naive or ignorant.
If this values are just abmattet of display, then your proposal is actually the one will do. Thx

trevorstephens commented 1 year ago

If you can provide a short self contained example with a toy dataset I can look into it. I'm not familiar with the issue.