forecaster
¶
Classes:
| Name | Description |
|---|---|
DeepForecaster |
Incremental PyTorch forecaster compatible with River's time-series API. |
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 |