Package org.tribuo

Interface OutputFactory<T extends Output<T>>

All Superinterfaces:
com.oracle.labs.mlrg.olcut.config.Configurable, ProtoSerializable<org.tribuo.protos.core.OutputFactoryProto>, com.oracle.labs.mlrg.olcut.provenance.Provenancable<OutputFactoryProvenance>, Serializable
All Known Implementing Classes:
AnomalyFactory, ClusteringFactory, LabelFactory, MultiLabelFactory, RegressionFactory

public interface OutputFactory<T extends Output<T>> extends com.oracle.labs.mlrg.olcut.config.Configurable, ProtoSerializable<org.tribuo.protos.core.OutputFactoryProto>, com.oracle.labs.mlrg.olcut.provenance.Provenancable<OutputFactoryProvenance>, Serializable
An interface associated with a specific Output, which can generate the appropriate Output subclass, and OutputInfo subclass.

Must be Configurable so it can be loaded from an olcut config file.

  • Method Details

    • generateOutput

      <V> T generateOutput(V label)
      Parses the V and generates the appropriate Output value.

      Most implementations call toString on the label before parsing it, but this is not required.

      Type Parameters:
      V - The type of the input value.
      Parameters:
      label - An input value.
      Returns:
      The parsed Output as an instance of T.
    • getUnknownOutput

      T getUnknownOutput()
      Returns the singleton unknown output of type T which can be used for prediction time examples.
      Returns:
      An unknown output.
    • generateInfo

      MutableOutputInfo<T> generateInfo()
      Generates the appropriate MutableOutputInfo so the output values can be tracked by a Dataset or other aggregate.
      Returns:
      The appropriate subclass of MutableOutputInfo initialised to zero.
    • constructInfoForExternalModel

      ImmutableOutputInfo<T> constructInfoForExternalModel(Map<T,Integer> mapping)
      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.

      Parameters:
      mapping - The mapping to use.
      Returns:
      The appropriate subclass of ImmutableOutputInfo with a single observation of each element.
    • getEvaluator

      Evaluator<T,? extends Evaluation<T>> getEvaluator()
      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.

      Returns:
      An evaluator.
    • getTypeWitness

      default Class<T> getTypeWitness()
      Gets the output class that this factory supports.
      Returns:
      The output class.
    • generateOutputs

      default <V> List<T> generateOutputs(List<V> inputs)
      Generate a list of outputs from the supplied list of inputs.

      Makes inputs.size() calls to generateOutput(V).

      Type Parameters:
      V - The type of the inputs
      Parameters:
      inputs - The list to convert.
      Returns:
      A list of outputs.
    • deserialize

      static OutputFactory<?> deserialize(org.tribuo.protos.core.OutputFactoryProto proto)
      Deserializes a OutputFactoryProto into a OutputFactory subclass.
      Parameters:
      proto - The proto to deserialize.
      Returns:
      The deserialized OutputFactory.
    • validateMapping

      static <T extends Output<T>> void validateMapping(Map<T,Integer> mapping)
      Validates that the mapping can be used as an output info, i.e. that it is dense in the region [0,mapping.size()) - meaning no duplicate ids, each id 0 through mapping.size() is used, and there are no negative ids.
      Type Parameters:
      T - The type of the output.
      Parameters:
      mapping - The mapping to use.