Class LabelInfo

java.lang.Object
org.tribuo.classification.LabelInfo
All Implemented Interfaces:
Serializable, OutputInfo<Label>
Direct Known Subclasses:
ImmutableLabelInfo, MutableLabelInfo

public abstract class LabelInfo extends Object implements OutputInfo<Label>
The base class for information about multi-class classification Labels.
See Also:
  • Field Details

    • labelCounts

      protected final Map<String,com.oracle.labs.mlrg.olcut.util.MutableLong> labelCounts
      The occurrence counts of each label.
    • unknownCount

      protected int unknownCount
      The number of unknown labels this LabelInfo has seen.
    • labels

      protected transient Map<String,Label> labels
      The label domain.
  • Method Details

    • getUnknownCount

      public int getUnknownCount()
      Description copied from interface: OutputInfo
      Returns the number of unknown Output instances (generated by OutputFactory.getUnknownOutput()) that this OutputInfo has seen.
      Specified by:
      getUnknownCount in interface OutputInfo<Label>
      Returns:
      The number of unknown outputs observed.
    • getDomain

      public Set<Label> getDomain()
      Returns the set of possible Labels that this LabelInfo has seen.

      Each label has the default score of Double.NaN.

      Specified by:
      getDomain in interface OutputInfo<Label>
      Returns:
      The set of possible labels.
    • getLabelCount

      public long getLabelCount(Label label)
      Gets the count of the supplied label, or 0 if the label is unknown.
      Parameters:
      label - A Label.
      Returns:
      A non-negative long.
    • getLabelCount

      public long getLabelCount(String label)
      Gets the count of the supplied label, or 0 if the label is unknown.
      Parameters:
      label - A String representing a Label.
      Returns:
      A non-negative long.
    • outputCountsIterable

      public Iterable<com.oracle.labs.mlrg.olcut.util.Pair<String,Long>> outputCountsIterable()
      Description copied from interface: OutputInfo
      An Iterable over the possible outputs and the number of times they were observed.

      Provides similar functionality to an iterator over the entrySet of a Map, though this is a copy of the data and immutable.

      Specified by:
      outputCountsIterable in interface OutputInfo<Label>
      Returns:
      Lambda wrapping an iterator over Pairs.
    • size

      public int size()
      The number of unique Labels this LabelInfo has seen.
      Specified by:
      size in interface OutputInfo<Label>
      Returns:
      The number of unique labels.
    • generateImmutableOutputInfo

      public ImmutableOutputInfo<Label> generateImmutableOutputInfo()
      Description copied from interface: OutputInfo
      Generates an ImmutableOutputInfo which has a copy of the data in this OutputInfo, but also has id values and is immutable.
      Specified by:
      generateImmutableOutputInfo in interface OutputInfo<Label>
      Returns:
      An immutable copy of this OutputInfo.
    • generateMutableOutputInfo

      public MutableOutputInfo<Label> generateMutableOutputInfo()
      Description copied from interface: OutputInfo
      Generates a mutable copy of this OutputInfo.
      Specified by:
      generateMutableOutputInfo in interface OutputInfo<Label>
      Returns:
      A mutable copy of this OutputInfo.
    • copy

      public abstract LabelInfo copy()
      Description copied from interface: OutputInfo
      Generates a copy of this OutputInfo, including it's mutability.
      Specified by:
      copy in interface OutputInfo<Label>
      Returns:
      A copy of the OutputInfo.