nltk.ConfusionMatrix
¶
-
class
nltk.
ConfusionMatrix
(reference, test, sort_by_count=False)[source]¶ The confusion matrix between a list of reference values and a corresponding list of test values. Entry [r,t] of this matrix is a count of the number of times that the reference value r corresponds to the test value t. E.g.:
>>> from nltk.metrics import ConfusionMatrix >>> ref = 'DET NN VB DET JJ NN NN IN DET NN'.split() >>> test = 'DET VB VB DET NN NN NN IN DET NN'.split() >>> cm = ConfusionMatrix(ref, test) >>> print(cm['NN', 'NN']) 3
Note that the diagonal entries Ri=Tj of this matrix corresponds to correct values; and the off-diagonal entries correspond to incorrect values.
Methods¶
__init__ (reference, test[, sort_by_count]) |
Construct a new confusion matrix from a list of reference values and a corresponding list of test values. | ||
key () |
|||
pretty_format ([show_percents, ...]) |
|
||
unicode_repr () |