def test_accuracy_all_correct(self): "Accuracy with all correct predictions" y_true = [1 for _ in range(50)] + [0 for _ in range(50)] y_pred = [1 for _ in range(50)] + [0 for _ in range(50)] score = metrics.accuracy(y_pred, y_true) self.assertAlmostEqual(score, 1.0)
def test_accuracy_numpy(self): "Accuracy with numpy arrays" y_true = np.array([1 for _ in range(50)] + [0 for _ in range(50)]) y_pred = ([1 for _ in range(30)] + [0 for _ in range(20)] + [0 for _ in range(50)]) score = metrics.accuracy(y_pred, y_true) self.assertAlmostEqual(score, 0.8)
def test_accuracy(self): "Accuracy" y_true = [1 for _ in range(50)] + [0 for _ in range(50)] y_pred = ([1 for _ in range(30)] + [0 for _ in range(20)] + [0 for _ in range(50)]) score = metrics.accuracy(y_pred, y_true) self.assertAlmostEqual(score, 0.8)