Package opennlp.tools.util.eval
Class FMeasure
- java.lang.Object
-
- opennlp.tools.util.eval.FMeasure
-
public final class FMeasure extends java.lang.ObjectTheFMeasureis an utility class for evaluators which measure 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()Retrieves the f-measure score.doublegetPrecisionScore()Retrieves the arithmetic mean of the precision scores calculated for each evaluated sample.doublegetRecallScore()Retrieves the arithmetic mean of the recall score calculated for each evaluated sample.voidmergeInto(FMeasure measure)Merge results into fmeasure metric.static doubleprecision(java.lang.Object[] references, java.lang.Object[] predictions)Calculates the precision score for the given reference and predicted spans.static doublerecall(java.lang.Object[] references, java.lang.Object[] predictions)Calculates the recall score for the given reference and predicted spans.java.lang.StringtoString()Creates a human read-ableStringrepresentation.voidupdateScores(java.lang.Object[] references, java.lang.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()
Retrieves the arithmetic mean of the precision scores calculated for each evaluated sample.- Returns:
- the arithmetic mean of all precision scores
-
getRecallScore
public double getRecallScore()
Retrieves the arithmetic mean of the recall score calculated for each evaluated sample.- Returns:
- the arithmetic mean of all recall scores
-
getFMeasure
public double getFMeasure()
Retrieves the f-measure score. f-measure = 2 * precision * recall / (precision + recall)- Returns:
- the f-measure or -1 if precision + recall <= 0
-
updateScores
public void updateScores(java.lang.Object[] references, java.lang.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 into fmeasure metric.- Parameters:
measure- the fmeasure
-
toString
public java.lang.String toString()
Creates a human read-ableStringrepresentation.- Overrides:
toStringin classjava.lang.Object- Returns:
- the results
-
precision
public static double precision(java.lang.Object[] references, java.lang.Object[] predictions)Calculates the precision score for the given reference and predicted spans.- Parameters:
references- the gold standard spanspredictions- the predicted spans- Returns:
- the precision score or NaN if there are no predicted spans
-
recall
public static double recall(java.lang.Object[] references, java.lang.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 NaN if there are no reference spans
-
-