Я следую руководству по квантильной регрессии в NeuralProphet, но при построении прогноза возникла проблема.
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)
Я получаю ошибку ниже. Я не нашел параметра, упомянутого в этих функциях выше (я использую версию 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.
Если я правильно понимаю, ошибка означает, что вы пропустили шаг в своем коде. Когда вы начинаете:
m = NeuralProphet(
yearly_seasonality=True,
weekly_seasonality=True,
daily_seasonality=False,
quantiles=quantile_list,
n_lags=30,
epochs=10,
n_forecasts=30,
)
Вы ставите n_forecasts=30
. При этом активируется следующий оператор if:
if (self.highlight_forecast_step_n) is None and (
self.n_forecasts > 1 or self.n_lags > 0
Вы не смогли установить highlight_forecast_step_n
и установили n_forecasts=30
. Таким образом, утверждение if равно True
, потому что highlight_forecast_step_n
равно None
, а n_forecasts
больше, чем 1
. Т
Чтобы это исправить, вам нужно установить атрибут highlight_forecast_step_n
вашей модели. Это можно сделать с помощью функции класса highlight_nth_step_ahead_of_each_forecast
.
Что-то вроде этого будет работать:
m.highlight_nth_step_ahead_of_each_forecast(step_number=10)