Class Event

java.lang.Object
org.tribuo.anomaly.Event
All Implemented Interfaces:
Serializable, Output<Event>, ProtoSerializable<org.tribuo.protos.core.OutputProto>

public final class Event extends Object implements Output<Event>
An Output representing either an Event.EventType.ANOMALOUS or an Event.EventType.EXPECTED event.

Event trainers are allowed to throw IllegalArgumentException if they are supplied an Event.EventType.ANOMALOUS at training time. It's noted in the documentation if they do support training from anomalous and expected data.

See Also:
  • Field Details

    • DEFAULT_SCORE

      public static final double DEFAULT_SCORE
      The default score of events.
      See Also:
  • Constructor Details

    • Event

      public Event(Event.EventType type, double score)
      Constructs a new event of the specified type and score.
      Parameters:
      type - The event type.
      score - The event score.
    • Event

      public Event(Event.EventType type)
      Constructs a new event of the specified type with the default score of DEFAULT_SCORE.
      Parameters:
      type - The event type.
  • Method Details

    • deserializeFromProto

      public static Event deserializeFromProto(int version, String className, com.google.protobuf.Any message) throws com.google.protobuf.InvalidProtocolBufferException
      Deserialization factory.
      Parameters:
      version - The serialized object version.
      className - The class name.
      message - The serialized data.
      Returns:
      The deserialized object.
      Throws:
      com.google.protobuf.InvalidProtocolBufferException - If the protobuf could not be parsed from the message.
    • serialize

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

      public double getScore()
      Get a real valued score for this label.

      If the score is not set then it returns DEFAULT_SCORE.

      Returns:
      The predicted score for this label.
    • getType

      public Event.EventType getType()
      Gets the event type.
      Returns:
      An event type.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

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

      public boolean fullEquals(Event o)
      Description copied from interface: Output
      Compares other to this output. Uses all score values and the strings.
      Specified by:
      fullEquals in interface Output<Event>
      Parameters:
      o - Another output instance.
      Returns:
      True if the other instance has value equality to this instance. False otherwise.
    • fullEquals

      public boolean fullEquals(Event o, double tolerance)
      Description copied from interface: Output
      Compares other to this output. Uses all score values and the strings.

      The default implementation of this method ignores the tolerance for compatibility reasons, it is overridden in all output classes in Tribuo.

      Specified by:
      fullEquals in interface Output<Event>
      Parameters:
      o - Another output instance.
      tolerance - The tolerance level for an absolute value comparison.
      Returns:
      True if the other instance has value equality to this instance. False otherwise.
    • toString

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

      public Event copy()
      Description copied from interface: Output
      Deep copy of the output up to its immutable state.
      Specified by:
      copy in interface Output<Event>
      Returns:
      A copy of the output.
    • getSerializableForm

      public String getSerializableForm(boolean includeConfidence)
      Returns "EventType" or "EventType,score=eventScore".
      Specified by:
      getSerializableForm in interface Output<Event>
      Parameters:
      includeConfidence - Include whatever confidence score the label contains, if known.
      Returns:
      A String form suitable for serialization.