philipperemy / n-beats

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

Polynomial basis for backcast #53

Closed chedatomasz closed 3 years ago

chedatomasz commented 3 years ago

The polynomial basis for backcast and forecast is

ls = np.arange(-backcast_length, forecast_length, 1) / forecast_length 
b_ls = ls[:backcast_length]  
f_ls = ls[backcast_length:]

Thus, for the trend_model, the polynomial for the backcast is evaluated at x < 0. Although the paper does not state what the backcast basis should be, the ElementAI implementation uses polynomials at x>=0 for both backcast and forecast. As far as I can tell, no transformation on thetas could make those bases equivalent. Is this a deliberate decision, or a bug? Edit: I noticed the ElementAI implementation flips the residuals, so I guess this is done here to reflect that without flipping. Did you perhaps get an answer from the authors as to why this is done?

philipperemy commented 3 years ago

Hmm not sure. We released this implementation before the official one. Do you have any suggestions on the matter? @chedatomasz I saw you opened a previous issue. Let me look into that! Sorry for the late response!

philipperemy commented 3 years ago

Fixed in https://github.com/philipperemy/n-beats/commit/be40395c9811eb5350417026a23fd88f8a8e79e0