rapid_models.preprocessing.scalers
Convenience scaling functions for rapid-models. For more scaling functions refer to e.g. https://scikit-learn.org/stable/modules/classes.html#module-sklearn.preprocessing
Module Contents
Functions
|
Input x = points in [0, 1]^n |
|
Inverse of scale_x_to_box |
|
Standardize features by removing the mean and scaling to unit variance. |
|
Rescale features based on specified mean and std. |
- rapid_models.preprocessing.scalers.scale_x_to_box(x, bounds)[source]
Input x = points in [0, 1]^n output scaled to lie in the box given by bounds
- rapid_models.preprocessing.scalers.standardScaler(x, mean=None, std=None, dim=0, tensorType='torch', bReturnParam=False)[source]
Standardize features by removing the mean and scaling to unit variance. The standard score of a sample $x$ is calculated as:
$$ x_{out} =
rac{x - x.mean()}{x.std()} $$
- Args:
x (array-like, ND): Array of features to be scaled. mean (float, default=None): Specify the mean that will be subtracted from
the features in $x$. If _None_, the mean will be calculated from the features as mean=x.mean().
- std (float, default=None): Specify the std that the features in $x$ will
be scaled by. If _None_, the std will be calculated from the features as std=x.std() (unbiased).
- dim (int or tuple of python:ints, defalt=0): The dimension or dimensions
to reduce to establish the mean and std if these are _None_.
- tensorType (str, default=torch): Specify if torch. or numpy. functions
are used.
- bReturnParam (bool, default=False): Specify if the function should return
the mean and std used in the scaling. Should be _True_ if mean and std is _None_ to retain the parameters.
- Returns:
x_out (array-like, ND): Scaled features.
if bReturnParam=True the function return a tuple with (x_out, mean, std)
- rapid_models.preprocessing.scalers.standardReScaler(x, mean, std)[source]
Rescale features based on specified mean and std.
$$ x_{out} = x*x.std() + x.mean()
- Parameters:
x (array-like, ND) – Array of features to be rescaled.
mean (float, default=None) – Specify the mean that will be added to the features in $x$ after rescaling.
std (float, default=None) – Specify the std that the features in $x$ will be rescaled by.
- Returns:
Re-scaled features.
- Return type:
x_out (array-like, ND)