-
Notifications
You must be signed in to change notification settings - Fork 496
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inconsistent NaN pattern in multi-step predictions with n_lags and n_forecasts #1669
Comments
Further Analysis Based on Code ReviewAfter reviewing the NeuralProphet implementation, I've found that the NaN pattern cannot be explained by recursive dependencies, as NeuralProphet actually uses direct multi-step forecasting, not recursive forecasting. Key Code EvidenceThe autoregression implementation in NeuralProphet shows that all forecasts are generated simultaneously in a single forward pass: def auto_regression(self, lags: Union[torch.Tensor, float]) -> torch.Tensor:
x = self.ar_net(lags) # Takes lags as input
x = x.view(x.shape[0], self.config_model.n_forecasts, len(self.quantiles)) # Outputs all forecasts at once
return x This indicates that:
ImplicationsGiven this implementation:
At row index 2:
ConclusionThe diagonal pattern of NaNs appears to be an implementation artifact rather than a necessary feature of the model's architecture. Since NeuralProphet uses direct multi-step forecasting (not recursive forecasting), all forecast horizons should theoretically be available as soon as we have sufficient lags. This suggests that the handling of NaN values in the prediction output might need to be reviewed, as it doesn't align with the actual forecasting mechanism being used in the model. Would it be possible to review how predictions are being assigned to the output DataFrame? It seems there might be a disconnect between how the predictions are generated (all at once) and how they're being populated in the results. |
I've run into this problem too - how neuralprophet's n_forcast and n_lags are handled internally is not adequately described in the documentation. |
Description
I've noticed an inconsistent pattern in how NeuralProphet handles multi-step predictions. When using
n_lags
andn_forecasts
, there appears to be a non-intuitive pattern of NaN values in the predictions.Minimal Reproducible Example
Current Behavior
At the start of predictions:
At row 2, we have:
Expected Behavior
At row 2, since we have the required 2 lags of history, we should be able to predict both yhat1 and yhat2. There's no mathematical reason why we can predict one step ahead but not two steps ahead when we have all the required historical data.
Expected output at row 2:
Questions
Environment
The text was updated successfully, but these errors were encountered: