Package smile.math
Class Scaler
java.lang.Object
smile.math.Scaler
- All Implemented Interfaces:
Serializable
,Function
Affine transformation
y = (x - offset) / scale
.- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiondouble
f
(double x) Computes the value of the function at x.double
inv
(double x) Computes the value of the inverse function at x.static Scaler
minmax
(double[] data) Returns the scaler that map the values into the range [0, 1].static Scaler
Returns the scaler.static Scaler
standardizer
(double[] data) Returns the standardize scaler to 0 mean and unit variance.static Scaler
standardizer
(double[] data, boolean robust) Returns the standardize scaler to 0 mean and unit variance.static Scaler
winsor
(double[] data) Returns the scaler that map the values into the range [0, 1].static Scaler
winsor
(double[] data, double lower, double upper) Returns the scaler that map the values into the range [0, 1].
-
Constructor Details
-
Scaler
public Scaler(double scale, double offset, boolean clip) Constructor.- Parameters:
scale
- the scaling factor.offset
- the offset.clip
- if true, clip the value in [0, 1].
-
-
Method Details
-
f
public double f(double x) Description copied from interface:Function
Computes the value of the function at x. -
inv
public double inv(double x) Description copied from interface:Function
Computes the value of the inverse function at x. -
minmax
Returns the scaler that map the values into the range [0, 1].- Parameters:
data
- the training data.- Returns:
- the scaler.
-
winsor
Returns the scaler that map the values into the range [0, 1]. The values greater than the 95% percentile are replaced with the upper limit, and those below the 5% percentile are replace with the lower limit.- Parameters:
data
- the training data.- Returns:
- the scaler.
-
winsor
Returns the scaler that map the values into the range [0, 1]. The values greater than the specified upper limit are replaced with the upper limit, and those below the lower limit are replace with the lower limit.- Parameters:
data
- the training data.lower
- the lower limit in terms of percentiles of the original distribution (e.g. 5th percentile).upper
- the upper limit in terms of percentiles of the original distribution (e.g. 95th percentile).- Returns:
- the scaler.
-
standardizer
Returns the standardize scaler to 0 mean and unit variance.- Parameters:
data
- The training data.- Returns:
- the scaler.
-
standardizer
Returns the standardize scaler to 0 mean and unit variance.- Parameters:
data
- The training data.robust
- If true, scale by subtracting the median and dividing by the IQR.- Returns:
- the scaler.
-
of
Returns the scaler. If the parameterscaler
is null or empty, returnnull
.- Parameters:
scaler
- the scaling algorithm.data
- the training data.- Returns:
- the scaler.
-