SlidingWindowReconstruct#
- class anomalearn.algorithms.preprocessing.SlidingWindowReconstruct.SlidingWindowReconstruct(window: int = 10, stride: int = 1)#
Bases:
IShapeChanger
,AbstractPipelineSavableLayer
Preprocessing object transforming the input using the sliding window technique.
The object takes as input a time series, thus an array-like with two dimensions.
- Parameters:
Attributes
- __json_file#
Inherited attributes
- _pipeline_class#
List of properties
Gets the number of points seen in the last call to shape_change.
List of methods
__eq__
(other)Return self==value.
__ne__
(other)Return self!=value.
__repr__
()Return repr(self).
__str__
()Return str(self).
copy
()Copies the object.
get_hyperparameters
(*args, **kwargs)Gets all the hyperparameters of the model and their allowed values.
Gets the input shape expected by the layer, eventually symbolic.
Gets the output shape expected by the layer, eventually symbolic.
load
(path, *args, **kwargs)Loads all the parameters of the model.
save
(path, *args, **kwargs)Saves the objects state.
set_hyperparameters
(hyperparameters, *args, ...)Sets the hyperparameters of the model.
shape_change
(x[, y])Builds input and target vectors doing sliding window.
List of class methods
load_model
(path, *args, **kwargs)Loads the saved object from a folder.
List of inherited methods
_get_all_params
([deep])Gets all the parameters and attributes of the model.
get_params
([deep])Gets all the parameters (public attributes) of the model.
Gets the class to be used in the pipeline when the model has multiple allowed interfaces.
set_params
(**params)Modify the parameters of the object.
set_pipeline_class
(interface)Set which interface must be used by the pipeline.
Properties
- property points_seen#
Gets the number of points seen in the last call to shape_change.
- Returns:
The number of points seen in the last call to shape_change.
- Return type:
points_seen
Methods
- __eq__(other)#
Return self==value.
- __ne__(other)#
Return self!=value.
- __repr__()#
Return repr(self).
- __str__()#
Return str(self).
- copy() SlidingWindowReconstruct #
Copies the object.
- Returns:
new_obj – A new object identical to this.
- Return type:
- get_hyperparameters(*args, **kwargs) dict #
Gets all the hyperparameters of the model and their allowed values.
- Parameters:
args – Not used, present to allow multiple inheritance and signature change.
kwargs – Not used, present to allow multiple inheritance and signature change.
- Returns:
hyperparameters – A dictionary with all the hyperparameters and the set of their possible values. Every key of the dictionary is the name of the hyperparameter. Each value of the dictionary is another dictionary with two keys: “value” and “set”. The former key identifies the current value of the hyperparameter, the latter identifies the allowed values for the model. The allowed values for the model may be one of Categorical, Integer or Real classes from skopt.
- Return type:
- get_input_shape() tuple #
Gets the input shape expected by the layer, eventually symbolic.
- Returns:
expected_input_shape – It is the tuple representing the type of input shape that the layer expects as input. The tuple must be complete, considering all dimensions. If a dimension can be variable, it should be expressed with a string/letter, e.g., (“n”, 5, 4) if the layer receives arrays with any dimensionality for axis 0 and dimension 5 and 5 for axis 1 and 2. If two letters are identical, they represent the same value, e.g. (“n”, “n”) can be any array with two dimensions with equal value such as (5, 5) or (100, 100).
- Return type:
- get_output_shape() tuple #
Gets the output shape expected by the layer, eventually symbolic.
- Returns:
expected_output_shape – It is the tuple representing the type of output shape that the layer will emit. The tuple must be complete, considering all dimensions. If a dimension can be variable, it should be expressed with a string/letter, e.g., (“n”, 5, 4) if the layer receives arrays with any dimensionality for axis 0 and dimension 5 and 5 for axis 1 and 2. If two letters are identical, they represent the same value, e.g. (“n”, “n”) can be any array with two dimensions with equal value such as (5, 5) or (100, 100).
- Return type:
- load(path: str, *args, **kwargs) SlidingWindowReconstruct #
Loads all the parameters of the model.
- Parameters:
path (str) – It is the path of the directory in which the object has been saved.
args – Not used, present to allow multiple inheritance and signature change.
kwargs – Not used, present to allow multiple inheritance and signature change.
- Returns:
Instance to itself to allow chain calls.
- Return type:
self
- Raises:
ValueError – If the given path does not point to a saved model.
- save(path, *args, **kwargs) SlidingWindowReconstruct #
Saves the objects state.
- Parameters:
path (path-like) – It is the path of the folder in which the object will be saved.
args – Not used, present to allow multiple inheritance and signature change.
kwargs – Not used, present to allow multiple inheritance and signature change.
- Returns:
Instance to itself to allow chain calls.
- Return type:
self
- Raises:
ValueError – If the given path points to an existing file and not to a directory.
- set_hyperparameters(hyperparameters: dict, *args, **kwargs) None #
Sets the hyperparameters of the model.
- Parameters:
hyperparameters (dict) – A dictionary with all the hyperparameters values. Each key is the name of a hyperparameter and the value is the value assumed by the parameter.
args – Not used, present to allow multiple inheritance and signature change.
kwargs – Not used, present to allow multiple inheritance and signature change.
- Return type:
None
- shape_change(x, y=None, *args, **kwargs) Tuple[ndarray, ndarray] #
Builds input and target vectors doing sliding window.
The sliding window is performed such that a window has as targets itself.
- Parameters:
x (array-like of shape (n_samples, n_features)) – It is the data to be reshaped using the sliding window approach.
y – Ignored.
- Returns:
x_new (array-like) – The sliding windows of the time series with given window and stride. Its shape is (n_samples, window, n_features).
y_new (array-like) – An array identical to x_new.
Class methods
- classmethod load_model(path: str, *args, **kwargs) SlidingWindowReconstruct #
Loads the saved object from a folder.
- Parameters:
path (str) – It is the path of the directory in which the object has been saved.
args – Not used, present to allow multiple inheritance and signature change.
kwargs – Not used, present to allow multiple inheritance and signature change.
- Returns:
The instance of the saved object.
- Return type:
model
Inherited methods
- get_pipeline_class()#
Gets the class to be used in the pipeline when the model has multiple allowed interfaces.
- Returns:
The interface to be used for the object.
- Return type:
interface_to_use
- set_params(**params) None #
Modify the parameters of the object.
- Parameters:
params – The dictionary of the parameters to modify.
- Return type:
None
- set_pipeline_class(interface) IPipelineLayer #
Set which interface must be used by the pipeline.
- Parameters:
interface – One of the interfaces of the object that must be used in the pipeline, or None to reset it.
- Returns:
Instance to itself
- Return type:
self