milia.features.scale#
Named scalers, so a pipeline axis can be swept by name.
Functions
|
Scale each slice to its own range, so that only its shape remains. |
|
Fit the named scaler on the data and return the scaled array. |
|
A fresh, unfitted scaler by name. |
|
Centre each slice and scale it to unit standard deviation. |
- milia.features.scale.scaler(name)#
A fresh, unfitted scaler by name.
- Parameters:
name (
str) – One ofSCALERS:"none","standard","minmax","robust","quantile"or"power".- Return type:
- Returns:
The scikit-learn transformer.
- Raises:
ValueError – If the name is unknown.
Examples
>>> type(scaler("robust")).__name__ 'RobustScaler'
- milia.features.scale.scale(X, name)#
Fit the named scaler on the data and return the scaled array.
- Parameters:
- Return type:
- Returns:
The scaled data.
Examples
>>> scale([[0.0], [5.0], [10.0]], "minmax").ravel().tolist() [0.0, 0.5, 1.0]
- milia.features.scale.rangescale(values, axis=-1)#
Scale each slice to its own range, so that only its shape remains.
The values of every slice along
axisare mapped linearly onto zero to one. This removes the level and the amplitude of a profile and keeps its timing, as the peak normalisation of a household profile does. A slice without range is mapped to zero.- Parameters:
- Return type:
- Returns:
An array of the same shape, each slice with minimum zero and maximum one.
Examples
>>> rangescale([[1.0, 2.0, 3.0], [10.0, 10.0, 10.0]]).tolist() [[0.0, 0.5, 1.0], [0.0, 0.0, 0.0]]
- milia.features.scale.standardise(values, axis=-1)#
Centre each slice and scale it to unit standard deviation.
The mean of the product of two standardised slices is their Pearson correlation, so the inner products of the result are correlations. A slice without variation is mapped to zero.
- Parameters:
- Return type:
- Returns:
An array of the same shape, each slice with mean zero and standard deviation one (zero when constant).
Examples
>>> standardise([[1.0, 2.0, 3.0], [5.0, 5.0, 5.0]]).round(3).tolist() [[-1.225, 0.0, 1.225], [0.0, 0.0, 0.0]]