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 Summary

    Fields
    Modifier and Type
    Field
    Description
    final smile.util.IntSet
    The class labels.
    final int
    The number of classes.
    final int[]
    The number of samples per classes.
    final double[]
    The estimated priori probabilities.
    final int[]
    The sample class id in [0, k).
  • Constructor Summary

    Constructors
    Constructor
    Description
    ClassLabels(int k, int[] y, smile.util.IntSet classes)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    fit(int[] y)
    Fits the class label mapping.
    fit(smile.data.vector.BaseVector<?,?,?> response)
    Fits the class label mapping.
    int[]
    indexOf(int[] y)
    Maps the class labels to index.
    smile.data.measure.NominalScale
    Returns the nominal scale of the class labels.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • k

      public final int k
      The number of classes.
    • classes

      public final smile.util.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, smile.util.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 smile.data.measure.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(int[] y)
      Fits the class label mapping.
      Parameters:
      y - the sample labels.
      Returns:
      the class label mapping.
    • fit

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