Class Normalize

java.lang.Object
com.jml.preprocessing.Normalize

public class Normalize extends Object
  • Method Summary

    Modifier and Type
    Method
    Description
    static double[]
    l1​(double[] data)
    Normalizes the data by subtracting the mean and dividing by the L1-norm.
    static double[]
    l2​(double[] data)
    Normalizes the data by subtracting the mean and dividing by the L2-norm.
    static double[][]
    l2​(double[][] data)
    Normalizes each column of the data by subtracting the mean of that column and dividing by the L2-norm of that column.
    static double[]
    meanNormalize​(double[] data)
    Applies meanNormalize normalization to the data.
    static double[]
    minMaxScale​(double[] data)
    Applies min-max feature scaling to data.
    static double[]
    minMaxScale​(double[] data, double a, double b)
    Applies min-max feature scaling to data.
    static double[]
    zScore​(double[] data)
    Applies Z-score normalization to the dataset.
    static double[][]
    zScore​(double[][] data)
    Applies Z-score normalization to the dataset.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • minMaxScale

      public static double[] minMaxScale(double[] data)
      Applies min-max feature scaling to data. This will rescale the data to be in [1, 0].

      Also see minMaxScale(double[], double, double).
      Parameters:
      data - Dataset to apply normalization to.
      Returns:
      A copy of the dataset that has been normalized using min-max feature scaling.
    • minMaxScale

      public static double[] minMaxScale(double[] data, double a, double b)
      Applies min-max feature scaling to data. This will rescale the data to be in [a, b].

      Also see minMaxScale(double[]).
      Parameters:
      data - Dataset to apply normalization to.
      a - Minimum value of the rescaled dataset.
      b - Maximum value of the rescaled dataset.
      Returns:
      A copy of the dataset that has been normalized using min-max feature scaling.
    • meanNormalize

      public static double[] meanNormalize(double[] data)
      Applies meanNormalize normalization to the data.
      Parameters:
      data - Dataset to apply meanNormalize normalization to.
      Returns:
      A copy of the dataset which has been normalized using meanNormalize normalization.
    • l1

      public static double[] l1(double[] data)
      Normalizes the data by subtracting the mean and dividing by the L1-norm.
      Parameters:
      data - - data to normalize.
      Returns:
      The L1-normalized data.
    • l2

      public static double[] l2(double[] data)
      Normalizes the data by subtracting the mean and dividing by the L2-norm.
      Parameters:
      data - - data to normalize.
      Returns:
      The L2-normalized data.
    • l2

      public static double[][] l2(double[][] data)
      Normalizes each column of the data by subtracting the mean of that column and dividing by the L2-norm of that column.
      Parameters:
      data - - data to normalize.
      Returns:
      The L2-normalized data.
    • zScore

      public static double[] zScore(double[] data)
      Applies Z-score normalization to the dataset.
      Parameters:
      data - The dataset of interest.
      Returns:
      A copy of the dataset which has been normalized using Z-score normalization.
    • zScore

      public static double[][] zScore(double[][] data)
      Applies Z-score normalization to the dataset.
      Parameters:
      data - The dataset of interest.
      Returns:
      A copy of the dataset which has been normalized using Z-score normalization.