EconML
EconML copied to clipboard
refit issue & store the model locally
Is there anyway I can store the EconML model locally (potentially include structure, parameter, model type) and avoid refitting every time?
It might help if you could further describe your scenario - what do you mean by "refitting each time"? Each of our models should support pickling, assuming that the models that are passed into its initializer also support pickling, so if you just want to reuse a trained estimator in a different python session, then pickling it to a file and then unpickling it some other time should work.
Several of our models that have multiple stages also support retraining only the final stage to prevent redundant work. For example, you can fit a LinearDML model (passing cache_values=True to store the intermediate results), and then update the featurizer on the instance and call refit_final, which will not retrain the first stage models. Does that help?
Thanks for the response! I think pickling the model resolve the problem properly. The follow-up question is that I usually call econML models from dowhy KPI for the sake of following refutation and I didn't find the proper way to pickling the model from dowhy KPI. Do you have any related experience on how to handle this?
Also, how can I access the first stage results mentioned by your example (passing cache_values=True)? If I want to get the predictions of model_y and model_t, how should I properly extract from an econML model object?