rolling_ae
¶
Classes:
Name | Description |
---|---|
RollingAutoencoder |
Wrapper for PyTorch autoencoder models that uses the networks |
RollingAutoencoderInitialized |
|
RollingAutoencoder
¶
RollingAutoencoder(
module: Type[Module],
loss_fn: Union[str, Callable] = "mse",
optimizer_fn: Union[str, Callable] = "sgd",
lr: float = 0.001,
device: str = "cpu",
seed: int = 42,
window_size: int = 10,
append_predict: bool = False,
**kwargs
)
Bases: RollingDeepEstimator
, AnomalyDetector
Wrapper for PyTorch autoencoder models that uses the networks reconstruction error for scoring the anomalousness of a given example. The class also features a rolling window to allow the model to make predictions based on the reconstructability of multiple previous examples.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
module
|
Type[Module]
|
Torch module that builds the autoencoder to be wrapped.
The module should accept inputs with shape
|
required |
loss_fn
|
Union[str, Callable]
|
Loss function to be used for training the wrapped model. Can be a
loss function provided by |
'mse'
|
optimizer_fn
|
Union[str, Callable]
|
Optimizer to be used for training the wrapped model. Can be an
optimizer class provided by |
'sgd'
|
lr
|
float
|
Learning rate of the optimizer. |
0.001
|
device
|
str
|
Device to run the wrapped model on. Can be "cpu" or "cuda". |
'cpu'
|
seed
|
int
|
Random seed to be used for training the wrapped model. |
42
|
window_size
|
int
|
Size of the rolling window used for storing previous examples. |
10
|
append_predict
|
bool
|
Whether to append inputs passed for prediction to the rolling window. |
False
|
**kwargs
|
Parameters to be passed to the |
{}
|
Methods:
Name | Description |
---|---|
clone |
Clones the estimator. |
draw |
Draws the wrapped model. |
initialize_module |
Parameters |
learn_many |
Performs one step of training with a batch of examples. |
learn_one |
Performs one step of training with a single example. |
Source code in deep_river/anomaly/rolling_ae.py
clone
¶
Clones the estimator.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
new_params
|
dict[Any, Any] | None
|
New parameters to be passed to the cloned estimator. |
None
|
include_attributes
|
If True, the attributes of the estimator will be copied to the cloned estimator. This is useful when the estimator is a transformer and the attributes are the learned parameters. |
False
|
Returns:
Type | Description |
---|---|
DeepEstimator
|
The cloned estimator. |
Source code in deep_river/base.py
draw
¶
Draws the wrapped model.
Source code in deep_river/base.py
initialize_module
¶
Parameters:
Name | Type | Description | Default |
---|---|---|---|
module
|
The instance or class or callable to be initialized, e.g.
|
required | |
kwargs
|
dict
|
The keyword arguments to initialize the instance or class. Can be an empty dict. |
{}
|
Returns:
Type | Description |
---|---|
instance
|
The initialized component. |
Source code in deep_river/base.py
learn_many
¶
Performs one step of training with a batch of examples.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X
|
DataFrame
|
Input batch of examples. |
required |
y
|
Should be None |
None
|
Returns:
Type | Description |
---|---|
RollingAutoencoder
|
The estimator itself. |
Source code in deep_river/anomaly/rolling_ae.py
learn_one
¶
Performs one step of training with a single example.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
dict
|
Input example. |
required |
Returns:
Type | Description |
---|---|
RollingAutoencoder
|
The estimator itself. |
Source code in deep_river/anomaly/rolling_ae.py
RollingAutoencoderInitialized
¶
RollingAutoencoderInitialized(
module: Module,
loss_fn: Union[str, Callable] = "mse",
optimizer_fn: Union[str, Callable] = "sgd",
lr: float = 0.001,
device: str = "cpu",
seed: int = 42,
window_size: int = 10,
append_predict: bool = False,
**kwargs
)
Bases: RollingDeepEstimatorInitialized
, AnomalyDetector