TimeSeriesPredictor.predict

TimeSeriesPredictor.predict(data: TimeSeriesDataFrame | DataFrame | Path | str, known_covariates: TimeSeriesDataFrame | DataFrame | Path | str | None = None, model: str | None = None, use_cache: bool = True, random_seed: int | None = 123) TimeSeriesDataFrame[source]

Return quantile and mean forecasts for the given dataset, starting from the end of each time series.

Parameters:
  • data (Union[TimeSeriesDataFrame, pd.DataFrame, Path, str]) –

    Historical time series data for which the forecast needs to be made.

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

    If provided data is a pandas.DataFrame, AutoGluon will attempt to convert it to a TimeSeriesDataFrame. If a str or a Path is provided, AutoGluon will attempt to load this file.

  • known_covariates (Union[TimeSeriesDataFrame, pd.DataFrame, Path, str], optional) –

    If known_covariates_names were specified when creating the predictor, it is necessary to provide the values of the known covariates for each time series during the forecast horizon. Specifically:

    • Must contain all columns listed in known_covariates_names.

    • Must include all item_id values present in the input data.

    • Must include timestamp values for the full forecast horizon (i.e., prediction_length time steps) following the end of each series in the input data.

    You can use autogluon.timeseries.TimeSeriesPredictor.make_future_data_frame() to generate a template containing the required item_id and timestamp combinations for the known_covariates data frame.

    See example below.

  • model (str, optional) – Name of the model that you would like to use for prediction. By default, the best model during training (with highest validation score) will be used.

  • random_seed (int or None, default = 123) – If provided, fixes the seed of the random number generator for all models. This guarantees reproducible results for most models (except those trained on GPU because of the non-determinism of GPU operations).

  • use_cache (bool, default = True) – If True, will attempt to use the cached predictions. If False, cached predictions will be ignored. This argument is ignored if cache_predictions was set to False when creating the TimeSeriesPredictor.

Examples

>>> print(data)
                    target  promotion  price
item_id timestamp
A       2020-01-05      20          0   19.9
        2020-01-06      40          1    9.9
        2020-01-07      32          0   15.0
B       2020-03-01      13          0    5.0
        2020-03-02      44          1    2.9
        2020-03-03      72          1    2.9
>>> predictor = TimeSeriesPredictor(prediction_length=2, known_covariates_names=["promotion", "price"]).fit(data)
>>> print(future_known_covariates)
                    promotion  price
item_id timestamp
A       2020-01-08          1   12.9
        2020-01-09          1   12.9
B       2020-03-04          0    5.0
        2020-03-05          0    7.0
>>> predictor.predict(data, known_covariates=future_known_covariates)
                      mean
item_id timestamp
A       2020-01-08    30.2
        2020-01-09    27.0
B       2020-03-04    17.1
        2020-03-05     8.3