【问题标题】:Save & load best model in AutoTS python在 AutoTS python 中保存和加载最佳模型
【发布时间】:2022-12-03 20:10:36
【问题描述】:

在对一些时间序列数据拟合 AutoTS 模型后,如何保存和加载经过训练的最佳模型?尽管 AutoTS 对象具有 export_template() 和 import_template() 函数来保存最佳模型,但是从该模板加载最佳模型时,它需要重新拟合。如何在生产中使用这样的解决方案?我的代码:

from autots import AutoTS

model = AutoTS(
frequency='infer',
prediction_interval=0.9,
ensemble=None,
model_list="fast",  # "superfast", "default", "fast_parallel"
transformer_list="fast",  # "superfast",
drop_most_recent=1,
max_generations=4,
num_validations=2,
validation_method="backwards") 

 model.fit(df_day,date_col='xyz',value_col='abc')
 model.export_template("unique_user_1", models='best', n=1, max_per_model_class=3)

现在,在一些新的例子中,当我这样做

 model = model.import_template('unique_user_1.csv',method='only')

该模型需要重新训练。

【问题讨论】:

    标签: python machine-learning time-series data-science forecasting


    【解决方案1】:

    您的代码的主要问题是您将 export_template 命名为“unique_user_1”而没有扩展名。尝试使用“unique_user_1.csv”将其保存为 csv 文件

    一旦你觉得你已经完成了模型的训练。写下以下几行

    model.export_template(
    "unique_user_1.csv",
    models="best",
    max_per_model_class=1,
    include_results=True,
    

    )

    加载模板并重新使用它

    model = model.import_template(
    "unique_user_1.csv",
    method="only",
    enforce_model_list=True,)
    model.fit(data)
    prediction = model.predict(forecast_length=15)
    

    【讨论】:

      猜你喜欢
      • 2019-06-09
      • 2020-08-27
      • 2018-06-25
      • 2018-06-27
      • 2013-01-23
      • 1970-01-01
      • 2021-12-15
      • 2019-09-26
      相关资源
      最近更新 更多