-
Notifications
You must be signed in to change notification settings - Fork 216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] Easy loading from equation file #167
Conversation
@kazewong this makes it easier to load from past runs |
Making it simpler to load past runs is a nice addition! I might have missed something, but I think the automatically created pickle file is of the unfitted model as it is called before For me, the |
It was the desired behavior, but your comment is making me reconsider. I guess I can see two scenarios where people would want to load their model:
For 1., it is necessary to checkpoint the parameters before the actual equation search finishes. With the loaded model, you can do For 2., I think you could have the equations stored in the pickle file itself, and perhaps not need the additional equation file. Maybe a nice solution for both these is to dump the pickle file twice: once before the fit runs to checkpoint the model parameters in case the search quits early, and once with the fitted equations (to the same file). What do you think? |
I think dumping the pickle file twice is a good simple solution |
Loading is really helpful, works perfectly as far as I can tell! |
Thanks for the feedback! The merged version saves a pickle file twice - so now you can send someone that pickle file and they can evaluate your equations. |
This makes it easier to load models directly from a saved equation file. There are two ways to use this:
pysr.load(...)
to load from a standalone csv file of equations. However, you must pass a few different attributes here, to initialize the model:binary_operators
,unary_operators
, andn_features_in
. If you have custom variable names, you also need to pass that, as well asnout
if the number of outputs is not 1.PySRRegressor
will now automatically create a pickle file of the model parameters when runningfit(...)
. This has the same name as the equation file, but with a.pkl
extension. This lets you run, e.g.,pysr.load("equations.csv")
, and have everything loaded from the equation. This also loads all the other parameters. (Although, you also need to passextra_sympy_mappings
andextra_torch_mappings
as they are unpicklable).@tttc3 what do you think of this?
I am also wondering if it might be more intuitive to have a
PySRRegressor.from_file(...)
constructor.