aPriori.NN.VectorScaler¶
- class aPriori.NN.VectorScaler(mode='minmax', modulus=False, log=False, vmin=None, vmax=None, copy=True)¶
Description:¶
A class for scaling and transforming vector data. This class supports various scaling modes, such as min-max scaling, standard scaling, and mean scaling, with additional options for modulus transformation, logarithmic scaling, and value clipping.
- The operations are performed in the following order:
Modulus transformation
Clipping
Logarithmic transformation (with an automatic clipping at 1e-20 to avoid negative or zero values)
Scaling based on the specified mode
Attributes:¶
- mode (str):
The scaling mode. Options are ‘minmax’, ‘standard’, ‘mean’, or None.
- modulus (bool):
Whether to apply the modulus (absolute value) operation.
- log (bool):
Whether to apply logarithmic transformation.
- vmin (float, optional):
Minimum value for clipping.
- vmax (float, optional):
Maximum value for clipping.
- copy (bool):
Whether to create a copy of the input array.
- max, min, mean, std, ptp (float):
calculated scaling parameters, depending on mode.
Methods:¶
- __init__(mode=’minmax’, modulus=False, log=False, vmin=None, vmax=None, copy=True):
Initialize the VectorScaler with scaling mode, transformation options, and optional clipping bounds.
- _preprocess_input(x):
Preprocess the input array by applying modulus, clipping, and logarithmic transformations.
- _reset():
Reset the scaler attributes (max, min, mean, std, ptp) to None. Used before recalculating parameters.
- fit(x):
Fit the VectorScaler to the data by calculating the necessary statistics based on the specified mode.
- transform(x):
Transform the input data based on the fitted scaling parameters and mode.
- load(state_dict):
Load saved state values into the VectorScaler.
- state_dict:
Return the current state of the VectorScaler, including mode and calculated parameters.
- mode = 'minmax'¶
- modulus = False¶
- log = False¶
- vmin = None¶
- vmax = None¶
- copy = True¶
- max = None¶
- min = None¶
- mean = None¶
- std = None¶
- ptp = None¶
- fit(x)¶
Fit the VectorScaler to the data by calculating the necessary statistics based on the specified mode.
Parameters:¶
- x (array-like):
The data to fit the scaler to.
Raises:¶
- ValueError:
If the mode is unrecognized.
- transform(x)¶
Transform the input data based on the fitted scaling parameters and mode.
Parameters:¶
- x (array-like):
The data to transform.
Returns:¶
- :
- np.ndarray:
The scaled and transformed data.
Raises:¶
- ValueError:
If the mode is unrecognized.