Class LabelFactory

java.lang.Object
org.tribuo.classification.LabelFactory
All Implemented Interfaces:
com.oracle.labs.mlrg.olcut.config.Configurable, com.oracle.labs.mlrg.olcut.provenance.Provenancable<OutputFactoryProvenance>, Serializable, OutputFactory<Label>, ProtoSerializable<org.tribuo.protos.core.OutputFactoryProto>

public final class LabelFactory extends Object implements OutputFactory<Label>
A factory for making Label related classes.

Parses the Label by calling toString on the input.

Label factories have no state, and are all equal to each other.

See Also:
  • Field Details

    • UNKNOWN_LABEL

      public static final Label UNKNOWN_LABEL
      The singleton unknown label, used for unlablled examples.
  • Constructor Details

    • LabelFactory

      public LabelFactory()
      Constructs a label factory.
  • Method Details

    • deserializeFromProto

      public static LabelFactory deserializeFromProto(int version, String className, com.google.protobuf.Any message)
      Deserialization factory.
      Parameters:
      version - The serialized object version.
      className - The class name.
      message - The serialized data.
      Returns:
      The deserialized object.
    • serialize

      public org.tribuo.protos.core.OutputFactoryProto serialize()
      Description copied from interface: ProtoSerializable
      Serializes this object to a protobuf.
      Specified by:
      serialize in interface ProtoSerializable<org.tribuo.protos.core.OutputFactoryProto>
      Returns:
      The protobuf.
    • generateOutput

      public <V> Label generateOutput(V label)
      Generates the Label string by calling toString on the input.
      Specified by:
      generateOutput in interface OutputFactory<Label>
      Type Parameters:
      V - The type of the input.
      Parameters:
      label - An input value.
      Returns:
      A Label object.
    • getUnknownOutput

      public Label getUnknownOutput()
      Description copied from interface: OutputFactory
      Returns the singleton unknown output of type T which can be used for prediction time examples.
      Specified by:
      getUnknownOutput in interface OutputFactory<Label>
      Returns:
      An unknown output.
    • generateInfo

      public MutableOutputInfo<Label> generateInfo()
      Generates an empty MutableLabelInfo.
      Specified by:
      generateInfo in interface OutputFactory<Label>
      Returns:
      An empty MutableLabelInfo.
    • constructInfoForExternalModel

      public ImmutableOutputInfo<Label> constructInfoForExternalModel(Map<Label,Integer> mapping)
      Description copied from interface: OutputFactory
      Creates an ImmutableOutputInfo from the supplied mapping. Requires that the mapping is dense in the integers [0,mapping.size()) and each mapping is unique.

      This call is used to import external models, and should not be used for other purposes.

      Specified by:
      constructInfoForExternalModel in interface OutputFactory<Label>
      Parameters:
      mapping - The mapping to use.
      Returns:
      The appropriate subclass of ImmutableOutputInfo with a single observation of each element.
    • getEvaluator

      public Evaluator<Label,LabelEvaluation> getEvaluator()
      Description copied from interface: OutputFactory
      Gets an Evaluator suitable for measuring performance of predictions for the Output subclass.

      Evaluator instances are thread safe and immutable, and commonly this is a singleton stored in the OutputFactory implementation.

      Specified by:
      getEvaluator in interface OutputFactory<Label>
      Returns:
      An evaluator.
    • getTypeWitness

      public Class<Label> getTypeWitness()
      Description copied from interface: OutputFactory
      Gets the output class that this factory supports.
      Specified by:
      getTypeWitness in interface OutputFactory<Label>
      Returns:
      The output class.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • getProvenance

      public OutputFactoryProvenance getProvenance()
      Specified by:
      getProvenance in interface com.oracle.labs.mlrg.olcut.provenance.Provenancable<OutputFactoryProvenance>