Record Class AccuracyMetrics.Counts

java.lang.Object
java.lang.Record
org.egothor.methodatlas.eval.AccuracyMetrics.Counts
Record Components:
tp - true positives
fp - false positives
fn - false negatives
tn - true negatives
Enclosing class:
AccuracyMetrics

public static record AccuracyMetrics.Counts(int tp, int fp, int fn, int tn) extends Record
Confusion counts for one binary decision.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Counts(int tp, int fp, int fn, int tn)
    Creates an instance of a Counts record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the accuracy.
    final boolean
    Indicates whether some other object is "equal to" this one.
    f1()
    Returns the F1 score, the harmonic mean of precision and recall.
    int
    fn()
    Returns the value of the fn record component.
    int
    fp()
    Returns the value of the fp record component.
    final int
    Returns a hash code value for this object.
    Returns the precision.
    Returns the recall.
    int
    Returns the number of truly positive samples.
    int
    tn()
    Returns the value of the tn record component.
    final String
    Returns a string representation of this record class.
    int
    Returns the total number of samples counted.
    int
    tp()
    Returns the value of the tp record component.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Counts

      public Counts(int tp, int fp, int fn, int tn)
      Creates an instance of a Counts record class.
      Parameters:
      tp - the value for the tp record component
      fp - the value for the fp record component
      fn - the value for the fn record component
      tn - the value for the tn record component
  • Method Details

    • support

      public int support()
      Returns the number of truly positive samples.
      Returns:
      tp + fn
    • total

      public int total()
      Returns the total number of samples counted.
      Returns:
      tp + fp + fn + tn
    • precision

      public OptionalDouble precision()
      Returns the precision.
      Returns:
      tp/(tp+fp), or empty when nothing was predicted positive
    • recall

      public OptionalDouble recall()
      Returns the recall.
      Returns:
      tp/(tp+fn), or empty when there are no true positives in the truth (zero support)
    • f1

      public OptionalDouble f1()
      Returns the F1 score, the harmonic mean of precision and recall.
      Returns:
      2tp/(2tp+fp+fn), or empty when there is neither a predicted nor a true positive
    • accuracy

      public OptionalDouble accuracy()
      Returns the accuracy.
      Returns:
      (tp+tn)/total, or empty when no samples were counted
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • tp

      public int tp()
      Returns the value of the tp record component.
      Returns:
      the value of the tp record component
    • fp

      public int fp()
      Returns the value of the fp record component.
      Returns:
      the value of the fp record component
    • fn

      public int fn()
      Returns the value of the fn record component.
      Returns:
      the value of the fn record component
    • tn

      public int tn()
      Returns the value of the tn record component.
      Returns:
      the value of the tn record component