def test_classification_recall_non_zero_one_input(self): # Data actual = ['a', 'b', 'a', 'a'] predicted = ['a', 'b', 'a', 'a'] # Metric metric = BinaryClassificationMetrics.Recall() # Score with self.assertRaises(ValueError): metric.get_score(actual, predicted)
def test_classification_recall_pandas(self): # Data actual = pd.Series([1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1]) predicted = pd.Series([1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1]) # Metric metric = BinaryClassificationMetrics.Recall() # Score score = metric.get_score(actual, predicted) self.assertEqual(score, 0.75)
def test_classification_recall_non_binary_input(self): # Data actual = [0, 1, 2, 0, 0, 0] predicted = [0, 0, 0, 0, 0, 0] # Metric metric = BinaryClassificationMetrics.Recall() # Score with self.assertRaises(ValueError): metric.get_score(actual, predicted)
def test_classification_recall_numpy(self): # Data actual = np.array([1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1]) predicted = np.array([1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1]) # Metric metric = BinaryClassificationMetrics.Recall() # Score score = metric.get_score(actual, predicted) self.assertEqual(score, 0.75)