bridgescaler.distributed#
Attributes#
Classes#
Base distributed scaler class. Used only to store attributes and methods shared across all distributed |
|
Distributed version of StandardScaler. You can calculate this map-reduce style by running it on individual |
|
Distributed MinMaxScaler enables calculation of min and max of variables in datasets in parallel then combining |
|
Distributed Quantile Scaler that uses the crick TDigest Cython library to compute quantiles across multiple |
Functions#
|
|
|
|
|
|
|
|
|
Module Contents#
- bridgescaler.distributed.CENTROID_DTYPE#
- class bridgescaler.distributed.DBaseScaler(channels_last=True)#
Bases:
objectBase distributed scaler class. Used only to store attributes and methods shared across all distributed scaler subclasses.
- x_columns_ = None#
- is_array_ = False#
- _fit = False#
- channels_last = True#
- is_fit()#
- static extract_x_columns(x, channels_last=True)#
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.
channels_last (bool) – If True, then assume the variable or channel dimension is the last dimension of the array. If False, then assume the variable or channel dimension is second.
- Returns:
Array of values to be transformed. is_array (bool): Whether or not x was a np.ndarray.
- Return type:
xv (numpy.ndarray)
- static extract_array(x)#
- get_column_order(x_in_columns)#
Get the indices of the scaler columns that have the same name as the columns in the input x array. This enables users to pass a DataFrame or DataArray to transform or inverse_transform with fewer columns than the original scaler or columns in a different order and still have the input dataset be transformed properly.
- Parameters:
x_in_columns (Union[list, numpy.ndarray]) – list of input columns.
- Returns:
indices of the input columns from x in the scaler in order.
- Return type:
x_in_col_indices (np.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:
- set_channel_dim(channels_last=None)#
- process_x_for_transform(x, channels_last=None)#
- fit(x, weight=None)#
- transform(x, channels_last=None)#
- fit_transform(x, channels_last=None, weight=None)#
- inverse_transform(x, channels_last=None)#
- __add__(other)#
- subset_columns(sel_columns)#
- add_variables(other)#
- class bridgescaler.distributed.DStandardScaler(channels_last=True)#
Bases:
DBaseScalerDistributed version of StandardScaler. You can calculate this map-reduce style by running it on individual data files, return the fitted objects, and then sum them together to represent the full dataset. Scaler supports numpy arrays, pandas dataframes, and xarray DataArrays and will return a transformed array in the same form as the original with column or coordinate names preserved.
- mean_x_ = None#
- n_ = 0#
- var_x_ = None#
- fit(x, weight=None)#
- transform(x, channels_last=None)#
Transform the input data from its original form to standard scaled form. If your input data has a different dimension order than the data used to fit the scaler, use the channels_last keyword argument to specify whether the new data are channels_last (True) or channels_first (False).
- Parameters:
x – Input data.
channels_last – Override the default channels_last parameter of the scaler.
- Returns:
Transformed data in the same shape and type as x.
- Return type:
x_transformed
- inverse_transform(x, channels_last=None)#
- get_scales()#
- __add__(other)#
- class bridgescaler.distributed.DMinMaxScaler(channels_last=True)#
Bases:
DBaseScalerDistributed MinMaxScaler enables calculation of min and max of variables in datasets in parallel then combining the mins and maxes as a reduction step. Scaler supports numpy arrays, pandas dataframes, and xarray DataArrays and will return a transformed array in the same form as the original with column or coordinate names preserved.
- max_x_ = None#
- min_x_ = None#
- fit(x, weight=None)#
- transform(x, channels_last=None)#
- inverse_transform(x, channels_last=None)#
- get_scales()#
- __add__(other)#
- bridgescaler.distributed.fit_variable(var_index, xv_shared=None, compression=None, channels_last=None)#
- bridgescaler.distributed.transform_variable(td_obj, xv, min_val=1e-06, max_val=0.9999999, distribution='normal')#
- bridgescaler.distributed.inv_transform_variable(td_obj, xv, distribution='normal')#
- bridgescaler.distributed.tdigest_cdf(xv, cent_mean, cent_weight, t_min, t_max, out)#
- bridgescaler.distributed.tdigest_quantile(qv, cent_mean, cent_weight, t_min, t_max, out)#
- class bridgescaler.distributed.DQuantileScaler(compression=250, distribution='uniform', min_val=1e-07, max_val=0.9999999, channels_last=True)#
Bases:
DBaseScalerDistributed Quantile Scaler that uses the crick TDigest Cython library to compute quantiles across multiple datasets in parallel. The library can perform fitting, transforms, and inverse transforms across variables in parallel using the multiprocessing library. Multidimensional arrays are stored in shared memory across processes to minimize inter-process communication.
DQuantileScaler supports
- compression#
Recommended number of centroids to use.
- distribution#
“uniform”, “normal”, or “logistic”.
- min_val#
Minimum value for quantile to prevent -inf results when distribution is normal or logistic.
- max_val#
Maximum value for quantile to prevent inf results when distribution is normal or logistic.
- channels_last#
Whether to assume the last dim or second dim are the channel/variable dimension.
- compression = 250#
- distribution = 'uniform'#
- min_val = 1e-07#
- max_val = 0.9999999#
- centroids_ = None#
- size_ = None#
- min_ = None#
- max_ = None#
- td_objs_to_attributes(td_objs)#
- attributes_to_td_objs()#
- fit(x, weight=None)#
- transform(x, channels_last=None, pool=None)#
- fit_transform(x, channels_last=None, weight=None, pool=None)#
- inverse_transform(x, channels_last=None, pool=None)#
- __add__(other)#