Class ClassLabels

java.lang.Object
smile.classification.ClassLabels
All Implemented Interfaces:
Serializable

public class ClassLabels extends Object implements Serializable
Map arbitrary class labels to [0, k), where k is the number of classes.
See Also:
  • Field Details

    • k

      public final int k
      The number of classes.
    • classes

      public final IntSet classes
      The class labels.
    • y

      public final int[] y
      The sample class id in [0, k).
    • ni

      public final int[] ni
      The number of samples per classes.
    • priori

      public final double[] priori
      The estimated priori probabilities.
  • Constructor Details

    • ClassLabels

      public ClassLabels(int k, int[] y, IntSet classes)
      Constructor.
      Parameters:
      k - The number of classes.
      y - The sample class id in [0, k).
      classes - the class label encoder.
  • Method Details

    • scale

      public NominalScale scale()
      Returns the nominal scale of the class labels.
      Returns:
      the nominal scale of the class labels.
    • indexOf

      public int[] indexOf(int[] y)
      Maps the class labels to index.
      Parameters:
      y - the sample labels.
      Returns:
      the indices of labels.
    • fit

      public static ClassLabels fit(Dataset<?,Integer> data)
      Fits the class label mapping.
      Parameters:
      data - the sample instances.
      Returns:
      the class label mapping.
    • fit

      public static ClassLabels fit(int[] y)
      Fits the class label mapping.
      Parameters:
      y - the sample labels.
      Returns:
      the class label mapping.
    • fit

      public static ClassLabels fit(BaseVector<?,?,?> response)
      Fits the class label mapping.
      Parameters:
      response - the sample labels.
      Returns:
      the class label mapping.