Core Module Documentation#

neuralprophet.plot_forecast_matplotlib.plot(fcst, quantiles, ax=None, xlabel='ds', ylabel='y', highlight_forecast=None, line_per_origin=False, figsize=(10, 6))#

Plot the NeuralProphet forecast.

Parameters
  • fcst (pd.DataFrame) – Output of m.predict

  • quantiles (list) – Quantiles for which the forecasts are to be plotted

  • ax (matplotlib axes) – Axes to plot on

  • xlabel (str) – Label name on X-axis

  • ylabel (str) – Label name on Y-axis

  • highlight_forecast (int) – i-th step ahead forecast to highlight.

  • line_per_origin (bool) – Print a line per forecast of one per forecast age

  • figsize (tuple) – Width, height in inches.

Returns

Figure showing the NeuralProphet forecast

Return type

matplotlib.pyplot.figure

Examples

Base usage

>>> from neuralprophet import NeuralProphet
>>> m = NeuralProphet()
>>> metrics = m.fit(df, freq="D")
>>> future = m.make_future_dataframe(df=df, periods=365)
>>> forecast = m.predict(df=future)
>>> fig_forecast = m.plot(forecast)

Additional plot specifications

>>> m.plot(forecast,
>>>    xlabel="ds",
>>>    ylabel="y",
>>>    highlight_forecast=None,
>>>    line_per_origin=False,
>>>    figsize=(10, 6)
>>>    )
neuralprophet.plot_forecast_matplotlib.plot_components(m, fcst, plot_configuration, df_name='__df__', quantile=0.5, one_period_per_season=False, figsize=None)#

Plot the NeuralProphet forecast components.

Parameters
  • m (NeuralProphet) – Fitted model

  • fcst (pd.DataFrame) – Output of m.predict

  • plot_configuration (dict) – dict of configured components to plot

  • df_name (str) – ID from time series that should be plotted

  • quantile (float) – Quantile for which the forecast components are to be plotted

  • one_period_per_season (bool) – Plot one period per season, instead of the true seasonal components of the forecast.

  • figsize (tuple) –

    Width, height in inches.

    Note

    Default value is set to None -> automatic figsize = (10, 3 * npanel)

Returns

Figure showing the NeuralProphet forecast components

Return type

matplotlib.pyplot.figure

neuralprophet.plot_forecast_matplotlib.plot_forecast_component(fcst, comp_name, plot_name=None, ax=None, figsize=(10, 6), multiplicative=False, bar=False, rolling=None, add_x=False, fill=False)#

Plot a particular component of the forecast.

Parameters
  • fcst (pd.DataFrame) – Output of m.predict

  • comp_name (str) – Name of the component to plot

  • plot_name (str) – Name of the plot Title

  • ax (matplotlib axis) – Matplotlib Axes to plot on

  • figsize (tuple) –

    Width, height in inches. Ignored if ax is not None

    Note

    Default value is set to figsize = (10, 6)

  • multiplicative (bool) – Set y axis as percentage

  • bar (bool) – Make barplot

  • rolling (int) – Rolling average underplot

  • add_x (bool) – Add x symbols to plotted points

  • fill (bool) – Add fill between signal and x(y=0) axis

Returns

List of Artist objects containing a particular forecast component

Return type

matplotlib.artist.Artist

neuralprophet.plot_forecast_matplotlib.plot_interval_width_per_timestep(q_hats, method)#

Plot the nonconformity scores as well as the one-sided interval width (q).

Parameters
  • q_hats (dataframe) – prediction interval widths (or q) for each timestep, contains column q_hat_sym for symmetric q or q_hat_lo and q_hat_hi for asymmetric q

  • method (str) –

    name of conformal prediction technique used

    Options
    • (default) naive: Naive or Absolute Residual

    • cqr: Conformalized Quantile Regression

Returns

Figure showing the q-values for each timestep

Return type

matplotlib.pyplot.figure

neuralprophet.plot_forecast_matplotlib.plot_multiforecast_component(fcst, comp_name, plot_name=None, ax=None, figsize=(10, 6), multiplicative=False, bar=False, focus=1, num_overplot=None)#

Plot a particular component of the forecast.

Parameters
  • fcst (pd.DataFrame) – Output of m.predict.

  • comp_name (str) – Name of the component to plot.

  • plot_name (str) – Name of the plot Title.

  • ax (matplotlib axis) – Matplotlib Axes to plot on.

  • figsize (tuple) –

    Width, height in inches, ignored if ax is not None.

    Note

    Default value is set to figsize = (10, 6)

  • multiplicative (bool) – Set y axis as percentage

  • bar (bool) – Make barplot

  • focus (int) – Forecast number to portray in detail.

  • num_overplot (int) –

    Overplot all forecasts up to num

    Note

    Default value is set to num_overplot = None -> only plot focus

Returns

List of Artist objects containing a particular forecast component

Return type

matplotlib.artist.Artist

neuralprophet.plot_forecast_matplotlib.plot_nonconformity_scores(scores, alpha, q, method)#

Plot the nonconformity scores as well as the one-sided interval width (q).

Parameters
  • scores (dict) – nonconformity scores

  • alpha (float or tuple) – user-specified significance level of the prediction interval, float if coverage error spread arbitrarily over left and right tails, tuple of two floats for different coverage error over left and right tails respectively

  • q (float or list) – prediction interval width (or q)

  • method (str) –

    name of conformal prediction technique used

    Options
    • (default) naive: Naive or Absolute Residual

    • cqr: Conformalized Quantile Regression

Returns

Figure showing the nonconformity score with horizontal line for q-value based on the significance level or alpha

Return type

matplotlib.pyplot.figure