I'm following the tutorial on quantile regression in NeuralProphet, but there is an issue when plotting the forecast.
confidence_lv = 0.9
quantile_list = [round(((1 - confidence_lv) / 2), 2), round((confidence_lv + (1 - confidence_lv) / 2), 2)]
m = NeuralProphet(
yearly_seasonality=True,
weekly_seasonality=True,
daily_seasonality=False,
quantiles=quantile_list,
n_lags=30,
epochs=10,
n_forecasts=30,
)
m.set_plotting_backend('plotly')
metrics = m.fit(df)
df_future = m.make_future_dataframe(
df,
n_historic_predictions=True,
periods=30,
)
forecast = m.predict(df_future)
m.plot(forecast, forecast_in_focus=30)
I'm getting the error below. I'm not finding the parameter they mentioned anywhere in these functions above (I'm using version 0.6.2
).
in NeuralProphet.plot(self, fcst, df_name, ax, xlabel, ylabel, figsize, forecast_in_focus, plotting_backend)
1886 if len(self.config_train.quantiles) > 1:
1887 if (self.highlight_forecast_step_n) is None and (
1888 self.n_forecasts > 1 or self.n_lags > 0
1889 ): # rather query if n_forecasts >1 than n_lags>1
-> 1890 raise ValueError(
1891 "Please specify step_number using the highlight_nth_step_ahead_of_each_forecast function"
1892 " for quantiles plotting when auto-regression enabled."
1893 )
1894 if (self.highlight_forecast_step_n or forecast_in_focus) is not None and self.n_lags == 0:
1895 log.warning("highlight_forecast_step_n is ignored since auto-regression not enabled.")
ValueError: Please specify step_number using the highlight_nth_step_ahead_of_each_forecast function for quantiles plotting when auto-regression enabled.
If I understand correctly the error is stating you are missing a step in your code. When you are initiating:
m = NeuralProphet(
yearly_seasonality=True,
weekly_seasonality=True,
daily_seasonality=False,
quantiles=quantile_list,
n_lags=30,
epochs=10,
n_forecasts=30,
)
You are setting n_forecasts=30
. Doing so triggers the following if statement:
if (self.highlight_forecast_step_n) is None and (
self.n_forecasts > 1 or self.n_lags > 0
You failed to set highlight_forecast_step_n
and have set n_forecasts=30
. Thus the if statement is True
because highlight_forecast_step_n
equals None
and n_forecasts
is higher then 1
. T
To fix this you need to set the highlight_forecast_step_n
attribute of your model. This can be done by using the class function highlight_nth_step_ahead_of_each_forecast
.
Something like this will work:
m.highlight_nth_step_ahead_of_each_forecast(step_number=10)
Reference: highlight_nth_step_ahead_of_each_forecast