Unrolling vs n_forecast does not yield same result with AR #1681
Unanswered
Splifit
asked this question in
Q&A - get help using NeuralProphet
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello everyone,
I am currently building an impact analysis using neural prophet.
I have as an input an arbitrary time series.
User should select an event start date and a post analysis range for which I should provide a forecast of the time series & the actual impact analysis (measure of the difference between observed data & forecast).
I encounter a problem with the AR layer. Adding it into the model means that I need to add "n_forecast" = length(post_analysis range) parameter to be able to easily get the forecast for the given range. My problem is:
This is something I would like to prevent. The workaround I figured out is to set up "n_forecast" = N (a constant) and then unroll the model if more prediction are needed or truncate the prediction if fewer are needed. But I encounter problem when I unroll the model :
event = '2024-07-05'
set_random_seed(42)
m = NeuralProphet(
# Disable change trendpoints
# Disable seasonality components
yearly_seasonality=True,
weekly_seasonality=True,
ar_layers= [7,14,7],
ar_reg = 10,
n_lags = 7,
daily_seasonality=False,
n_changepoints=2,
n_forecasts=7,
impute_missing=True,
impute_linear=62
)
ts = df.loc[df.ds < event].reset_index(drop = True)
m.add_country_holidays(country_name='US')
m.set_plotting_backend("plotly-static")
metrics = m.fit(ts)
future = m.make_future_dataframe(ts, periods=7)
extrapolation_forecast = m.predict(future, decompose = False)
latest = m.get_latest_forecast(extrapolation_forecast)
for i in range(7):
extrapolation_forecast.loc[extrapolation_forecast.y.isnull(), 'y'] = extrapolation_forecast.loc[extrapolation_forecast.y.isnull(), 'yhat1']
future = m.make_future_dataframe(extrapolation_forecast[['ds', 'y']].loc[extrapolation_forecast.y.notnull()], periods=1, n_historic_prediction=True)
extrapolation_forecast = m.predict(future)
print(latest)
print(extrapolation_forecast.loc[(extrapolation_forecast.ds<= '2024-07-11')*(extrapolation_forecast.ds>= '2024-07-05'), ['ds', 'y']])
What am I doing wrong here ?
Beta Was this translation helpful? Give feedback.
All reactions