forecasting
¶
This module contains forecasters for the deep_river package.
Modules:
| Name | Description |
|---|---|
forecaster |
|
zoo |
|
Classes:
| Name | Description |
|---|---|
DeepForecaster |
Incremental PyTorch forecaster compatible with River's time-series API. |
GRUForecaster |
Autoregressive forecaster backed by |
LSTMForecaster |
Autoregressive forecaster backed by |
LinearForecaster |
Autoregressive linear forecaster with optional exogenous features. |
LiquidForecaster |
Autoregressive forecaster backed by closed-form liquid recurrent cells. |
MLPForecaster |
Autoregressive multi-layer perceptron forecaster. |
NBEATSForecaster |
Compact N-BEATS-style residual MLP forecaster for online point forecasts. |
RNNForecaster |
Autoregressive forecaster backed by |
DeepForecaster
¶
DeepForecaster(
module: Module,
loss_fn: Union[str, Callable] = "mse",
optimizer_fn: Union[str, Type[Optimizer]] = "sgd",
lr: float = 0.001,
is_feature_incremental: bool = False,
device: str = "cpu",
seed: int = 42,
window_size: int = 10,
is_sequence_model: bool = False,
gradient_clip_value: float | None = 1.0,
**kwargs
)
Bases: DeepEstimator, Forecaster
Incremental PyTorch forecaster compatible with River's time-series API.
DeepForecaster learns a one-step-ahead model from the recent endogenous
target history and optional exogenous features. Multi-step forecasts are
produced autoregressively by feeding each predicted value back into a copied
history buffer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
module
|
Module
|
PyTorch module. In flat mode it receives a tensor of shape
|
required |
window_size
|
int
|
Number of past target values used as autoregressive context. |
10
|
is_sequence_model
|
bool
|
Whether |
False
|
loss_fn
|
Union[str, Callable]
|
|
'mse'
|
optimizer_fn
|
Union[str, Callable]
|
|
'mse'
|
lr
|
Union[str, Callable]
|
|
'mse'
|
is_feature_incremental
|
Union[str, Callable]
|
|
'mse'
|
device
|
Union[str, Callable]
|
|
'mse'
|
seed
|
Union[str, Callable]
|
|
'mse'
|
gradient_clip_value
|
float | None
|
Standard deep-river estimator configuration. |
1.0
|
**kwargs
|
float | None
|
Standard deep-river estimator configuration. |
1.0
|
Methods:
| Name | Description |
|---|---|
clone |
Return a fresh estimator instance with (optionally) copied state. |
draw |
Render a (partial) computational graph of the wrapped model. |
forecast |
Forecast |
learn_one |
Update the model with one target and optional exogenous features. |
load |
Load a previously saved estimator. |
save |
Persist the estimator (architecture, weights, optimiser & runtime state). |
Source code in deep_river/forecasting/forecaster.py
clone
¶
Return a fresh estimator instance with (optionally) copied state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
new_params
|
dict | None
|
Parameter overrides for the cloned instance. |
None
|
include_attributes
|
bool
|
If True, runtime state (observed features, buffers) is also copied. |
False
|
copy_weights
|
bool
|
If True, model weights are copied (otherwise the module is re‑initialised). |
False
|
Source code in deep_river/base.py
draw
¶
Render a (partial) computational graph of the wrapped model.
Imports graphviz and torchviz lazily. Raises an informative
ImportError if the optional dependencies are not installed.
Source code in deep_river/base.py
forecast
¶
Forecast horizon steps ahead using autoregressive rollouts.
Source code in deep_river/forecasting/forecaster.py
learn_one
¶
Update the model with one target and optional exogenous features.
Source code in deep_river/forecasting/forecaster.py
load
classmethod
¶
Load a previously saved estimator.
The method reconstructs the estimator class, its wrapped module, optimiser state and runtime information (feature names, buffers, etc.).
Source code in deep_river/base.py
save
¶
Persist the estimator (architecture, weights, optimiser & runtime state).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filepath
|
str | Path
|
Destination file. Parent directories are created automatically. |
required |
Source code in deep_river/base.py
GRUForecaster
¶
GRUForecaster(
n_features: int = 0,
window_size: int = 10,
hidden_size: int = 16,
num_layers: int = 1,
dropout: float = 0.0,
loss_fn: Union[str, Callable] = "mse",
optimizer_fn: Union[str, Type[Optimizer]] = "adam",
lr: float = 0.001,
is_feature_incremental: bool = False,
device: str = "cpu",
seed: int = 42,
gradient_clip_value: float | None = 1.0,
**kwargs
)
Bases: DeepForecaster
Autoregressive forecaster backed by torch.nn.GRU.
Methods:
| Name | Description |
|---|---|
clone |
Return a fresh estimator instance with (optionally) copied state. |
draw |
Render a (partial) computational graph of the wrapped model. |
forecast |
Forecast |
learn_one |
Update the model with one target and optional exogenous features. |
load |
Load a previously saved estimator. |
save |
Persist the estimator (architecture, weights, optimiser & runtime state). |
Source code in deep_river/forecasting/zoo.py
clone
¶
Return a fresh estimator instance with (optionally) copied state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
new_params
|
dict | None
|
Parameter overrides for the cloned instance. |
None
|
include_attributes
|
bool
|
If True, runtime state (observed features, buffers) is also copied. |
False
|
copy_weights
|
bool
|
If True, model weights are copied (otherwise the module is re‑initialised). |
False
|
Source code in deep_river/base.py
draw
¶
Render a (partial) computational graph of the wrapped model.
Imports graphviz and torchviz lazily. Raises an informative
ImportError if the optional dependencies are not installed.
Source code in deep_river/base.py
forecast
¶
Forecast horizon steps ahead using autoregressive rollouts.
Source code in deep_river/forecasting/forecaster.py
learn_one
¶
Update the model with one target and optional exogenous features.
Source code in deep_river/forecasting/forecaster.py
load
classmethod
¶
Load a previously saved estimator.
The method reconstructs the estimator class, its wrapped module, optimiser state and runtime information (feature names, buffers, etc.).
Source code in deep_river/base.py
save
¶
Persist the estimator (architecture, weights, optimiser & runtime state).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filepath
|
str | Path
|
Destination file. Parent directories are created automatically. |
required |
Source code in deep_river/base.py
LSTMForecaster
¶
LSTMForecaster(
n_features: int = 0,
window_size: int = 10,
hidden_size: int = 16,
num_layers: int = 1,
dropout: float = 0.0,
loss_fn: Union[str, Callable] = "mse",
optimizer_fn: Union[str, Type[Optimizer]] = "adam",
lr: float = 0.001,
is_feature_incremental: bool = False,
device: str = "cpu",
seed: int = 42,
gradient_clip_value: float | None = 1.0,
**kwargs
)
Bases: DeepForecaster
Autoregressive forecaster backed by torch.nn.LSTM.
Methods:
| Name | Description |
|---|---|
clone |
Return a fresh estimator instance with (optionally) copied state. |
draw |
Render a (partial) computational graph of the wrapped model. |
forecast |
Forecast |
learn_one |
Update the model with one target and optional exogenous features. |
load |
Load a previously saved estimator. |
save |
Persist the estimator (architecture, weights, optimiser & runtime state). |
Source code in deep_river/forecasting/zoo.py
clone
¶
Return a fresh estimator instance with (optionally) copied state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
new_params
|
dict | None
|
Parameter overrides for the cloned instance. |
None
|
include_attributes
|
bool
|
If True, runtime state (observed features, buffers) is also copied. |
False
|
copy_weights
|
bool
|
If True, model weights are copied (otherwise the module is re‑initialised). |
False
|
Source code in deep_river/base.py
draw
¶
Render a (partial) computational graph of the wrapped model.
Imports graphviz and torchviz lazily. Raises an informative
ImportError if the optional dependencies are not installed.
Source code in deep_river/base.py
forecast
¶
Forecast horizon steps ahead using autoregressive rollouts.
Source code in deep_river/forecasting/forecaster.py
learn_one
¶
Update the model with one target and optional exogenous features.
Source code in deep_river/forecasting/forecaster.py
load
classmethod
¶
Load a previously saved estimator.
The method reconstructs the estimator class, its wrapped module, optimiser state and runtime information (feature names, buffers, etc.).
Source code in deep_river/base.py
save
¶
Persist the estimator (architecture, weights, optimiser & runtime state).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filepath
|
str | Path
|
Destination file. Parent directories are created automatically. |
required |
Source code in deep_river/base.py
LinearForecaster
¶
LinearForecaster(
n_features: int = 0,
window_size: int = 10,
loss_fn: Union[str, Callable] = "mse",
optimizer_fn: Union[str, Type[Optimizer]] = "sgd",
lr: float = 0.001,
is_feature_incremental: bool = False,
device: str = "cpu",
seed: int = 42,
gradient_clip_value: float | None = 1.0,
**kwargs
)
Bases: DeepForecaster
Autoregressive linear forecaster with optional exogenous features.
Methods:
| Name | Description |
|---|---|
clone |
Return a fresh estimator instance with (optionally) copied state. |
draw |
Render a (partial) computational graph of the wrapped model. |
forecast |
Forecast |
learn_one |
Update the model with one target and optional exogenous features. |
load |
Load a previously saved estimator. |
save |
Persist the estimator (architecture, weights, optimiser & runtime state). |
Source code in deep_river/forecasting/zoo.py
clone
¶
Return a fresh estimator instance with (optionally) copied state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
new_params
|
dict | None
|
Parameter overrides for the cloned instance. |
None
|
include_attributes
|
bool
|
If True, runtime state (observed features, buffers) is also copied. |
False
|
copy_weights
|
bool
|
If True, model weights are copied (otherwise the module is re‑initialised). |
False
|
Source code in deep_river/base.py
draw
¶
Render a (partial) computational graph of the wrapped model.
Imports graphviz and torchviz lazily. Raises an informative
ImportError if the optional dependencies are not installed.
Source code in deep_river/base.py
forecast
¶
Forecast horizon steps ahead using autoregressive rollouts.
Source code in deep_river/forecasting/forecaster.py
learn_one
¶
Update the model with one target and optional exogenous features.
Source code in deep_river/forecasting/forecaster.py
load
classmethod
¶
Load a previously saved estimator.
The method reconstructs the estimator class, its wrapped module, optimiser state and runtime information (feature names, buffers, etc.).
Source code in deep_river/base.py
save
¶
Persist the estimator (architecture, weights, optimiser & runtime state).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filepath
|
str | Path
|
Destination file. Parent directories are created automatically. |
required |
Source code in deep_river/base.py
LiquidForecaster
¶
LiquidForecaster(
n_features: int = 0,
window_size: int = 10,
hidden_size: int = 16,
num_layers: int = 1,
dropout: float = 0.0,
time_delta: float = 1.0,
loss_fn: Union[str, Callable] = "mse",
optimizer_fn: Union[str, Type[Optimizer]] = "adam",
lr: float = 0.001,
is_feature_incremental: bool = False,
device: str = "cpu",
seed: int = 42,
gradient_clip_value: float | None = 1.0,
**kwargs
)
Bases: DeepForecaster
Autoregressive forecaster backed by closed-form liquid recurrent cells.
The recurrent state follows a fixed-step liquid update where each hidden unit
learns a positive time constant. time_delta is constant across all steps,
matching regularly sampled time series.
Methods:
| Name | Description |
|---|---|
clone |
Return a fresh estimator instance with (optionally) copied state. |
draw |
Render a (partial) computational graph of the wrapped model. |
forecast |
Forecast |
learn_one |
Update the model with one target and optional exogenous features. |
load |
Load a previously saved estimator. |
save |
Persist the estimator (architecture, weights, optimiser & runtime state). |
Source code in deep_river/forecasting/zoo.py
clone
¶
Return a fresh estimator instance with (optionally) copied state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
new_params
|
dict | None
|
Parameter overrides for the cloned instance. |
None
|
include_attributes
|
bool
|
If True, runtime state (observed features, buffers) is also copied. |
False
|
copy_weights
|
bool
|
If True, model weights are copied (otherwise the module is re‑initialised). |
False
|
Source code in deep_river/base.py
draw
¶
Render a (partial) computational graph of the wrapped model.
Imports graphviz and torchviz lazily. Raises an informative
ImportError if the optional dependencies are not installed.
Source code in deep_river/base.py
forecast
¶
Forecast horizon steps ahead using autoregressive rollouts.
Source code in deep_river/forecasting/forecaster.py
learn_one
¶
Update the model with one target and optional exogenous features.
Source code in deep_river/forecasting/forecaster.py
load
classmethod
¶
Load a previously saved estimator.
The method reconstructs the estimator class, its wrapped module, optimiser state and runtime information (feature names, buffers, etc.).
Source code in deep_river/base.py
save
¶
Persist the estimator (architecture, weights, optimiser & runtime state).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filepath
|
str | Path
|
Destination file. Parent directories are created automatically. |
required |
Source code in deep_river/base.py
MLPForecaster
¶
MLPForecaster(
n_features: int = 0,
window_size: int = 10,
n_width: int = 16,
n_layers: int = 2,
loss_fn: Union[str, Callable] = "mse",
optimizer_fn: Union[str, Type[Optimizer]] = "adam",
lr: float = 0.001,
is_feature_incremental: bool = False,
device: str = "cpu",
seed: int = 42,
gradient_clip_value: float | None = 1.0,
**kwargs
)
Bases: DeepForecaster
Autoregressive multi-layer perceptron forecaster.
Methods:
| Name | Description |
|---|---|
clone |
Return a fresh estimator instance with (optionally) copied state. |
draw |
Render a (partial) computational graph of the wrapped model. |
forecast |
Forecast |
learn_one |
Update the model with one target and optional exogenous features. |
load |
Load a previously saved estimator. |
save |
Persist the estimator (architecture, weights, optimiser & runtime state). |
Source code in deep_river/forecasting/zoo.py
clone
¶
Return a fresh estimator instance with (optionally) copied state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
new_params
|
dict | None
|
Parameter overrides for the cloned instance. |
None
|
include_attributes
|
bool
|
If True, runtime state (observed features, buffers) is also copied. |
False
|
copy_weights
|
bool
|
If True, model weights are copied (otherwise the module is re‑initialised). |
False
|
Source code in deep_river/base.py
draw
¶
Render a (partial) computational graph of the wrapped model.
Imports graphviz and torchviz lazily. Raises an informative
ImportError if the optional dependencies are not installed.
Source code in deep_river/base.py
forecast
¶
Forecast horizon steps ahead using autoregressive rollouts.
Source code in deep_river/forecasting/forecaster.py
learn_one
¶
Update the model with one target and optional exogenous features.
Source code in deep_river/forecasting/forecaster.py
load
classmethod
¶
Load a previously saved estimator.
The method reconstructs the estimator class, its wrapped module, optimiser state and runtime information (feature names, buffers, etc.).
Source code in deep_river/base.py
save
¶
Persist the estimator (architecture, weights, optimiser & runtime state).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filepath
|
str | Path
|
Destination file. Parent directories are created automatically. |
required |
Source code in deep_river/base.py
NBEATSForecaster
¶
NBEATSForecaster(
n_features: int = 0,
window_size: int = 10,
n_width: int = 32,
n_layers: int = 2,
n_blocks: int = 2,
loss_fn: Union[str, Callable] = "mse",
optimizer_fn: Union[str, Type[Optimizer]] = "adam",
lr: float = 0.001,
is_feature_incremental: bool = False,
device: str = "cpu",
seed: int = 42,
gradient_clip_value: float | None = 1.0,
**kwargs
)
Bases: DeepForecaster
Compact N-BEATS-style residual MLP forecaster for online point forecasts.
Methods:
| Name | Description |
|---|---|
clone |
Return a fresh estimator instance with (optionally) copied state. |
draw |
Render a (partial) computational graph of the wrapped model. |
forecast |
Forecast |
learn_one |
Update the model with one target and optional exogenous features. |
load |
Load a previously saved estimator. |
save |
Persist the estimator (architecture, weights, optimiser & runtime state). |
Source code in deep_river/forecasting/zoo.py
clone
¶
Return a fresh estimator instance with (optionally) copied state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
new_params
|
dict | None
|
Parameter overrides for the cloned instance. |
None
|
include_attributes
|
bool
|
If True, runtime state (observed features, buffers) is also copied. |
False
|
copy_weights
|
bool
|
If True, model weights are copied (otherwise the module is re‑initialised). |
False
|
Source code in deep_river/base.py
draw
¶
Render a (partial) computational graph of the wrapped model.
Imports graphviz and torchviz lazily. Raises an informative
ImportError if the optional dependencies are not installed.
Source code in deep_river/base.py
forecast
¶
Forecast horizon steps ahead using autoregressive rollouts.
Source code in deep_river/forecasting/forecaster.py
learn_one
¶
Update the model with one target and optional exogenous features.
Source code in deep_river/forecasting/forecaster.py
load
classmethod
¶
Load a previously saved estimator.
The method reconstructs the estimator class, its wrapped module, optimiser state and runtime information (feature names, buffers, etc.).
Source code in deep_river/base.py
save
¶
Persist the estimator (architecture, weights, optimiser & runtime state).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filepath
|
str | Path
|
Destination file. Parent directories are created automatically. |
required |
Source code in deep_river/base.py
RNNForecaster
¶
RNNForecaster(
n_features: int = 0,
window_size: int = 10,
hidden_size: int = 16,
num_layers: int = 1,
nonlinearity: str = "tanh",
dropout: float = 0.0,
loss_fn: Union[str, Callable] = "mse",
optimizer_fn: Union[str, Type[Optimizer]] = "adam",
lr: float = 0.001,
is_feature_incremental: bool = False,
device: str = "cpu",
seed: int = 42,
gradient_clip_value: float | None = 1.0,
**kwargs
)
Bases: DeepForecaster
Autoregressive forecaster backed by torch.nn.RNN.
Methods:
| Name | Description |
|---|---|
clone |
Return a fresh estimator instance with (optionally) copied state. |
draw |
Render a (partial) computational graph of the wrapped model. |
forecast |
Forecast |
learn_one |
Update the model with one target and optional exogenous features. |
load |
Load a previously saved estimator. |
save |
Persist the estimator (architecture, weights, optimiser & runtime state). |
Source code in deep_river/forecasting/zoo.py
clone
¶
Return a fresh estimator instance with (optionally) copied state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
new_params
|
dict | None
|
Parameter overrides for the cloned instance. |
None
|
include_attributes
|
bool
|
If True, runtime state (observed features, buffers) is also copied. |
False
|
copy_weights
|
bool
|
If True, model weights are copied (otherwise the module is re‑initialised). |
False
|
Source code in deep_river/base.py
draw
¶
Render a (partial) computational graph of the wrapped model.
Imports graphviz and torchviz lazily. Raises an informative
ImportError if the optional dependencies are not installed.
Source code in deep_river/base.py
forecast
¶
Forecast horizon steps ahead using autoregressive rollouts.
Source code in deep_river/forecasting/forecaster.py
learn_one
¶
Update the model with one target and optional exogenous features.
Source code in deep_river/forecasting/forecaster.py
load
classmethod
¶
Load a previously saved estimator.
The method reconstructs the estimator class, its wrapped module, optimiser state and runtime information (feature names, buffers, etc.).
Source code in deep_river/base.py
save
¶
Persist the estimator (architecture, weights, optimiser & runtime state).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filepath
|
str | Path
|
Destination file. Parent directories are created automatically. |
required |