Package opennlp.tools.util.eval
Class FMeasure
- java.lang.Object
-
- opennlp.tools.util.eval.FMeasure
-
public final class FMeasure extends Object
TheFMeasureis a utility class forevaluatorswhich measures precision, recall and the resulting f-measure. Evaluation results are the arithmetic mean of the precision scores calculated for each reference sample and the arithmetic mean of the recall scores calculated for each reference sample.
-
-
Constructor Summary
Constructors Constructor Description FMeasure()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description doublegetFMeasure()f-measure = 2 * precision * recall / (precision + recall).doublegetPrecisionScore()doublegetRecallScore()voidmergeInto(FMeasure measure)Merge results intometric.static doubleprecision(Object[] references, Object[] predictions)Calculates the precision score for the given reference and predicted spans.static doublerecall(Object[] references, Object[] predictions)Calculates the recall score for the given reference and predicted spans.StringtoString()voidupdateScores(Object[] references, Object[] predictions)Updates the score based on the number of true positives and the number of predictions and references.
-
-
-
Method Detail
-
getPrecisionScore
public double getPrecisionScore()
- Returns:
- Retrieves the arithmetic mean of the precision scores calculated for each evaluated sample.
-
getRecallScore
public double getRecallScore()
- Returns:
- Retrieves the arithmetic mean of the recall score calculated for each evaluated sample.
-
getFMeasure
public double getFMeasure()
f-measure = 2 * precision * recall / (precision + recall).- Returns:
- Retrieves the f-measure or
-1if precision + recall<= 0
-
updateScores
public void updateScores(Object[] references, Object[] predictions)
Updates the score based on the number of true positives and the number of predictions and references.- Parameters:
references- the provided referencespredictions- the predicted spans
-
mergeInto
public void mergeInto(FMeasure measure)
Merge results intometric.- Parameters:
measure- TheFMeasureto merge.
-
toString
public String toString()
-
precision
public static double precision(Object[] references, Object[] predictions)
Calculates the precision score for the given reference and predicted spans.- Parameters:
references- The gold standard spans.predictions- The predicted spans.- Returns:
- The precision score or
NaNif there are no predicted spans.
-
recall
public static double recall(Object[] references, Object[] predictions)
Calculates the recall score for the given reference and predicted spans.- Parameters:
references- The gold standard spanspredictions- The predicted spans- Returns:
- The recall score or
NaNif there are no reference spans.
-
-