def testAccuraciesNFold(self): cm = ConfusionMatrix() # Fold 0 with acc = 100% cm = self.populateFold(cm, 1, 0, 1, 0, fold=0) # Fold 1 with acc = 0% cm = self.populateFold(cm, 0, 1, 0, 1, fold=1) # Resulting accuracy should be the average self.assertEqual(cm.accuracy(), 50.0)
def testNormalizedAccuracy(self): cm = ConfusionMatrix() # Consider the following confussion matrix, # A B # A | 3 | 1 | # B | 6 | 2 | # raw accuracy is 5 / 12 ~= 41.67% # However, normalized accuracy divides each # class contrubion by the class population: # A accuracy: 3 / 4, B accuracy: 2 / 8 # normalized accuracy is 50% cm = self.populateFold(cm, 3, 1, 2, 6, fold=0) self.assertEqual(cm.accuracy(), 100 * 5. / 12) self.assertEqual(cm.normalizedAccuracy(), 50.0)