nltk.f_measure()
¶
-
nltk.
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
precision
andrecall
, weighted byalpha
. In particular, given the precision p and recall r defined by:- p = card(
reference
intersectiontest
)/card(test
) - r = card(
reference
intersectiontest
)/card(reference
)
The f-measure is:
- 1/(alpha/p + (1-alpha)/r)
If either
reference
ortest
is empty, thenf_measure
returns 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
- p = card(