bridgescaler.group#
Classes#
Scaler that enables calculation and sharing of scaling parameters among multiple variables via variable groupings. |
|
Group version of MinMaxScaler |
|
Group version of RobustScaler |
Module Contents#
- class bridgescaler.group.GroupBaseScaler#
Bases:
object- groups_ = None#
- group_index_ = None#
- x_columns_ = None#
- extract_x_columns(x)#
Extract the variable names to be transformed from x depending on if x is a pandas DataFrame, an xarray DataArray, or a numpy array. All of these assume that the columns are in the last dimension. If x is an xarray DataArray, there should be a coorindate variable with the same name as the last dimension of the DataArray being transformed.
- Parameters:
x (Union[pandas.DataFrame, xarray.DataArray, numpy.ndarray]) – array of values to be transformed.
- Returns:
Array of values to be transformed.
- Return type:
xv (numpy.ndarray)
- static package_transformed_x(x_transformed, x)#
Repackaged a transformed numpy array into the same datatype as the original x, including all metadata.
- Parameters:
x_transformed (numpy.ndarray) – array after being transformed or inverse transformed
x (Union[pandas.DataFrame, xarray.DataArray, numpy.ndarray])
Returns:
- fit(x, groups=None)#
- fit_transform(x, groups=None)#
- transform(x)#
- inverse_transform(x)#
- set_groups(x, groups)#
- find_group(var_name)#
- abstractmethod _fit(x, groups)#
- abstractmethod _transform_column(x, group_index)#
- abstractmethod _inverse_transform_column(x, group_index)#
- class bridgescaler.group.GroupStandardScaler#
Bases:
GroupBaseScalerScaler that enables calculation and sharing of scaling parameters among multiple variables via variable groupings. This is useful for situations where variables are related, such as temperatures at different height levels.
Groups are specified as a list of column ids, which can be column names for pandas dataframes or column indices for numpy arrays.
For example:
` groups = [["a", "b"], ["c", "d"], "e"] `“a” and “b” are a single group and all values of both will be included when calculating the mean and standard deviation for that group.- center_ = None#
- scale_ = None#
- _fit(x, groups=None)#
- _transform_column(x_column, group_index)#
- _inverse_transform_column(x_column, group_index)#