def testStdNfoldNormalizedAccuracies(self): # Same test considering normalized accuracies cm = ConfusionMatrix() # Fold 0 with normalized acc = 0% cm = self.populateFold(cm, 0, 1, 0, 1, fold=0) # Fold 1 with normalized acc = 10% cm = self.populateFold(cm, 4, 16, 0, 10, fold=1) # Fold 2 with normalized acc = 20% cm = self.populateFold(cm, 2, 8, 2, 8, fold=2) # resulting accuracy should be the average nfolds = 3. values = [-10. * -10., 0., 10. * 10.] # each fold contribution to the # std after substractig the mean analitic_std = sqrt(sum(values) / nfolds) self.assertEqual(cm.stdNfold(normalizedAccuracies=True), analitic_std) # Also make sure that this test does not work without the normalization self.assertNotEqual(cm.stdNfold(normalizedAccuracies=False), analitic_std)
def testStdNfold(self): cm = ConfusionMatrix() # Fold 0 with acc = 0% cm = self.populateFold(cm, 0, 1, 0, 1, fold=0) # Fold 1 with acc = 10% cm = self.populateFold(cm, 1, 9, 1, 9, fold=1) # Fold 2 with acc = 20% cm = self.populateFold(cm, 2, 8, 2, 8, fold=2) nfolds = 3. values = [-10. * -10., 0., 10. * 10.] # each fold contribution to the # std after substractig the mean analitic_std = sqrt(sum(values) / nfolds) self.assertEqual(cm.stdNfold(), analitic_std)