TimeSeriesPredictor.backtest_targets

TimeSeriesPredictor.backtest_targets(data: TimeSeriesDataFrame | None = None, *, num_val_windows: int | None = None, val_step_size: int | None = None) list[TimeSeriesDataFrame][source]

Return target values for each validation window.

Returns the actual target values corresponding to each validation window used in backtest_predictions(). The returned targets are aligned with the predictions, making it easy to compute custom evaluation metrics or analyze forecast errors.

Parameters:
  • data (TimeSeriesDataFrame, optional) –

    Time series data to extract targets from. If None, returns the targets from the validation windows used during training.

    If provided, all time series in data must have length at least prediction_length + (num_val_windows - 1) * val_step_size + 1.

    The names and dtypes of columns and static features in data must match the train_data used to train the predictor.

  • num_val_windows (int, optional) –

    Number of validation windows to extract targets for. If None, uses the num_val_windows value from training configuration when data=None, otherwise defaults to 1.

    This should match the num_val_windows argument passed to backtest_predictions().

  • val_step_size (int, optional) –

    Number of time steps between the start of consecutive validation windows. If None, defaults to prediction_length.

    This should match the val_step_size argument passed to backtest_predictions().

Returns:

Target values for each validation window. Returns a list of length num_val_windows, where each element contains the full time series data for one validation window. Each dataframe includes both historical context and the last prediction_length time steps that represent the target values to compare against predictions.

The returned targets are aligned with the output of backtest_predictions(), so targets[i] corresponds to predictions[i] for the i-th validation window.

Return type:

list[TimeSeriesDataFrame]

See also

backtest_predictions

Return predictions for multiple validation windows.

evaluate

Evaluate forecast accuracy on a hold-out set.