Open In Colab

Multiplicative SeasonalityΒΆ

By default NeuralProphet fits additive seasonalities, meaning the effect of the seasonality is added to the trend to get the forecast. This time series of the number of air passengers is an example of when additive seasonality does not work:

[1]:
if 'google.colab' in str(get_ipython()):
    !pip install git+https://github.com/ourownstory/neural_prophet.git # may take a while
    #!pip install neuralprophet # much faster, but may not have the latest upgrades/bugfixes

import pandas as pd
from neuralprophet import NeuralProphet, set_log_level
set_log_level("ERROR")
[2]:
data_location = "https://raw.githubusercontent.com/ourownstory/neuralprophet-data/main/datasets/"
df = pd.read_csv(data_location + "air_passengers.csv")
[3]:
m = NeuralProphet()
metrics = m.fit(df, freq="MS")

[4]:
forecast = m.predict(df)
fig = m.plot(forecast)
# fig_param = m.plot_parameters()
_images/season_multiplicative_air_travel_5_0.png

This time series has a clear yearly cycle, but the seasonality in the forecast is too large at the start of the time series and too small at the end. In this time series, the seasonality is not a constant additive factor as assumed by NeuralProphet, rather it grows with the trend. This is multiplicative seasonality.

NeuralProphet can model multiplicative seasonality by setting seasonality_mode="multiplicative" in the input arguments:

[5]:
m = NeuralProphet(seasonality_mode="multiplicative")
metrics = m.fit(df, freq="MS")

[6]:
forecast = m.predict(df)
fig = m.plot(forecast)
# fig_param = m.plot_parameters()
_images/season_multiplicative_air_travel_8_0.png

The components figure will now show the seasonality as a percent of the trend:

[7]:
fig_param = m.plot_components(forecast)
_images/season_multiplicative_air_travel_10_0.png

Note that the seasonality is only fit on data occuring at the start of the month. Thus, the plotted values for seasonality inbetween months may take on random values.

Settingseasonality_mode="multiplicative" will model all seasonalities as multiplicative, including custom seasonalities added with add_seasonality.