Class AnomalyFactory

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

public final class AnomalyFactory extends Object implements OutputFactory<Event>
A factory for generating events.
See Also:
  • Field Details

    • UNKNOWN_EVENT

      public static final Event UNKNOWN_EVENT
      The unknown event. Used at inference time.
    • EXPECTED_EVENT

      public static final Event EXPECTED_EVENT
      The expected event. Used for things which are not anomalous.
    • ANOMALOUS_EVENT

      public static final Event ANOMALOUS_EVENT
      The anomalous event. It's anomalous.
  • Constructor Details

    • AnomalyFactory

      public AnomalyFactory()
      Create an AnomalyFactory.
  • Method Details

    • deserializeFromProto

      public static AnomalyFactory 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> Event generateOutput(V label)
      Description copied from interface: OutputFactory
      Parses the V and generates the appropriate Output value.

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

      Specified by:
      generateOutput in interface OutputFactory<Event>
      Type Parameters:
      V - The type of the input value.
      Parameters:
      label - An input value.
      Returns:
      The parsed Output as an instance of T.
    • getUnknownOutput

      public Event 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<Event>
      Returns:
      An unknown output.
    • generateInfo

      public MutableOutputInfo<Event> generateInfo()
      Description copied from interface: OutputFactory
      Generates the appropriate MutableOutputInfo so the output values can be tracked by a Dataset or other aggregate.
      Specified by:
      generateInfo in interface OutputFactory<Event>
      Returns:
      The appropriate subclass of MutableOutputInfo initialised to zero.
    • constructInfoForExternalModel

      public ImmutableOutputInfo<Event> constructInfoForExternalModel(Map<Event,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<Event>
      Parameters:
      mapping - The mapping to use.
      Returns:
      The appropriate subclass of ImmutableOutputInfo with a single observation of each element.
    • getEvaluator

      public Evaluator<Event,AnomalyEvaluation> 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<Event>
      Returns:
      An evaluator.
    • getTypeWitness

      public Class<Event> getTypeWitness()
      Description copied from interface: OutputFactory
      Gets the output class that this factory supports.
      Specified by:
      getTypeWitness in interface OutputFactory<Event>
      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()
      Generate provenance for this anomaly factory.
      Specified by:
      getProvenance in interface com.oracle.labs.mlrg.olcut.provenance.Provenancable<OutputFactoryProvenance>
      Returns:
      The provenance.