gluonts.evaluation.backtest module

class gluonts.evaluation.backtest.BacktestInformation(train_dataset_stats, test_dataset_stats, estimator, agg_metrics)[source]

Bases: tuple

property agg_metrics

Alias for field number 3

property estimator

Alias for field number 2

static make_from_log(log_file)[source]
static make_from_log_contents(log_contents)[source]
property test_dataset_stats

Alias for field number 1

property train_dataset_stats

Alias for field number 0

gluonts.evaluation.backtest.backtest_metrics(test_dataset: Iterable[Dict[str, Any]], predictor: gluonts.model.predictor.Predictor, evaluator=<gluonts.evaluation._base.Evaluator object>, num_samples: int = 100, logging_file: Optional[str] = None) → Tuple[dict, pandas.core.frame.DataFrame][source]
  • test_dataset – Dataset to use for testing.

  • predictor – The predictor to test.

  • evaluator – Evaluator to use.

  • num_samples – Number of samples to use when generating sample-based forecasts. Only sampling-based models will use this.

  • logging_file – If specified, information of the backtest is redirected to this file.


A tuple of aggregate metrics and per-time-series metrics obtained by training forecaster on train_dataset and evaluating the resulting evaluator provided on the test_dataset.

Return type

Tuple[dict, pd.DataFrame]

gluonts.evaluation.backtest.make_evaluation_predictions(dataset: Iterable[Dict[str, Any]], predictor: gluonts.model.predictor.Predictor, num_samples: int = 100) → Tuple[Iterator[gluonts.model.forecast.Forecast], Iterator[pandas.core.series.Series]][source]

Returns predictions for the trailing prediction_length observations of the given time series, using the given predictor.

The predictor will take as input the given time series without the trailing prediction_length observations.

  • dataset – Dataset where the evaluation will happen. Only the portion excluding the prediction_length portion is used when making prediction.

  • predictor – Model used to draw predictions.

  • num_samples – Number of samples to draw on the model when evaluating. Only sampling-based models will use this.


A pair of iterators, the first one yielding the forecasts, and the second one yielding the corresponding ground truth series.

Return type

Tuple[Iterator[Forecast], Iterator[pd.Series]]

gluonts.evaluation.backtest.serialize_message(logger, message: str, variable)[source]