加入新推出的
Discord 社区,展开实时讨论,获得同行支持,并直接与 Meridian 团队互动!
保存并加载模型对象
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
执行模型运行作业后,我们建议保存模型对象,以供将来使用。这有助于避免重复运行模型,节省时间和计算资源。保存模型对象后,可在后续阶段加载该对象,继续进行分析或进行可视化处理,而无需重新运行相应模型。
保存模型对象
运行以下命令,以保存模型对象:
file_path = f'{PATH}/{FILENAME}.pkl'
model.save_mmm(meridian, file_path)
其中:
PATH
表示路径,用于指示文件的位置。
FILENAME
是文件的名称。文件扩展名必须为 PKL。
加载模型对象
运行以下命令,以加载已保存的模型:
file_path = f'{PATH}/{FILENAME}.pkl'
meridian=model.load_mmm(file_path)
其中:
PATH
表示路径,用于指示文件的位置。
FILENAME
是文件的名称。文件扩展名必须为 PKL。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-04。
[null,null,["最后更新时间 (UTC):2025-08-04。"],[[["\u003cp\u003eSaving the model object after a run is recommended to prevent repetitive runs and conserve resources.\u003c/p\u003e\n"],["\u003cp\u003eA saved model object can be loaded later for continued analysis or visualizations without needing to re-run the model.\u003c/p\u003e\n"],["\u003cp\u003eTo save the model, use the \u003ccode\u003emodel.save_mmm(meridian, file_path)\u003c/code\u003e command, where \u003ccode\u003efile_path\u003c/code\u003e includes the \u003ccode\u003ePATH\u003c/code\u003e and a \u003ccode\u003eFILENAME\u003c/code\u003e with a PKL extension.\u003c/p\u003e\n"],["\u003cp\u003eTo load a previously saved model, use the \u003ccode\u003emodel.load_mmm(file_path)\u003c/code\u003e command, where \u003ccode\u003efile_path\u003c/code\u003e includes the \u003ccode\u003ePATH\u003c/code\u003e and a \u003ccode\u003eFILENAME\u003c/code\u003e with a PKL extension.\u003c/p\u003e\n"]]],[],null,["# Save and load the model object\n\nAfter executing the model run, we recommend saving the model object for future\nuse. This helps you avoid repetitive model runs, and saves time and\ncomputational resources. After the model object is saved, the object can be\nloaded at a later stage to continue the analysis or visualizations without\nhaving to re-run the model.\n\nSave the model object\n---------------------\n\nRun the following command to save the model object: \n\n file_path = f'{PATH}/{FILENAME}.pkl'\n model.save_mmm(meridian, file_path)\n\nWhere:\n\n- `PATH` is the path to the file location.\n- `FILENAME` is the name of the file. It must have a PKL extension.\n\nLoad the model object\n---------------------\n\nRun the following command to load the saved model: \n\n file_path = f'{PATH}/{FILENAME}.pkl'\n meridian=model.load_mmm(file_path)\n\nWhere:\n\n- `PATH` is the path to the file location.\n- `FILENAME` is the name of the file. It must have a PKL extension."]]