Class AnomalyInfo

java.lang.Object
org.tribuo.anomaly.AnomalyInfo
All Implemented Interfaces:
Serializable, OutputInfo<Event>, ProtoSerializable<org.tribuo.protos.core.OutputDomainProto>
Direct Known Subclasses:
ImmutableAnomalyInfo, MutableAnomalyInfo

public abstract class AnomalyInfo extends Object implements OutputInfo<Event>
The base class for tracking anomalous events.
See Also:
  • Field Details

    • expectedCount

      protected long expectedCount
      The number of expected events observed.
    • anomalyCount

      protected long anomalyCount
      The number of anomalous events observed.
    • unknownCount

      protected int unknownCount
      The number of unknown events observed (i.e., those without labels).
  • Constructor Details

    • AnomalyInfo

      protected AnomalyInfo()
      Constructs a new empty anomaly info.
    • AnomalyInfo

      protected AnomalyInfo(AnomalyInfo other)
      Copies the supplied anomaly info.
      Parameters:
      other - The info to copy.
    • AnomalyInfo

      protected AnomalyInfo(long expectedCount, long anomalyCount, int unknownCount)
      Deserialization constructor.

      Validates that the inputs are non-negative.

      Parameters:
      expectedCount - The observed number of expected events.
      anomalyCount - The observed number of anomalous events.
      unknownCount - The observed number of unknown events.
  • Method Details

    • serialize

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

      public int getUnknownCount()
      Description copied from interface: OutputInfo
      Returns the number of unknown Output instances (generated by OutputFactory.getUnknownOutput()) that this OutputInfo has seen.
      Specified by:
      getUnknownCount in interface OutputInfo<Event>
      Returns:
      The number of unknown outputs observed.
    • getAnomalyCount

      public long getAnomalyCount()
      The number of anomalous events observed.
      Returns:
      The number of anomalies.
    • getExpectedCount

      public long getExpectedCount()
      The number of expected events observed.
      Returns:
      The number of normal events.
    • getDomain

      public Set<Event> getDomain()
      Returns the set of possible Events.

      Each event has the default score of Double.NaN.

      Specified by:
      getDomain in interface OutputInfo<Event>
      Returns:
      The set of possible events.
    • getEventCount

      public long getEventCount(Event.EventType type)
      Gets the count of the supplied EventType.
      Parameters:
      type - An EventType.
      Returns:
      A non-negative long.
    • outputCountsIterable

      public Iterable<com.oracle.labs.mlrg.olcut.util.Pair<String,Long>> outputCountsIterable()
      Description copied from interface: OutputInfo
      An Iterable over the possible outputs and the number of times they were observed.

      Provides similar functionality to an iterator over the entrySet of a Map, though this is a copy of the data and immutable.

      Specified by:
      outputCountsIterable in interface OutputInfo<Event>
      Returns:
      Lambda wrapping an iterator over Pairs.
    • size

      public int size()
      The number of possible event types (i.e., 2).
      Specified by:
      size in interface OutputInfo<Event>
      Returns:
      The number of possible event types.
    • generateImmutableOutputInfo

      public ImmutableOutputInfo<Event> generateImmutableOutputInfo()
      Description copied from interface: OutputInfo
      Generates an ImmutableOutputInfo which has a copy of the data in this OutputInfo, but also has id values and is immutable.
      Specified by:
      generateImmutableOutputInfo in interface OutputInfo<Event>
      Returns:
      An immutable copy of this OutputInfo.
    • generateMutableOutputInfo

      public MutableOutputInfo<Event> generateMutableOutputInfo()
      Description copied from interface: OutputInfo
      Generates a mutable copy of this OutputInfo.
      Specified by:
      generateMutableOutputInfo in interface OutputInfo<Event>
      Returns:
      A mutable copy of this OutputInfo.
    • toReadableString

      public String toReadableString()
      Description copied from interface: OutputInfo
      Generates a String form of this OutputInfo.

      This String can contain newlines, tabs and other formatting.

      Specified by:
      toReadableString in interface OutputInfo<Event>
      Returns:
      A formatted String representing this OutputInfo.
    • toString

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

      public abstract AnomalyInfo copy()
      Description copied from interface: OutputInfo
      Generates a copy of this OutputInfo, including it's mutability.
      Specified by:
      copy in interface OutputInfo<Event>
      Returns:
      A copy of the OutputInfo.
    • equals

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

      public int hashCode()
      Overrides:
      hashCode in class Object