Package org.tribuo

Interface OutputFactory<T extends Output<T>>

All Superinterfaces:, ProtoSerializable<org.tribuo.protos.core.OutputFactoryProto>,<OutputFactoryProvenance>, Serializable
All Known Implementing Classes:
AnomalyFactory, ClusteringFactory, LabelFactory, MultiLabelFactory, RegressionFactory

public interface OutputFactory<T extends Output<T>> extends, ProtoSerializable<org.tribuo.protos.core.OutputFactoryProto>,<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.
      label - An input value.
      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.
      An unknown output.
    • generateInfo

      MutableOutputInfo<T> generateInfo()
      Generates the appropriate MutableOutputInfo so the output values can be tracked by a Dataset or other aggregate.
      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.

      mapping - The mapping to use.
      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.

      An evaluator.
    • getTypeWitness

      default Class<T> getTypeWitness()
      Gets the output class that this factory supports.
      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
      inputs - The list to convert.
      A list of outputs.
    • deserialize

      static OutputFactory<?> deserialize(org.tribuo.protos.core.OutputFactoryProto proto)
      Deserializes a OutputFactoryProto into a OutputFactory subclass.
      proto - The proto to deserialize.
      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.
      mapping - The mapping to use.