opennlp.tools.util.eval
Class FMeasure

java.lang.Object
  extended by opennlp.tools.util.eval.FMeasure

public final class FMeasure
extends Object

The FMeasure is 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
FMeasure()
           
 
Method Summary
 double getFMeasure()
          Retrieves the f-measure score.
 double getPrecisionScore()
          Retrieves the arithmetic mean of the precision scores calculated for each evaluated sample.
 double getRecallScore()
          Retrieves the arithmetic mean of the recall score calculated for each evaluated sample.
 void mergeInto(FMeasure measure)
           
static double precision(Object[] references, Object[] predictions)
          Calculates the precision score for the given reference and predicted spans.
static double recall(Object[] references, Object[] predictions)
          Calculates the recall score for the given reference and predicted spans.
 String toString()
          Creates a human read-able String representation.
 void updateScores(Object[] references, Object[] predictions)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FMeasure

public FMeasure()
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(Object[] references,
                         Object[] predictions)

mergeInto

public void mergeInto(FMeasure measure)

toString

public String toString()
Creates a human read-able String representation.

Overrides:
toString in class Object

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 NaN if 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 spans
predictions - the predicted spans
Returns:
the recall score or NaN if there are no reference spans


Copyright © 2013 The Apache Software Foundation. All Rights Reserved.