philipperemy / n-beats

Keras/Pytorch implementation of N-BEATS: Neural basis expansion analysis for interpretable time series forecasting.
MIT License
855 stars 163 forks source link

Return backcast for Keras model #47

Closed mnaylor5 closed 3 years ago

mnaylor5 commented 3 years ago

Is there a method to return the backcast for each stack in nbeats-keras? I am interested in illustrating the interpretability for a model like in the n-beats paper (Fig. 2), but this does not seem straightforward in the Keras implementation.

The forward method of PyTorch model returns both the forecast and backcast, but I am getting consistently much better models using the Keras trainer. I would appreciate any example or instruction you have to access the interpretability features for this implementation.

Thank you!

philipperemy commented 3 years ago

Yes definitely possible and it would make the implementations more consistent. I'll try to prioritize it this week! Thanks for reporting

mnaylor5 commented 3 years ago

Awesome! Thank you, @philipperemy!

philipperemy commented 3 years ago

https://github.com/philipperemy/n-beats/pull/48

philipperemy commented 3 years ago

@mnaylor5 done! Released in 1.4.0 (with pip). All you need to do is pass return_backcast=True to the predict function of the Keras model.

predictions_keras_backcast = model_keras.predict(x_test, return_backcast=True)