N-BEATS

The Neural Basis Expansion Analysis (NBEATS) is an MLP-based deep neural architecture with backward and forward residual links. The network has two variants: (1) in its interpretable configuration, NBEATS sequentially projects the signal into polynomials and harmonic basis to learn trend and seasonality components; (2) in its generic configuration, it substitutes the polynomial and harmonic basis for identity basis and larger network’s depth. The Neural Basis Expansion Analysis with Exogenous (NBEATSx), incorporates projections to exogenous temporal variables available at the time of the prediction.

This method proved state-of-the-art performance on the M3, M4, and Tourism Competition datasets, improving accuracy by 3% over the ESRNN M4 competition winner.

References
-Boris N. Oreshkin, Dmitri Carpov, Nicolas Chapados, Yoshua Bengio (2019). “N-BEATS: Neural basis expansion analysis for interpretable time series forecasting”.
-Kin G. Olivares, Cristian Challu, Grzegorz Marcjasz, Rafał Weron, Artur Dubrawski (2021). “Neural basis expansion analysis with exogenous variables: Forecasting electricity prices with NBEATSx”.

Figure 1. Neural Basis Expansion Analysis.


source

NBEATS

 NBEATS (input_size, h, n_polynomials=2, n_harmonics=2,
         stack_types:list=['identity', 'trend', 'seasonality'],
         n_blocks:list=[1, 1, 1], mlp_units:list=[[512, 512], [512, 512],
         [512, 512]], dropout_prob_theta=0.0, activation='ReLU',
         shared_weights=False, learning_rate=0.001,
         windows_batch_size:int=1024, step_size:int=1,
         loss=<neuralforecast.losses.pytorch.MAE object at
         0x7f9535c2e3b0>, random_seed=1)

Hooks to be used in LightningModule.


NBEATS.fit

 NBEATS.fit (dataset, trainer, val_size=0, test_size=0, **data_kwargs)

Fits Model.

Parameters:
dataset: TimeSeriesDataset.
trainer: pl.Trainer.
val_size: int, validation size.
test_size: int, test size.
data_kwargs: extra arguments to be passed to TimeSeriesDataModule.


NBEATS.predict

 NBEATS.predict (dataset, trainer, step_size=1, **data_kwargs)

Predicts Model.

Parameters:
dataset: TimeSeriesDataset.
trainer: pl.Trainer.
step_size: int, Step size between each window.
data_kwargs: extra arguments to be passed to TimeSeriesDataModule.

import matplotlib.pyplot as plt
import pandas as pd
from neuralforecast.utils import AirPassengersDF as Y_df
from neuralforecast.tsdataset import TimeSeriesDataset, TimeSeriesLoader

Y_train_df = Y_df[Y_df.ds<='1959-12-31'] # 132 train
Y_test_df = Y_df[Y_df.ds>'1959-12-31']   # 12 test

dataset, *_ = TimeSeriesDataset.from_df(df = Y_train_df)
nbeats = NBEATS(24, 12, windows_batch_size=None)
trainer = pl.Trainer(max_epochs=50)
nbeats.fit(dataset=dataset, trainer=trainer)
y_hat = nbeats.predict(dataset=dataset, trainer=trainer)
Y_test_df['N-BEATS'] = y_hat

