Nbeats
polars_ts.dl.nbeats
N-BEATS: Neural Basis Expansion Analysis for Time Series.
Implements the N-BEATS architecture (Oreshkin et al., ICLR 2020) with both generic and interpretable (trend + seasonality) stack types.
References
Oreshkin et al. (2020). N-BEATS: Neural basis expansion analysis for interpretable time series forecasting. ICLR.
_GenericBlock
Bases: Module
Generic N-BEATS block with learnable basis.
_TrendBlock
Bases: Module
Interpretable trend block using polynomial basis.
_SeasonalityBlock
Bases: Module
Interpretable seasonality block using Fourier basis.
_NBEATSNet
Bases: Module
Full N-BEATS network.
NBEATSForecaster
N-BEATS time series forecaster.
Parameters
h
Forecast horizon.
input_size
Lookback window size.
hidden_size
Hidden layer size in each block.
n_stacks
Number of stacks (only used with default stack_types).
n_blocks
Number of blocks per stack.
stack_types
List of stack types: "generic", "trend", "seasonality".
If None, uses n_stacks generic stacks.
max_epochs
Maximum training epochs.
lr
Learning rate.
batch_size
Training batch size.
id_col, time_col, target_col
Column names.
fit(df)
Train the N-BEATS model on historical data.
Parameters
df Panel DataFrame with historical observations.
Returns
NBEATSForecaster Self, for chaining.
predict(df)
Generate forecasts for each series.
Parameters
df
Panel DataFrame (uses last input_size observations per series).
Returns
pl.DataFrame
Columns: [id_col, time_col, y_hat].