Package edu.stanford.nlp.parser.metrics
Class EvaluationMetric
- java.lang.Object
-
- edu.stanford.nlp.parser.metrics.EvaluationMetric
-
public class EvaluationMetric extends Object
A general class that scores precision, recall, and F1. The package supports incremental computation of these statistics via theupdate(double, double, double, double)method. Formatted output reflecting the current values of the statistics may be obtained via thetoString()method.- Author:
- Spence Green
- See Also:
Evalb
-
-
Constructor Summary
Constructors Constructor Description EvaluationMetric()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Pair<Double,Double>getPFractionals()Returns the components of the precision.Pair<Double,Double>getRFractionals()Returns the components of the recall.doublegetTestInstances()Returns the number of test instances (e.g., parse trees or sentences) used in the calculation of the statistics.doublenumRelevantExamples()A convenience method that returns the number of true positive examples from among the test instances.StringtoString()voidupdate(double curP, double curPnum, double curR, double curRnum)Updates the evaluation statistics.
-
-
-
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 examplecurPnum- The denominator used to calculate the current precisioncurR- Recall of the current test examplecurRnum- The denominator used to calculate the current recall
-
getPFractionals
public Pair<Double,Double> getPFractionals()
Returns the components of the precision.- Returns:
- A
Pairwith 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
Pairwith 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 toupdate(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
-
-