pd.concat([Y_train_df, Y_test_df]).drop('unique_id', axis=1).set_index('ds').plot()
Training: 0it [00:00, ?it/s]Training:   0%|          | 0/1 [00:00<?, ?it/s]Epoch 0:   0%|          | 0/1 [00:00<?, ?it/s] Epoch 0: 100%|##########| 1/1 [00:00<00:00, 20.23it/s]Epoch 0: 100%|##########| 1/1 [00:00<00:00, 20.00it/s, loss=47, v_num=1, train_loss_step=47.00]Epoch 0: 100%|##########| 1/1 [00:00<00:00, 19.71it/s, loss=47, v_num=1, train_loss_step=47.00, train_loss_epoch=47.00]Epoch 0:   0%|          | 0/1 [00:00<?, ?it/s, loss=47, v_num=1, train_loss_step=47.00, train_loss_epoch=47.00]        Epoch 1:   0%|          | 0/1 [00:00<?, ?it/s, loss=47, v_num=1, train_loss_step=47.00, train_loss_epoch=47.00]Epoch 1: 100%|##########| 1/1 [00:00<00:00, 35.73it/s, loss=47, v_num=1, train_loss_step=47.00, train_loss_epoch=47.00]Epoch 1: 100%|##########| 1/1 [00:00<00:00, 35.24it/s, loss=62.4, v_num=1, train_loss_step=77.80, train_loss_epoch=47.00]Epoch 1: 100%|##########| 1/1 [00:00<00:00, 34.52it/s, loss=62.4, v_num=1, train_loss_step=77.80, train_loss_epoch=77.80]Epoch 1:   0%|          | 0/1 [00:00<?, ?it/s, loss=62.4, v_num=1, train_loss_step=77.80, train_loss_epoch=77.80]        Epoch 2:   0%|          | 0/1 [00:00<?, ?it/s, loss=62.4, v_num=1, train_loss_step=77.80, train_loss_epoch=77.80]Epoch 2: 100%|##########| 1/1 [00:00<00:00, 34.46it/s, loss=62.4, v_num=1, train_loss_step=77.80, train_loss_epoch=77.80]Epoch 2: 100%|##########| 1/1 [00:00<00:00, 33.99it/s, loss=68.5, v_num=1, train_loss_step=80.60, train_loss_epoch=77.80]Epoch 2: 100%|##########| 1/1 [00:00<00:00, 33.29it/s, loss=68.5, v_num=1, train_loss_step=80.60, train_loss_epoch=80.60]Epoch 2:   0%|          | 0/1 [00:00<?, ?it/s, loss=68.5, v_num=1, train_loss_step=80.60, train_loss_epoch=80.60]        Epoch 3:   0%|          | 0/1 [00:00<?, ?it/s, loss=68.5, v_num=1, train_loss_step=80.60, train_loss_epoch=80.60]Epoch 3: 100%|##########| 1/1 [00:00<00:00, 34.59it/s, loss=68.5, v_num=1, train_loss_step=80.60, train_loss_epoch=80.60]Epoch 3: 100%|##########| 1/1 [00:00<00:00, 34.06it/s, loss=63, v_num=1, train_loss_step=46.50, train_loss_epoch=80.60]  Epoch 3: 100%|##########| 1/1 [00:00<00:00, 33.27it/s, loss=63, v_num=1, train_loss_step=46.50, train_loss_epoch=46.50]Epoch 3:   0%|          | 0/1 [00:00<?, ?it/s, loss=63, v_num=1, train_loss_step=46.50, train_loss_epoch=46.50]        Epoch 4:   0%|          | 0/1 [00:00<?, ?it/s, loss=63, v_num=1, train_loss_step=46.50, train_loss_epoch=46.50]Epoch 4: 100%|##########| 1/1 [00:00<00:00, 34.63it/s, loss=63, v_num=1, train_loss_step=46.50, train_loss_epoch=46.50]Epoch 4: 100%|##########| 1/1 [00:00<00:00, 34.16it/s, loss=60.9, v_num=1, train_loss_step=52.80, train_loss_epoch=46.50]Epoch 4: 100%|##########| 1/1 [00:00<00:00, 33.40it/s, loss=60.9, v_num=1, train_loss_step=52.80, train_loss_epoch=52.80]Epoch 4:   0%|          | 0/1 [00:00<?, ?it/s, loss=60.9, v_num=1, train_loss_step=52.80, train_loss_epoch=52.80]        Epoch 5:   0%|          | 0/1 [00:00<?, ?it/s, loss=60.9, v_num=1, train_loss_step=52.80, train_loss_epoch=52.80]Epoch 5: 100%|##########| 1/1 [00:00<00:00, 34.99it/s, loss=60.9, v_num=1, train_loss_step=52.80, train_loss_epoch=52.80]Epoch 5: 100%|##########| 1/1 [00:00<00:00, 34.47it/s, loss=57.7, v_num=1, train_loss_step=41.30, train_loss_epoch=52.80]Epoch 5: 100%|##########| 1/1 [00:00<00:00, 33.81it/s, loss=57.7, v_num=1, train_loss_step=41.30, train_loss_epoch=41.30]Epoch 5:   0%|          | 0/1 [00:00<?, ?it/s, loss=57.7, v_num=1, train_loss_step=41.30, train_loss_epoch=41.30]        Epoch 6:   0%|          | 0/1 [00:00<?, ?it/s, loss=57.7, v_num=1, train_loss_step=41.30, train_loss_epoch=41.30]Epoch 6: 100%|##########| 1/1 [00:00<00:00, 35.65it/s, loss=57.7, v_num=1, train_loss_step=41.30, train_loss_epoch=41.30]Epoch 6: 100%|##########| 1/1 [00:00<00:00, 35.15it/s, loss=56, v_num=1, train_loss_step=45.70, train_loss_epoch=41.30]  Epoch 6: 100%|##########| 1/1 [00:00<00:00, 34.41it/s, loss=56, v_num=1, train_loss_step=45.70, train_loss_epoch=45.70]Epoch 6:   0%|          | 0/1 [00:00<?, ?it/s, loss=56, v_num=1, train_loss_step=45.70, train_loss_epoch=45.70]        Epoch 7:   0%|          | 0/1 [00:00<?, ?it/s, loss=56, v_num=1, train_loss_step=45.70, train_loss_epoch=45.70]Epoch 7: 100%|##########| 1/1 [00:00<00:00, 35.35it/s, loss=56, v_num=1, train_loss_step=45.70, train_loss_epoch=45.70]Epoch 7: 100%|##########| 1/1 [00:00<00:00, 34.85it/s, loss=54, v_num=1, train_loss_step=39.90, train_loss_epoch=45.70]Epoch 7: 100%|##########| 1/1 [00:00<00:00, 34.07it/s, loss=54, v_num=1, train_loss_step=39.90, train_loss_epoch=39.90]Epoch 7:   0%|          | 0/1 [00:00<?, ?it/s, loss=54, v_num=1, train_loss_step=39.90, train_loss_epoch=39.90]        Epoch 8:   0%|          | 0/1 [00:00<?, ?it/s, loss=54, v_num=1, train_loss_step=39.90, train_loss_epoch=39.90]Epoch 8: 100%|##########| 1/1 [00:00<00:00, 33.77it/s, loss=54, v_num=1, train_loss_step=39.90, train_loss_epoch=39.90]Epoch 8: 100%|##########| 1/1 [00:00<00:00, 33.32it/s, loss=52.2, v_num=1, train_loss_step=37.90, train_loss_epoch=39.90]Epoch 8: 100%|##########| 1/1 [00:00<00:00, 32.64it/s, loss=52.2, v_num=1, train_loss_step=37.90, train_loss_epoch=37.90]Epoch 8:   0%|          | 0/1 [00:00<?, ?it/s, loss=52.2, v_num=1, train_loss_step=37.90, train_loss_epoch=37.90]        Epoch 9:   0%|          | 0/1 [00:00<?, ?it/s, loss=52.2, v_num=1, train_loss_step=37.90, train_loss_epoch=37.90]Epoch 9: 100%|##########| 1/1 [00:00<00:00, 35.02it/s, loss=52.2, v_num=1, train_loss_step=37.90, train_loss_epoch=37.90]Epoch 9: 100%|##########| 1/1 [00:00<00:00, 34.55it/s, loss=50.6, v_num=1, train_loss_step=36.60, train_loss_epoch=37.90]Epoch 9: 100%|##########| 1/1 [00:00<00:00, 33.90it/s, loss=50.6, v_num=1, train_loss_step=36.60, train_loss_epoch=36.60]Epoch 9:   0%|          | 0/1 [00:00<?, ?it/s, loss=50.6, v_num=1, train_loss_step=36.60, train_loss_epoch=36.60]        Epoch 10:   0%|          | 0/1 [00:00<?, ?it/s, loss=50.6, v_num=1, train_loss_step=36.60, train_loss_epoch=36.60]Epoch 10: 100%|##########| 1/1 [00:00<00:00, 34.34it/s, loss=50.6, v_num=1, train_loss_step=36.60, train_loss_epoch=36.60]Epoch 10: 100%|##########| 1/1 [00:00<00:00, 33.81it/s, loss=48.9, v_num=1, train_loss_step=31.50, train_loss_epoch=36.60]Epoch 10: 100%|##########| 1/1 [00:00<00:00, 33.07it/s, loss=48.9, v_num=1, train_loss_step=31.50, train_loss_epoch=31.50]Epoch 10:   0%|          | 0/1 [00:00<?, ?it/s, loss=48.9, v_num=1, train_loss_step=31.50, train_loss_epoch=31.50]        Epoch 11:   0%|          | 0/1 [00:00<?, ?it/s, loss=48.9, v_num=1, train_loss_step=31.50, train_loss_epoch=31.50]Epoch 11: 100%|##########| 1/1 [00:00<00:00, 35.28it/s, loss=48.9, v_num=1, train_loss_step=31.50, train_loss_epoch=31.50]Epoch 11: 100%|##########| 1/1 [00:00<00:00, 34.77it/s, loss=47.2, v_num=1, train_loss_step=28.60, train_loss_epoch=31.50]Epoch 11: 100%|##########| 1/1 [00:00<00:00, 34.07it/s, loss=47.2, v_num=1, train_loss_step=28.60, train_loss_epoch=28.60]Epoch 11:   0%|          | 0/1 [00:00<?, ?it/s, loss=47.2, v_num=1, train_loss_step=28.60, train_loss_epoch=28.60]        Epoch 12:   0%|          | 0/1 [00:00<?, ?it/s, loss=47.2, v_num=1, train_loss_step=28.60, train_loss_epoch=28.60]Epoch 12: 100%|##########| 1/1 [00:00<00:00, 33.06it/s, loss=47.2, v_num=1, train_loss_step=28.60, train_loss_epoch=28.60]Epoch 12: 100%|##########| 1/1 [00:00<00:00, 32.65it/s, loss=45.6, v_num=1, train_loss_step=26.20, train_loss_epoch=28.60]Epoch 12: 100%|##########| 1/1 [00:00<00:00, 32.02it/s, loss=45.6, v_num=1, train_loss_step=26.20, train_loss_epoch=26.20]Epoch 12:   0%|          | 0/1 [00:00<?, ?it/s, loss=45.6, v_num=1, train_loss_step=26.20, train_loss_epoch=26.20]        Epoch 13:   0%|          | 0/1 [00:00<?, ?it/s, loss=45.6, v_num=1, train_loss_step=26.20, train_loss_epoch=26.20]Epoch 13: 100%|##########| 1/1 [00:00<00:00, 34.26it/s, loss=45.6, v_num=1, train_loss_step=26.20, train_loss_epoch=26.20]Epoch 13: 100%|##########| 1/1 [00:00<00:00, 33.77it/s, loss=44, v_num=1, train_loss_step=23.20, train_loss_epoch=26.20]  Epoch 13: 100%|##########| 1/1 [00:00<00:00, 33.04it/s, loss=44, v_num=1, train_loss_step=23.20, train_loss_epoch=23.20]Epoch 13:   0%|          | 0/1 [00:00<?, ?it/s, loss=44, v_num=1, train_loss_step=23.20, train_loss_epoch=23.20]        Epoch 14:   0%|          | 0/1 [00:00<?, ?it/s, loss=44, v_num=1, train_loss_step=23.20, train_loss_epoch=23.20]Epoch 14: 100%|##########| 1/1 [00:00<00:00, 35.60it/s, loss=44, v_num=1, train_loss_step=23.20, train_loss_epoch=23.20]Epoch 14: 100%|##########| 1/1 [00:00<00:00, 35.10it/s, loss=42.8, v_num=1, train_loss_step=25.80, train_loss_epoch=23.20]Epoch 14: 100%|##########| 1/1 [00:00<00:00, 34.32it/s, loss=42.8, v_num=1, train_loss_step=25.80, train_loss_epoch=25.80]Epoch 14:   0%|          | 0/1 [00:00<?, ?it/s, loss=42.8, v_num=1, train_loss_step=25.80, train_loss_epoch=25.80]        Epoch 15:   0%|          | 0/1 [00:00<?, ?it/s, loss=42.8, v_num=1, train_loss_step=25.80, train_loss_epoch=25.80]Epoch 15: 100%|##########| 1/1 [00:00<00:00, 32.76it/s, loss=42.8, v_num=1, train_loss_step=25.80, train_loss_epoch=25.80]Epoch 15: 100%|##########| 1/1 [00:00<00:00, 32.34it/s, loss=41.6, v_num=1, train_loss_step=24.50, train_loss_epoch=25.80]Epoch 15: 100%|##########| 1/1 [00:00<00:00, 31.70it/s, loss=41.6, v_num=1, train_loss_step=24.50, train_loss_epoch=24.50]Epoch 15:   0%|          | 0/1 [00:00<?, ?it/s, loss=41.6, v_num=1, train_loss_step=24.50, train_loss_epoch=24.50]        Epoch 16:   0%|          | 0/1 [00:00<?, ?it/s, loss=41.6, v_num=1, train_loss_step=24.50, train_loss_epoch=24.50]Epoch 16: 100%|##########| 1/1 [00:00<00:00, 34.62it/s, loss=41.6, v_num=1, train_loss_step=24.50, train_loss_epoch=24.50]Epoch 16: 100%|##########| 1/1 [00:00<00:00, 34.16it/s, loss=40.3, v_num=1, train_loss_step=19.80, train_loss_epoch=24.50]Epoch 16: 100%|##########| 1/1 [00:00<00:00, 33.51it/s, loss=40.3, v_num=1, train_loss_step=19.80, train_loss_epoch=19.80]Epoch 16:   0%|          | 0/1 [00:00<?, ?it/s, loss=40.3, v_num=1, train_loss_step=19.80, train_loss_epoch=19.80]        Epoch 17:   0%|          | 0/1 [00:00<?, ?it/s, loss=40.3, v_num=1, train_loss_step=19.80, train_loss_epoch=19.80]Epoch 17: 100%|##########| 1/1 [00:00<00:00, 34.83it/s, loss=40.3, v_num=1, train_loss_step=19.80, train_loss_epoch=19.80]Epoch 17: 100%|##########| 1/1 [00:00<00:00, 34.35it/s, loss=39.3, v_num=1, train_loss_step=21.20, train_loss_epoch=19.80]Epoch 17: 100%|##########| 1/1 [00:00<00:00, 33.60it/s, loss=39.3, v_num=1, train_loss_step=21.20, train_loss_epoch=21.20]Epoch 17:   0%|          | 0/1 [00:00<?, ?it/s, loss=39.3, v_num=1, train_loss_step=21.20, train_loss_epoch=21.20]        Epoch 18:   0%|          | 0/1 [00:00<?, ?it/s, loss=39.3, v_num=1, train_loss_step=21.20, train_loss_epoch=21.20]Epoch 18: 100%|##########| 1/1 [00:00<00:00, 36.72it/s, loss=39.3, v_num=1, train_loss_step=21.20, train_loss_epoch=21.20]Epoch 18: 100%|##########| 1/1 [00:00<00:00, 36.14it/s, loss=38.1, v_num=1, train_loss_step=17.50, train_loss_epoch=21.20]Epoch 18: 100%|##########| 1/1 [00:00<00:00, 35.29it/s, loss=38.1, v_num=1, train_loss_step=17.50, train_loss_epoch=17.50]Epoch 18:   0%|          | 0/1 [00:00<?, ?it/s, loss=38.1, v_num=1, train_loss_step=17.50, train_loss_epoch=17.50]        Epoch 19:   0%|          | 0/1 [00:00<?, ?it/s, loss=38.1, v_num=1, train_loss_step=17.50, train_loss_epoch=17.50]Epoch 19: 100%|##########| 1/1 [00:00<00:00, 33.59it/s, loss=38.1, v_num=1, train_loss_step=17.50, train_loss_epoch=17.50]Epoch 19: 100%|##########| 1/1 [00:00<00:00, 33.10it/s, loss=37.2, v_num=1, train_loss_step=18.70, train_loss_epoch=17.50]Epoch 19: 100%|##########| 1/1 [00:00<00:00, 32.45it/s, loss=37.2, v_num=1, train_loss_step=18.70, train_loss_epoch=18.70]Epoch 19:   0%|          | 0/1 [00:00<?, ?it/s, loss=37.2, v_num=1, train_loss_step=18.70, train_loss_epoch=18.70]        Epoch 20:   0%|          | 0/1 [00:00<?, ?it/s, loss=37.2, v_num=1, train_loss_step=18.70, train_loss_epoch=18.70]Epoch 20: 100%|##########| 1/1 [00:00<00:00, 35.35it/s, loss=37.2, v_num=1, train_loss_step=18.70, train_loss_epoch=18.70]Epoch 20: 100%|##########| 1/1 [00:00<00:00, 34.87it/s, loss=35.7, v_num=1, train_loss_step=17.30, train_loss_epoch=18.70]Epoch 20: 100%|##########| 1/1 [00:00<00:00, 34.09it/s, loss=35.7, v_num=1, train_loss_step=17.30, train_loss_epoch=17.30]Epoch 20:   0%|          | 0/1 [00:00<?, ?it/s, loss=35.7, v_num=1, train_loss_step=17.30, train_loss_epoch=17.30]        Epoch 21:   0%|          | 0/1 [00:00<?, ?it/s, loss=35.7, v_num=1, train_loss_step=17.30, train_loss_epoch=17.30]Epoch 21: 100%|##########| 1/1 [00:00<00:00, 35.73it/s, loss=35.7, v_num=1, train_loss_step=17.30, train_loss_epoch=17.30]Epoch 21: 100%|##########| 1/1 [00:00<00:00, 35.21it/s, loss=32.6, v_num=1, train_loss_step=16.10, train_loss_epoch=17.30]Epoch 21: 100%|##########| 1/1 [00:00<00:00, 34.40it/s, loss=32.6, v_num=1, train_loss_step=16.10, train_loss_epoch=16.10]Epoch 21:   0%|          | 0/1 [00:00<?, ?it/s, loss=32.6, v_num=1, train_loss_step=16.10, train_loss_epoch=16.10]        Epoch 22:   0%|          | 0/1 [00:00<?, ?it/s, loss=32.6, v_num=1, train_loss_step=16.10, train_loss_epoch=16.10]Epoch 22: 100%|##########| 1/1 [00:00<00:00, 35.04it/s, loss=32.6, v_num=1, train_loss_step=16.10, train_loss_epoch=16.10]Epoch 22: 100%|##########| 1/1 [00:00<00:00, 34.52it/s, loss=29.4, v_num=1, train_loss_step=16.30, train_loss_epoch=16.10]Epoch 22: 100%|##########| 1/1 [00:00<00:00, 33.78it/s, loss=29.4, v_num=1, train_loss_step=16.30, train_loss_epoch=16.30]Epoch 22:   0%|          | 0/1 [00:00<?, ?it/s, loss=29.4, v_num=1, train_loss_step=16.30, train_loss_epoch=16.30]        Epoch 23:   0%|          | 0/1 [00:00<?, ?it/s, loss=29.4, v_num=1, train_loss_step=16.30, train_loss_epoch=16.30]Epoch 23: 100%|##########| 1/1 [00:00<00:00, 35.31it/s, loss=29.4, v_num=1, train_loss_step=16.30, train_loss_epoch=16.30]Epoch 23: 100%|##########| 1/1 [00:00<00:00, 34.78it/s, loss=27.8, v_num=1, train_loss_step=15.00, train_loss_epoch=16.30]Epoch 23: 100%|##########| 1/1 [00:00<00:00, 33.96it/s, loss=27.8, v_num=1, train_loss_step=15.00, train_loss_epoch=15.00]Epoch 23:   0%|          | 0/1 [00:00<?, ?it/s, loss=27.8, v_num=1, train_loss_step=15.00, train_loss_epoch=15.00]        Epoch 24:   0%|          | 0/1 [00:00<?, ?it/s, loss=27.8, v_num=1, train_loss_step=15.00, train_loss_epoch=15.00]Epoch 24: 100%|##########| 1/1 [00:00<00:00, 33.34it/s, loss=27.8, v_num=1, train_loss_step=15.00, train_loss_epoch=15.00]Epoch 24: 100%|##########| 1/1 [00:00<00:00, 32.92it/s, loss=25.9, v_num=1, train_loss_step=15.20, train_loss_epoch=15.00]Epoch 24: 100%|##########| 1/1 [00:00<00:00, 32.33it/s, loss=25.9, v_num=1, train_loss_step=15.20, train_loss_epoch=15.20]Epoch 24:   0%|          | 0/1 [00:00<?, ?it/s, loss=25.9, v_num=1, train_loss_step=15.20, train_loss_epoch=15.20]        Epoch 25:   0%|          | 0/1 [00:00<?, ?it/s, loss=25.9, v_num=1, train_loss_step=15.20, train_loss_epoch=15.20]Epoch 25: 100%|##########| 1/1 [00:00<00:00, 35.94it/s, loss=25.9, v_num=1, train_loss_step=15.20, train_loss_epoch=15.20]Epoch 25: 100%|##########| 1/1 [00:00<00:00, 35.43it/s, loss=24.5, v_num=1, train_loss_step=14.00, train_loss_epoch=15.20]Epoch 25: 100%|##########| 1/1 [00:00<00:00, 34.63it/s, loss=24.5, v_num=1, train_loss_step=14.00, train_loss_epoch=14.00]Epoch 25:   0%|          | 0/1 [00:00<?, ?it/s, loss=24.5, v_num=1, train_loss_step=14.00, train_loss_epoch=14.00]        Epoch 26:   0%|          | 0/1 [00:00<?, ?it/s, loss=24.5, v_num=1, train_loss_step=14.00, train_loss_epoch=14.00]Epoch 26: 100%|##########| 1/1 [00:00<00:00, 33.38it/s, loss=24.5, v_num=1, train_loss_step=14.00, train_loss_epoch=14.00]Epoch 26: 100%|##########| 1/1 [00:00<00:00, 32.92it/s, loss=23, v_num=1, train_loss_step=14.70, train_loss_epoch=14.00]  Epoch 26: 100%|##########| 1/1 [00:00<00:00, 32.23it/s, loss=23, v_num=1, train_loss_step=14.70, train_loss_epoch=14.70]Epoch 26:   0%|          | 0/1 [00:00<?, ?it/s, loss=23, v_num=1, train_loss_step=14.70, train_loss_epoch=14.70]        Epoch 27:   0%|          | 0/1 [00:00<?, ?it/s, loss=23, v_num=1, train_loss_step=14.70, train_loss_epoch=14.70]Epoch 27: 100%|##########| 1/1 [00:00<00:00, 33.86it/s, loss=23, v_num=1, train_loss_step=14.70, train_loss_epoch=14.70]Epoch 27: 100%|##########| 1/1 [00:00<00:00, 33.41it/s, loss=21.7, v_num=1, train_loss_step=13.50, train_loss_epoch=14.70]Epoch 27: 100%|##########| 1/1 [00:00<00:00, 32.71it/s, loss=21.7, v_num=1, train_loss_step=13.50, train_loss_epoch=13.50]Epoch 27:   0%|          | 0/1 [00:00<?, ?it/s, loss=21.7, v_num=1, train_loss_step=13.50, train_loss_epoch=13.50]        Epoch 28:   0%|          | 0/1 [00:00<?, ?it/s, loss=21.7, v_num=1, train_loss_step=13.50, train_loss_epoch=13.50]Epoch 28: 100%|##########| 1/1 [00:00<00:00, 34.35it/s, loss=21.7, v_num=1, train_loss_step=13.50, train_loss_epoch=13.50]Epoch 28: 100%|##########| 1/1 [00:00<00:00, 33.93it/s, loss=20.5, v_num=1, train_loss_step=13.80, train_loss_epoch=13.50]Epoch 28: 100%|##########| 1/1 [00:00<00:00, 33.27it/s, loss=20.5, v_num=1, train_loss_step=13.80, train_loss_epoch=13.80]Epoch 28:   0%|          | 0/1 [00:00<?, ?it/s, loss=20.5, v_num=1, train_loss_step=13.80, train_loss_epoch=13.80]        Epoch 29:   0%|          | 0/1 [00:00<?, ?it/s, loss=20.5, v_num=1, train_loss_step=13.80, train_loss_epoch=13.80]Epoch 29: 100%|##########| 1/1 [00:00<00:00, 35.16it/s, loss=20.5, v_num=1, train_loss_step=13.80, train_loss_epoch=13.80]Epoch 29: 100%|##########| 1/1 [00:00<00:00, 34.72it/s, loss=19.3, v_num=1, train_loss_step=12.40, train_loss_epoch=13.80]Epoch 29: 100%|##########| 1/1 [00:00<00:00, 33.97it/s, loss=19.3, v_num=1, train_loss_step=12.40, train_loss_epoch=12.40]Epoch 29:   0%|          | 0/1 [00:00<?, ?it/s, loss=19.3, v_num=1, train_loss_step=12.40, train_loss_epoch=12.40]        Epoch 30:   0%|          | 0/1 [00:00<?, ?it/s, loss=19.3, v_num=1, train_loss_step=12.40, train_loss_epoch=12.40]Epoch 30: 100%|##########| 1/1 [00:00<00:00, 34.31it/s, loss=19.3, v_num=1, train_loss_step=12.40, train_loss_epoch=12.40]Epoch 30: 100%|##########| 1/1 [00:00<00:00, 33.79it/s, loss=18.3, v_num=1, train_loss_step=13.00, train_loss_epoch=12.40]Epoch 30: 100%|##########| 1/1 [00:00<00:00, 33.06it/s, loss=18.3, v_num=1, train_loss_step=13.00, train_loss_epoch=13.00]Epoch 30:   0%|          | 0/1 [00:00<?, ?it/s, loss=18.3, v_num=1, train_loss_step=13.00, train_loss_epoch=13.00]        Epoch 31:   0%|          | 0/1 [00:00<?, ?it/s, loss=18.3, v_num=1, train_loss_step=13.00, train_loss_epoch=13.00]Epoch 31: 100%|##########| 1/1 [00:00<00:00, 34.00it/s, loss=18.3, v_num=1, train_loss_step=13.00, train_loss_epoch=13.00]Epoch 31: 100%|##########| 1/1 [00:00<00:00, 33.52it/s, loss=17.5, v_num=1, train_loss_step=12.20, train_loss_epoch=13.00]Epoch 31: 100%|##########| 1/1 [00:00<00:00, 32.82it/s, loss=17.5, v_num=1, train_loss_step=12.20, train_loss_epoch=12.20]Epoch 31:   0%|          | 0/1 [00:00<?, ?it/s, loss=17.5, v_num=1, train_loss_step=12.20, train_loss_epoch=12.20]        Epoch 32:   0%|          | 0/1 [00:00<?, ?it/s, loss=17.5, v_num=1, train_loss_step=12.20, train_loss_epoch=12.20]Epoch 32: 100%|##########| 1/1 [00:00<00:00, 33.73it/s, loss=17.5, v_num=1, train_loss_step=12.20, train_loss_epoch=12.20]Epoch 32: 100%|##########| 1/1 [00:00<00:00, 33.28it/s, loss=16.8, v_num=1, train_loss_step=12.20, train_loss_epoch=12.20]Epoch 32: 100%|##########| 1/1 [00:00<00:00, 32.63it/s, loss=16.8, v_num=1, train_loss_step=12.20, train_loss_epoch=12.20]Epoch 32:   0%|          | 0/1 [00:00<?, ?it/s, loss=16.8, v_num=1, train_loss_step=12.20, train_loss_epoch=12.20]        Epoch 33:   0%|          | 0/1 [00:00<?, ?it/s, loss=16.8, v_num=1, train_loss_step=12.20, train_loss_epoch=12.20]Epoch 33: 100%|##########| 1/1 [00:00<00:00, 33.47it/s, loss=16.8, v_num=1, train_loss_step=12.20, train_loss_epoch=12.20]Epoch 33: 100%|##########| 1/1 [00:00<00:00, 33.03it/s, loss=16.3, v_num=1, train_loss_step=12.10, train_loss_epoch=12.20]Epoch 33: 100%|##########| 1/1 [00:00<00:00, 32.38it/s, loss=16.3, v_num=1, train_loss_step=12.10, train_loss_epoch=12.10]Epoch 33:   0%|          | 0/1 [00:00<?, ?it/s, loss=16.3, v_num=1, train_loss_step=12.10, train_loss_epoch=12.10]        Epoch 34:   0%|          | 0/1 [00:00<?, ?it/s, loss=16.3, v_num=1, train_loss_step=12.10, train_loss_epoch=12.10]Epoch 34: 100%|##########| 1/1 [00:00<00:00, 34.97it/s, loss=16.3, v_num=1, train_loss_step=12.10, train_loss_epoch=12.10]Epoch 34: 100%|##########| 1/1 [00:00<00:00, 34.53it/s, loss=15.6, v_num=1, train_loss_step=12.00, train_loss_epoch=12.10]Epoch 34: 100%|##########| 1/1 [00:00<00:00, 33.85it/s, loss=15.6, v_num=1, train_loss_step=12.00, train_loss_epoch=12.00]Epoch 34:   0%|          | 0/1 [00:00<?, ?it/s, loss=15.6, v_num=1, train_loss_step=12.00, train_loss_epoch=12.00]        Epoch 35:   0%|          | 0/1 [00:00<?, ?it/s, loss=15.6, v_num=1, train_loss_step=12.00, train_loss_epoch=12.00]Epoch 35: 100%|##########| 1/1 [00:00<00:00, 34.06it/s, loss=15.6, v_num=1, train_loss_step=12.00, train_loss_epoch=12.00]Epoch 35: 100%|##########| 1/1 [00:00<00:00, 33.57it/s, loss=14.9, v_num=1, train_loss_step=12.00, train_loss_epoch=12.00]Epoch 35: 100%|##########| 1/1 [00:00<00:00, 32.90it/s, loss=14.9, v_num=1, train_loss_step=12.00, train_loss_epoch=12.00]Epoch 35:   0%|          | 0/1 [00:00<?, ?it/s, loss=14.9, v_num=1, train_loss_step=12.00, train_loss_epoch=12.00]        Epoch 36:   0%|          | 0/1 [00:00<?, ?it/s, loss=14.9, v_num=1, train_loss_step=12.00, train_loss_epoch=12.00]Epoch 36: 100%|##########| 1/1 [00:00<00:00, 33.68it/s, loss=14.9, v_num=1, train_loss_step=12.00, train_loss_epoch=12.00]Epoch 36: 100%|##########| 1/1 [00:00<00:00, 33.23it/s, loss=14.5, v_num=1, train_loss_step=11.70, train_loss_epoch=12.00]Epoch 36: 100%|##########| 1/1 [00:00<00:00, 32.54it/s, loss=14.5, v_num=1, train_loss_step=11.70, train_loss_epoch=11.70]Epoch 36:   0%|          | 0/1 [00:00<?, ?it/s, loss=14.5, v_num=1, train_loss_step=11.70, train_loss_epoch=11.70]        Epoch 37:   0%|          | 0/1 [00:00<?, ?it/s, loss=14.5, v_num=1, train_loss_step=11.70, train_loss_epoch=11.70]Epoch 37: 100%|##########| 1/1 [00:00<00:00, 33.81it/s, loss=14.5, v_num=1, train_loss_step=11.70, train_loss_epoch=11.70]Epoch 37: 100%|##########| 1/1 [00:00<00:00, 33.35it/s, loss=14, v_num=1, train_loss_step=11.00, train_loss_epoch=11.70]  Epoch 37: 100%|##########| 1/1 [00:00<00:00, 32.68it/s, loss=14, v_num=1, train_loss_step=11.00, train_loss_epoch=11.00]Epoch 37:   0%|          | 0/1 [00:00<?, ?it/s, loss=14, v_num=1, train_loss_step=11.00, train_loss_epoch=11.00]        Epoch 38:   0%|          | 0/1 [00:00<?, ?it/s, loss=14, v_num=1, train_loss_step=11.00, train_loss_epoch=11.00]Epoch 38: 100%|##########| 1/1 [00:00<00:00, 33.67it/s, loss=14, v_num=1, train_loss_step=11.00, train_loss_epoch=11.00]Epoch 38: 100%|##########| 1/1 [00:00<00:00, 33.22it/s, loss=13.7, v_num=1, train_loss_step=10.80, train_loss_epoch=11.00]Epoch 38: 100%|##########| 1/1 [00:00<00:00, 32.53it/s, loss=13.7, v_num=1, train_loss_step=10.80, train_loss_epoch=10.80]Epoch 38:   0%|          | 0/1 [00:00<?, ?it/s, loss=13.7, v_num=1, train_loss_step=10.80, train_loss_epoch=10.80]        Epoch 39:   0%|          | 0/1 [00:00<?, ?it/s, loss=13.7, v_num=1, train_loss_step=10.80, train_loss_epoch=10.80]Epoch 39: 100%|##########| 1/1 [00:00<00:00, 36.46it/s, loss=13.7, v_num=1, train_loss_step=10.80, train_loss_epoch=10.80]Epoch 39: 100%|##########| 1/1 [00:00<00:00, 35.98it/s, loss=13.3, v_num=1, train_loss_step=10.70, train_loss_epoch=10.80]Epoch 39: 100%|##########| 1/1 [00:00<00:00, 35.27it/s, loss=13.3, v_num=1, train_loss_step=10.70, train_loss_epoch=10.70]Epoch 39:   0%|          | 0/1 [00:00<?, ?it/s, loss=13.3, v_num=1, train_loss_step=10.70, train_loss_epoch=10.70]        Epoch 40:   0%|          | 0/1 [00:00<?, ?it/s, loss=13.3, v_num=1, train_loss_step=10.70, train_loss_epoch=10.70]Epoch 40: 100%|##########| 1/1 [00:00<00:00, 33.82it/s, loss=13.3, v_num=1, train_loss_step=10.70, train_loss_epoch=10.70]Epoch 40: 100%|##########| 1/1 [00:00<00:00, 33.37it/s, loss=13, v_num=1, train_loss_step=10.70, train_loss_epoch=10.70]  Epoch 40: 100%|##########| 1/1 [00:00<00:00, 32.71it/s, loss=13, v_num=1, train_loss_step=10.70, train_loss_epoch=10.70]Epoch 40:   0%|          | 0/1 [00:00<?, ?it/s, loss=13, v_num=1, train_loss_step=10.70, train_loss_epoch=10.70]        Epoch 41:   0%|          | 0/1 [00:00<?, ?it/s, loss=13, v_num=1, train_loss_step=10.70, train_loss_epoch=10.70]Epoch 41: 100%|##########| 1/1 [00:00<00:00, 34.97it/s, loss=13, v_num=1, train_loss_step=10.70, train_loss_epoch=10.70]Epoch 41: 100%|##########| 1/1 [00:00<00:00, 34.49it/s, loss=12.7, v_num=1, train_loss_step=10.50, train_loss_epoch=10.70]Epoch 41: 100%|##########| 1/1 [00:00<00:00, 33.77it/s, loss=12.7, v_num=1, train_loss_step=10.50, train_loss_epoch=10.50]Epoch 41:   0%|          | 0/1 [00:00<?, ?it/s, loss=12.7, v_num=1, train_loss_step=10.50, train_loss_epoch=10.50]        Epoch 42:   0%|          | 0/1 [00:00<?, ?it/s, loss=12.7, v_num=1, train_loss_step=10.50, train_loss_epoch=10.50]Epoch 42: 100%|##########| 1/1 [00:00<00:00, 34.70it/s, loss=12.7, v_num=1, train_loss_step=10.50, train_loss_epoch=10.50]Epoch 42: 100%|##########| 1/1 [00:00<00:00, 34.23it/s, loss=12.4, v_num=1, train_loss_step=9.980, train_loss_epoch=10.50]Epoch 42: 100%|##########| 1/1 [00:00<00:00, 33.53it/s, loss=12.4, v_num=1, train_loss_step=9.980, train_loss_epoch=9.980]Epoch 42:   0%|          | 0/1 [00:00<?, ?it/s, loss=12.4, v_num=1, train_loss_step=9.980, train_loss_epoch=9.980]        Epoch 43:   0%|          | 0/1 [00:00<?, ?it/s, loss=12.4, v_num=1, train_loss_step=9.980, train_loss_epoch=9.980]Epoch 43: 100%|##########| 1/1 [00:00<00:00, 36.32it/s, loss=12.4, v_num=1, train_loss_step=9.980, train_loss_epoch=9.980]Epoch 43: 100%|##########| 1/1 [00:00<00:00, 35.81it/s, loss=12.1, v_num=1, train_loss_step=9.840, train_loss_epoch=9.980]Epoch 43: 100%|##########| 1/1 [00:00<00:00, 35.11it/s, loss=12.1, v_num=1, train_loss_step=9.840, train_loss_epoch=9.840]Epoch 43:   0%|          | 0/1 [00:00<?, ?it/s, loss=12.1, v_num=1, train_loss_step=9.840, train_loss_epoch=9.840]        Epoch 44:   0%|          | 0/1 [00:00<?, ?it/s, loss=12.1, v_num=1, train_loss_step=9.840, train_loss_epoch=9.840]Epoch 44: 100%|##########| 1/1 [00:00<00:00, 33.18it/s, loss=12.1, v_num=1, train_loss_step=9.840, train_loss_epoch=9.840]Epoch 44: 100%|##########| 1/1 [00:00<00:00, 32.74it/s, loss=11.8, v_num=1, train_loss_step=9.930, train_loss_epoch=9.840]Epoch 44: 100%|##########| 1/1 [00:00<00:00, 32.14it/s, loss=11.8, v_num=1, train_loss_step=9.930, train_loss_epoch=9.930]Epoch 44:   0%|          | 0/1 [00:00<?, ?it/s, loss=11.8, v_num=1, train_loss_step=9.930, train_loss_epoch=9.930]        Epoch 45:   0%|          | 0/1 [00:00<?, ?it/s, loss=11.8, v_num=1, train_loss_step=9.930, train_loss_epoch=9.930]Epoch 45: 100%|##########| 1/1 [00:00<00:00, 35.60it/s, loss=11.8, v_num=1, train_loss_step=9.930, train_loss_epoch=9.930]Epoch 45: 100%|##########| 1/1 [00:00<00:00, 35.11it/s, loss=11.7, v_num=1, train_loss_step=10.20, train_loss_epoch=9.930]Epoch 45: 100%|##########| 1/1 [00:00<00:00, 34.34it/s, loss=11.7, v_num=1, train_loss_step=10.20, train_loss_epoch=10.20]Epoch 45:   0%|          | 0/1 [00:00<?, ?it/s, loss=11.7, v_num=1, train_loss_step=10.20, train_loss_epoch=10.20]        Epoch 46:   0%|          | 0/1 [00:00<?, ?it/s, loss=11.7, v_num=1, train_loss_step=10.20, train_loss_epoch=10.20]Epoch 46: 100%|##########| 1/1 [00:00<00:00, 36.18it/s, loss=11.7, v_num=1, train_loss_step=10.20, train_loss_epoch=10.20]Epoch 46: 100%|##########| 1/1 [00:00<00:00, 35.68it/s, loss=11.4, v_num=1, train_loss_step=10.40, train_loss_epoch=10.20]Epoch 46: 100%|##########| 1/1 [00:00<00:00, 34.93it/s, loss=11.4, v_num=1, train_loss_step=10.40, train_loss_epoch=10.40]Epoch 46:   0%|          | 0/1 [00:00<?, ?it/s, loss=11.4, v_num=1, train_loss_step=10.40, train_loss_epoch=10.40]        Epoch 47:   0%|          | 0/1 [00:00<?, ?it/s, loss=11.4, v_num=1, train_loss_step=10.40, train_loss_epoch=10.40]Epoch 47: 100%|##########| 1/1 [00:00<00:00, 35.06it/s, loss=11.4, v_num=1, train_loss_step=10.40, train_loss_epoch=10.40]Epoch 47: 100%|##########| 1/1 [00:00<00:00, 34.56it/s, loss=11.3, v_num=1, train_loss_step=10.00, train_loss_epoch=10.40]Epoch 47: 100%|##########| 1/1 [00:00<00:00, 33.81it/s, loss=11.3, v_num=1, train_loss_step=10.00, train_loss_epoch=10.00]Epoch 47:   0%|          | 0/1 [00:00<?, ?it/s, loss=11.3, v_num=1, train_loss_step=10.00, train_loss_epoch=10.00]        Epoch 48:   0%|          | 0/1 [00:00<?, ?it/s, loss=11.3, v_num=1, train_loss_step=10.00, train_loss_epoch=10.00]Epoch 48: 100%|##########| 1/1 [00:00<00:00, 33.63it/s, loss=11.3, v_num=1, train_loss_step=10.00, train_loss_epoch=10.00]Epoch 48: 100%|##########| 1/1 [00:00<00:00, 33.22it/s, loss=11, v_num=1, train_loss_step=9.390, train_loss_epoch=10.00]  Epoch 48: 100%|##########| 1/1 [00:00<00:00, 32.63it/s, loss=11, v_num=1, train_loss_step=9.390, train_loss_epoch=9.390]Epoch 48:   0%|          | 0/1 [00:00<?, ?it/s, loss=11, v_num=1, train_loss_step=9.390, train_loss_epoch=9.390]        Epoch 49:   0%|          | 0/1 [00:00<?, ?it/s, loss=11, v_num=1, train_loss_step=9.390, train_loss_epoch=9.390]Epoch 49: 100%|##########| 1/1 [00:00<00:00, 33.93it/s, loss=11, v_num=1, train_loss_step=9.390, train_loss_epoch=9.390]Epoch 49: 100%|##########| 1/1 [00:00<00:00, 33.46it/s, loss=10.9, v_num=1, train_loss_step=9.840, train_loss_epoch=9.390]Epoch 49: 100%|##########| 1/1 [00:00<00:00, 32.08it/s, loss=10.9, v_num=1, train_loss_step=9.840, train_loss_epoch=9.840]Epoch 49: 100%|##########| 1/1 [00:00<00:00, 11.37it/s, loss=10.9, v_num=1, train_loss_step=9.840, train_loss_epoch=9.840]
Predicting: 1it [00:00, ?it/s]Predicting:   0%|          | 0/1 [00:00<00:00, -28728.11it/s]Predicting DataLoader 0:   0%|          | 0/1 [00:00<?, ?it/s]Predicting DataLoader 0: 100%|##########| 1/1 [00:00<00:00, 507.42it/s]Predicting DataLoader 0: 100%|##########| 1/1 [00:00<00:00, 430.36it/s]
<AxesSubplot:xlabel='ds'>

# #| hide
# np.testing.assert_almost_equal(
#     y_hat,
#     np.array([
#         416.3054, 393.8008, 470.5799, 457.6244, 462.8301, 551.377 ,
#         625.2131, 627.285 , 547.3862, 462.755 , 406.449 , 459.006 
#     ], dtype=np.float32),
#     decimal=4
# )
# #| hide
# error = np.mean((Y_test_df['y'] - Y_test_df['N-BEATS']) ** 2)
# assert error <= 600