Class ImmutableLabelInfo

java.lang.Object
org.tribuo.classification.LabelInfo
org.tribuo.classification.ImmutableLabelInfo
All Implemented Interfaces:
Serializable, Iterable<com.oracle.labs.mlrg.olcut.util.Pair<Integer,Label>>, ImmutableOutputInfo<Label>, OutputInfo<Label>

public class ImmutableLabelInfo extends LabelInfo implements ImmutableOutputInfo<Label>
An ImmutableOutputInfo object for Labels.

Gives each unique label an id number. Also counts each label occurrence like MutableLabelInfo does, though the counts are frozen in this object.

See Also:
  • Method Details

    • 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>
      Overrides:
      getDomain in class LabelInfo
      Returns:
      The set of possible labels.
    • getID

      public int getID(Label output)
      Description copied from interface: ImmutableOutputInfo
      Return the id number associated with this output, or -1 if the output is unknown.
      Specified by:
      getID in interface ImmutableOutputInfo<Label>
      Parameters:
      output - An output
      Returns:
      A non-negative integer if the output is known, or -1 if the output is unknown.
    • getOutput

      public Label getOutput(int id)
      Description copied from interface: ImmutableOutputInfo
      Returns the output associated with this id, or null if the id is unknown.
      Specified by:
      getOutput in interface ImmutableOutputInfo<Label>
      Parameters:
      id - A non-negative integer.
      Returns:
      An output object or null if it's unknown.
    • getTotalObservations

      public long getTotalObservations()
      Description copied from interface: ImmutableOutputInfo
      Returns the total number of observed outputs seen by this ImmutableOutputInfo.
      Specified by:
      getTotalObservations in interface ImmutableOutputInfo<Label>
      Returns:
      The number of observed outputs.
    • getLabelCount

      public long getLabelCount(int id)
      Returns the number of times the supplied id was observed before this LabelInfo was frozen.
      Parameters:
      id - The id number.
      Returns:
      The count.
    • copy

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

      public String toReadableString()
      Description copied from interface: OutputInfo
      Generates a String form of this OutputInfo.

      This String can contain newlines, tabs and other formatting.

      Specified by:
      toReadableString in interface OutputInfo<Label>
      Returns:
      A formatted String representing this OutputInfo.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • iterator

      public Iterator<com.oracle.labs.mlrg.olcut.util.Pair<Integer,Label>> iterator()
      Specified by:
      iterator in interface Iterable<com.oracle.labs.mlrg.olcut.util.Pair<Integer,Label>>