mojolearn.RobustScaler#
- class mojolearn.RobustScaler(*, with_centering=True, with_scaling=True, quantile_range=(25.0, 75.0), copy=True, unit_variance=False)[source]#
Bases:
_PrepBaseScale features by the median and the interquantile range.
Follows scikit-learn’s
RobustScaler. Each column is centered by its median and divided by the range between thequantile_rangepercentiles, computed with numpy’s linear percentile over the non-NaN entries. NaN values are ignored during fit and kept as NaN by transform. A scale smaller than ten float32 epsilons is replaced by one. Input and output are float32.- Parameters:
with_centering (bool, default True) – Subtract the median before scaling.
with_scaling (bool, default True) – Divide by the interquantile range.
quantile_range (tuple of float, default (25.0, 75.0)) –
(q_min, q_max)percentiles, with0 <= q_min <= q_max <= 100; otherwise fit raisesValueError.copy (bool, default True) – Accepted for scikit-learn compatibility; transform always returns a new array.
unit_variance (bool, default False) – Also divide the scale by
norm.ppf(q_max) - norm.ppf(q_min), so that normally distributed data ends with unit variance. Requires0 < q_min < q_max < 100(ValueErrorotherwise).
- Variables:
center_ (array of shape (n_features,) or None) – Per-column median, or None when
with_centering=False.scale_ (array of shape (n_features,) or None) – Per-column scale, or None when
with_scaling=False.n_features_in_ (int) – Number of columns seen in fit.
numeric_mode_ (str) – Numeric mode the estimator was fitted in; transform runs in the same mode.
Examples
>>> import numpy as np, mojolearn >>> X = np.random.default_rng(0).random((1000, 8), dtype=np.float32) >>> Xt = mojolearn.RobustScaler().fit_transform(X)
- __init__(*, with_centering=True, with_scaling=True, quantile_range=(25.0, 75.0), copy=True, unit_variance=False)[source]#
Methods
fit(X[, y])fit_transform(X[, y])Fit to
X, then transformX.get_params([deep])Return the constructor parameters as a dict.
set_params(**params)Set constructor parameters.
transform(X)