在AWS Forecast中,"backtest windows"是一个用来指定训练时使用的历史数据量的参数。具体来说,它指定了训练窗口的长度,而训练窗口则是从历史数据最后一个观测时间开始,向前回溯一段时间。
例如,如果您的历史数据有1年的时间,您可以将"backtest windows"设置为6个月,这意味着您将训练使用从最后6个月为止的年度数据。训练过程将重复这个过程,直到覆盖整个历史时间范围。通过这种方式,您可以测试不同的"backtest windows"设置来寻找最佳的模型训练参数。
以下是一个基本的AWS Forecast代码片段,演示如何设置“backtest windows”:
import boto3
from datetime import datetime
forecast = boto3.client('forecast')
project_name = "example_project"
dataset_group_name = "example_dataset"
predictor_name = "example_predictor"
algorithm_arn = "arn:aws:forecast:::algorithm/"
# Specify the backtest window
backtest_window = {"EvaluationParameters": {"NumberOfBacktestWindows": 1, "BackTestWindowOffset": 30}}
# Train the predictor
predictor_arn = forecast.create_predictor(
PredictorName = predictor_name,
AlgorithmArn = algorithm_arn,
FeaturizationConfig = {},
ForecastHorizon = 30,
PerformAutoML = False,
PerformHPO = False,
EvaluationParameters = backtest_window,
InputDataConfig = {},
TrainingParameters = {},
Tags = []
)['PredictorArn']
在上面的代码中,我们通过将"backtest windows"包含在"backtest_window"参数中来设置回测窗口。"NumberOfBacktestWindows"指定在训练过程中要使用的回归窗