Class RobustScaler


  • public class RobustScaler
    extends TransformerMixin<NumpyArray<Double>,​NumpyArray<Double>>
    Scale features using statistics that are robust to outliers. This Scaler removes the median and scales the data according to the quantile range (defaults to IQR: Interquartile Range). The IQR is the range between the 1st quartile (25th quantile) and the 3rd quartile (75th quantile). Centering and scaling happen independently on each feature by computing the relevant statistics on the samples in the training set. Median and interquartile range are then stored to be used on later data using the :meth:`transform` method. Standardization of a dataset is a common requirement for many machine learning estimators. Typically this is done by removing the mean and scaling to unit variance. However, outliers can often influence the sample mean / variance in a negative way. In such cases, the median and the interquartile range often give better results. .. versionadded:: 0.17
    • Constructor Detail

      • RobustScaler

        public RobustScaler()
        Instantiate a new object of RobustScaler.
    • Method Detail

      • setCenter

        public void setCenter​(NumpyArray value)
        Sets the The median value for each feature in the training set.
        Parameters:
        value - The new value for center.
      • getCenter

        public NumpyArray getCenter()
        Gets the The median value for each feature in the training set.
      • setScale

        public void setScale​(NumpyArray value)
        Sets the The (scaled) interquartile range for each feature in the training set.
        Parameters:
        value - The new value for scale.
      • getScale

        public NumpyArray getScale()
        Gets the The (scaled) interquartile range for each feature in the training set.
      • setNFeaturesIn

        public void setNFeaturesIn​(long value)
        Sets the Number of features seen during `fit`.
        Parameters:
        value - The new value for nFeaturesIn.
      • getNFeaturesIn

        public long getNFeaturesIn()
        Gets the Number of features seen during `fit`.
      • setFeatureNamesIn

        public void setFeatureNamesIn​(String[] value)
        Sets the Names of features seen during `fit`. Defined only when `X` has feature names that are all strings.
        Parameters:
        value - The new value for featureNamesIn.
      • getFeatureNamesIn

        public String[] getFeatureNamesIn()
        Gets the Names of features seen during `fit`. Defined only when `X` has feature names that are all strings.
      • isWithCentering

        public boolean isWithCentering()
        Gets if the transformer centers the data before scaling.
        Returns:
        If True, center the data before scaling.
      • setWithCentering

        public void setWithCentering​(boolean withCentering)
        Sets if the transformer centers the data before scaling.
        Parameters:
        withCentering - True for centering before scaling.
      • isWithScaling

        public boolean isWithScaling()
        Gets if the transformer scale the data to interquartile range.
        Returns:
        If True, scale the data to interquartile range.
      • setWithScaling

        public void setWithScaling​(boolean withScaling)
        Sets if the transformer scale the data to interquartile range.
        Parameters:
        withScaling - True to scale the data to interquartile range.
      • isUnitVariance

        public boolean isUnitVariance()
        Gets if scale data so that normally distributed features have a variance of 1.
        Returns:
        True if scale data so that normally distributed features have a variance of 1, otherwise false.
      • setUnitVariance

        public void setUnitVariance​(boolean unitVariance)
        Sets if scale data so that normally distributed features have a variance of 1.
        Parameters:
        unitVariance - True to scale, otherwise false.
      • getQuantilesRange

        public double[] getQuantilesRange()
        Gets the quantile range used to calculate scale.
        Returns:
        The rage of the quantile.
      • setQuantilesRange

        public void setQuantilesRange​(double[] quantilesRange)
        Sets the quantile range used to calculate scale
        Parameters:
        quantilesRange - A double[] array specifying the min and max of the range.