dSalmon.scalers
Scalers for streaming data.
Classes
|
Performs normalization so that the p-quantile of the current sliding window is mapped to 0 and the (1-p)-quantile is mapped to 1. |
|
Base class for sliding window scalers. |
|
Performs z-score normalization of samples based on mean and standard deviation observed in a sliding window of length window. |
- class dSalmon.scalers.SWQuantileScaler(window, quantile, float_type=<class 'numpy.float64'>)[source]
Performs normalization so that the p-quantile of the current sliding window is mapped to 0 and the (1-p)-quantile is mapped to 1. If quantile==0, performs minmax normalization. Note that due to its lacking robustness, minmax normalization is likely to result in unstable results for stream data.
- Parameters
window (float) – Window length after which samples will be pruned.
quantile (float with 0 <= quantile < 0.5) – The quantile value for computing reference values.
float_type (np.float32 or np.float64) – The floating point type to use for internal processing.
- transform(X, times=None)
Transform the next chunk of data.
- Parameters
X (ndarray, shape (n_samples, n_features)) – The input data.
times (ndarray, shape (n_samples,), optional) – Timestamps for input data. If None, timestamps are linearly increased for each sample.
- Returns
X_tr – Transformed input data.
- Return type
ndarray, shape (n_samples, n_features)
- transform_inplace(X, times=None)
Transform the next chunk of data in-place. Requires X to be a C-style contiguous ndarray.
- Parameters
X (ndarray, shape (n_samples, n_features)) – The input data.
times (ndarray, shape (n_samples,), optional) – Timestamps for input data. If None, timestamps are linearly increased for each sample.
- Returns
X_tr – Transformed input data. Equal to X.
- Return type
ndarray, shape (n_samples, n_features)
- class dSalmon.scalers.SWScaler(float_type=<class 'numpy.float64'>)[source]
Base class for sliding window scalers.
- transform(X, times=None)[source]
Transform the next chunk of data.
- Parameters
X (ndarray, shape (n_samples, n_features)) – The input data.
times (ndarray, shape (n_samples,), optional) – Timestamps for input data. If None, timestamps are linearly increased for each sample.
- Returns
X_tr – Transformed input data.
- Return type
ndarray, shape (n_samples, n_features)
- transform_inplace(X, times=None)[source]
Transform the next chunk of data in-place. Requires X to be a C-style contiguous ndarray.
- Parameters
X (ndarray, shape (n_samples, n_features)) – The input data.
times (ndarray, shape (n_samples,), optional) – Timestamps for input data. If None, timestamps are linearly increased for each sample.
- Returns
X_tr – Transformed input data. Equal to X.
- Return type
ndarray, shape (n_samples, n_features)
- class dSalmon.scalers.SWZScoreScaler(window, float_type=<class 'numpy.float64'>)[source]
Performs z-score normalization of samples based on mean and standard deviation observed in a sliding window of length window.
- Parameters
window (float) – Window length after which samples will be pruned.
float_type (np.float32 or np.float64) – The floating point type to use for internal processing.
- transform(X, times=None)
Transform the next chunk of data.
- Parameters
X (ndarray, shape (n_samples, n_features)) – The input data.
times (ndarray, shape (n_samples,), optional) – Timestamps for input data. If None, timestamps are linearly increased for each sample.
- Returns
X_tr – Transformed input data.
- Return type
ndarray, shape (n_samples, n_features)
- transform_inplace(X, times=None)
Transform the next chunk of data in-place. Requires X to be a C-style contiguous ndarray.
- Parameters
X (ndarray, shape (n_samples, n_features)) – The input data.
times (ndarray, shape (n_samples,), optional) – Timestamps for input data. If None, timestamps are linearly increased for each sample.
- Returns
X_tr – Transformed input data. Equal to X.
- Return type
ndarray, shape (n_samples, n_features)