Class EvaluationMetric


  • public class EvaluationMetric
    extends Object
    A general class that scores precision, recall, and F1. The package supports incremental computation of these statistics via the update(double, double, double, double) method. Formatted output reflecting the current values of the statistics may be obtained via the toString() method.
    Author:
    Spence Green
    See Also:
    Evalb
    • Constructor Detail

      • EvaluationMetric

        public EvaluationMetric()
    • Method Detail

      • update

        public void update​(double curP,
                           double curPnum,
                           double curR,
                           double curRnum)
        Updates the evaluation statistics. Should be called once for each test example (e.g., sentence, parse tree, etc.).
        Parameters:
        curP - Precision of the current test example
        curPnum - The denominator used to calculate the current precision
        curR - Recall of the current test example
        curRnum - The denominator used to calculate the current recall
      • getPFractionals

        public Pair<Double,​Double> getPFractionals()
        Returns the components of the precision.
        Returns:
        A Pair with the numerator of the precision in the first element and the denominator of the precision in the second element.
      • getRFractionals

        public Pair<Double,​Double> getRFractionals()
        Returns the components of the recall.
        Returns:
        A Pair with the numerator of the recall in the first element and the denominator of the recall in the second element.
      • getTestInstances

        public double getTestInstances()
        Returns the number of test instances (e.g., parse trees or sentences) used in the calculation of the statistics. This value corresponds to the number of calls to update(double, double, double, double).
        Returns:
        The number of test instances
      • numRelevantExamples

        public double numRelevantExamples()
        A convenience method that returns the number of true positive examples from among the test instances. Mathematically, this value is the denominator of the recall.
        Returns:
        Number of true positive examples