Best way to extract parameters and save model objects? #40
-
Hi, I'm wondering are there any recommended workflows/guidelines for extracting parameters from fitted objects and saving model objects? I can't find any guidelines in the documentation. It seems like there are many ways to extract parameters from fitted objects: Does PyDDM have built-in functions/methods for saving objects? I've been using Really appreciate any help anyone can provide. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Thanks for your inquiry! I would not recommend using get_dependence() or model.dependencies, since these will make it difficult to extract the information you need. If you want to save a model to reuse later, the easiest (and most space-efficient) way to do this is to print() the model, cast it to a string with str(), or run repr() on it, and then save the string they output. The function print() produces a nicer formatting than repr(), but otherwise they are identical. (str(), print(), and repr() I am talking about are all the versions built-in to Python) If you execute these strings on a new python interpreter with the appropriate imports, you should get the same model. For analyzing parameters, get_model_paramters() gives you what you want, and get_model_parameter_names() gives you the name. They are guaranteed to be in the same order, so you can use these lists to easily construct a dataframe. I just updated the quickstart guide in the documentation to clarify all of this! |
Beta Was this translation helpful? Give feedback.
Thanks for your inquiry!
I would not recommend using get_dependence() or model.dependencies, since these will make it difficult to extract the information you need.
If you want to save a model to reuse later, the easiest (and most space-efficient) way to do this is to print() the model, cast it to a string with str(), or run repr() on it, and then save the string they output. The function print() produces a nicer formatting than repr(), but otherwise they are identical. (str(), print(), and repr() I am talking about are all the versions built-in to Python) If you execute these strings on a new python interpreter with the appropriate imports, you should get the same model.
For analyzing pa…