Returns the matrix of classes x predicted classes as a dictionary.
(self, classify=lambda document: True, documents=[])
| 1862 | class ConfusionMatrix(defaultdict): |
| 1863 | |
| 1864 | def __init__(self, classify=lambda document: True, documents=[]): |
| 1865 | """ Returns the matrix of classes x predicted classes as a dictionary. |
| 1866 | """ |
| 1867 | defaultdict.__init__(self, lambda: defaultdict(int)) |
| 1868 | for document, type1 in documents: |
| 1869 | type2 = classify(document) |
| 1870 | self[type1][type2] += 1 |
| 1871 | |
| 1872 | def split(self): |
| 1873 | """ Returns an iterator over one-vs-all (type, TP, TN, FP, FN)-tuples. |