Skip to content

plot_forecast


method plot_forecast(models=None, fh="dataset", X=None, target=0, plot_insample=False, plot_interval=True, inverse=True, title=None, legend="upper left", figsize=(900, 900), filename=None, display=True)[source]
Plot model forecasts for the target time series.

This figure shows two plots: the upper plot shows the predicted values, where the gray, intersected line shows the target time series; and the lower plot, that shows the prediction residuals. This plot is only available for forecast tasks.

Parametersmodels: int, str, Model, segment, sequence or None, default=None
Models to plot. If None, all models are selected.

fh: hashable, segment, sequence, dataframe or ForecastingHorizon, default="dataset"
The forecasting horizon for which to plot the predictions.

X: dataframe-like or None, default=None
Exogenous time series corresponding to fh. This parameter is ignored if fh is part of the dataset. The data is transformed through the model's pipeline before using it for predictions.

target: int or str, default=0
Target column to look at. Only for multivariate tasks.

plot_insample: bool, default=False
Whether to draw in-sample predictions (predictions on the training set). Models that do not support this feature are silently skipped.

plot_interval: bool, default=True
Whether to plot prediction intervals together with the exact predicted values. Models wihtout a predict_interval method are skipped silently.

inverse: bool, default=True
Whether to inversely transform the output through the pipeline. This doesn't affect the predictions if there are no transformers in the pipeline or if the transformers have no inverse_transform method or don't apply to y.

title: str, dict or None, default=None
Title for the plot.

legend: str, dict or None, default="upper left"
Legend for the plot. See the user guide for an extended description of the choices.

  • If None: No legend is shown.
  • If str: Position to display the legend.
  • If dict: Legend configuration.

figsize: tuple, default=(900, 900)
Figure's size in pixels, format as (x, y).

filename: str, Path or None, default=None
Save the plot using this name. Use "auto" for automatic naming. The type of the file depends on the provided name (.html, .png, .pdf, etc...). If filename has no file type, the plot is saved as html. If None, the plot is not saved.

display: bool or None, default=True
Whether to render the plot. If None, it returns the figure.

Returnsgo.Figure or None
Plot object. Only returned if display=None.


See Also

plot_distribution

Plot column distributions.

plot_series

Plot a data series.

plot_errors

Plot a model's prediction errors.


Example

>>> from atom import ATOMForecaster
>>> from sktime.datasets import load_airline
>>> from sktime.forecasting.base import ForecastingHorizon

>>> y = load_airline()

>>> atom = ATOMForecaster(y, random_state=1)
>>> atom.run(
...     models="arima",
...     est_params={"order": (1, 1, 0), "seasonal_order": (0, 1, 0, 12)},
... )
>>> atom.plot_forecast()

>>> atom.plot_forecast(fh="train+test", plot_interval=False)

>>> # Forecast the next 4 years starting from the test set
>>> atom.plot_forecast(fh=ForecastingHorizon(range(48)))