StandardScaler#

class anomalearn.algorithms.transformers.StandardScaler.StandardScaler(copy: bool = True, with_mean: bool = True, with_std: bool = True)#

Bases: ITransformer, IParametric, AbstractPipelineSavableLayer

Standard scaler wrapper for scikit-learn.

_standard_scaler#

It is an instance of the scikit-learn StandardScaler.

Type:

scikit-learn StandardScaler

Attributes

__scikit_file#

Inherited attributes

_pipeline_class#

List of properties

copy_attribute

Get the copy from scikit wrapped object.

seen_features_in

Get the n_features_in_ from scikit wrapped object if present.

seen_features_names_in

Get the feature_names_in_ from scikit wrapped object if present.

seen_mean

Get the mean_ from scikit wrapped object if present.

seen_samples_in

Get the n_samples_seen_ from scikit wrapped object if present.

seen_scale

Get the scale_ from scikit wrapped object if present.

seen_var

Get the var_ from scikit wrapped object if present.

with_mean

Get the with_mean from scikit wrapped object.

with_std

Get the with_std from scikit wrapped object.

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.

fit(x[, y])

Fits the model to the given training data.

get_input_shape()

Gets the input shape expected by the layer, eventually symbolic.

get_output_shape()

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.

transform(x, *args, **kwargs)

Transforms the input.

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_hyperparameters(*args, **kwargs)

Gets all the hyperparameters of the model and their allowed values.

get_params([deep])

Gets all the parameters (public attributes) of the model.

get_pipeline_class()

Gets the class to be used in the pipeline when the model has multiple allowed interfaces.

set_hyperparameters(hyperparameters, *args, ...)

Sets the hyperparameters of the model.

set_params(**params)

Modify the parameters of the object.

set_pipeline_class(interface)

Set which interface must be used by the pipeline.

Properties

property copy_attribute#

Get the copy from scikit wrapped object.

Returns:

The value of copy.

Return type:

copy

property seen_features_in#

Get the n_features_in_ from scikit wrapped object if present.

Returns:

The value of n_features_in_ if present, None otherwise.

Return type:

n_features_in_

property seen_features_names_in#

Get the feature_names_in_ from scikit wrapped object if present.

Returns:

The value of feature_names_in_ if present, None otherwise.

Return type:

feature_names_in_

property seen_mean#

Get the mean_ from scikit wrapped object if present.

Returns:

The value of mean_ if present, None otherwise.

Return type:

mean_

property seen_samples_in#

Get the n_samples_seen_ from scikit wrapped object if present.

Returns:

The value of n_samples_seen_ if present, None otherwise.

Return type:

n_samples_seen_

property seen_scale#

Get the scale_ from scikit wrapped object if present.

Returns:

The value of scale_ if present, None otherwise.

Return type:

scale_

property seen_var#

Get the var_ from scikit wrapped object if present.

Returns:

The value of var_ if present, None otherwise.

Return type:

var_

property with_mean#

Get the with_mean from scikit wrapped object.

Returns:

The value of with_mean.

Return type:

with_mean

property with_std#

Get the with_std from scikit wrapped object.

Returns:

The value of with_std.

Return type:

with_std

Methods

__eq__(other)#

Return self==value.

__ne__(other)#

Return self!=value.

__repr__()#

Return repr(self).

__str__()#

Return str(self).

copy() StandardScaler#

Copies the object.

Note that since scikit-learn does not provide standard save and load methods for objects, and it does not provide a complete copy method, deepcopy will be used.

Returns:

new_object – The copied object.

Return type:

MinMaxScaler

fit(x, y=None, *args, **kwargs) None#

Fits the model to the given training data.

Parameters:
  • x (array-like) – The data used for fitting. Data must have at least two dimensions in which the first dimension represent the number of samples.

  • y (array-like, default=None) – The target for the fitting data. Data must have at least two dimensions in which the first dimension represent the number of samples. Moreover, if not None, the first dimension must be the same as that of x.

  • 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

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:

tuple

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:

tuple

load(path: str, *args, **kwargs) StandardScaler#

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) StandardScaler#

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.

transform(x, *args, **kwargs) ndarray#

Transforms the input.

Parameters:
  • x (array-like) – The data to transform. Data must have at least two dimensions in which the first dimension represent the number of samples.

  • args – Not used, present to allow multiple inheritance and signature change.

  • kwargs – Not used, present to allow multiple inheritance and signature change.

Returns:

transformations – The transformations for the points in input.

Return type:

ndarray with shape[0]=x.shape[0]

Class methods

classmethod load_model(path: str, *args, **kwargs) StandardScaler#

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_all_params(deep=True) dict#

Gets all the parameters and attributes of the model.

Parameters:

deep (bool, default=True) – States whether the method must return also the parameters of nested base models.

Returns:

param_dict – Dictionary with parameters’ names as keys and values as values.

Return type:

dict

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:

dict

get_params(deep=True) dict#

Gets all the parameters (public attributes) of the model.

Parameters:

deep (bool, default=True) – States whether the method must return also the parameters of nested base models.

Returns:

param_dict – Dictionary with parameters’ names as keys and values as values.

Return type:

dict

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_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

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