nltk.metrics.f_measure¶
- nltk.metrics.f_measure(reference, test, alpha=0.5)[source]¶
Given a set of reference values and a set of test values, return the f-measure of the test values, when compared against the reference values. The f-measure is the harmonic mean of the
precisionandrecall, weighted byalpha. In particular, given the precision p and recall r defined by:p = card(
referenceintersectiontest)/card(test)r = card(
referenceintersectiontest)/card(reference)
The f-measure is:
1/(alpha/p + (1-alpha)/r)
If either
referenceortestis empty, thenf_measurereturns None.- Parameters
reference (set) – A set of reference values.
test (set) – A set of values to compare against the reference set.
- Return type
float or None