def test_f1_non_zero_one_input(self):

        # Data
        actual = ['a', 'b', 'a', 'a']
        predicted = ['a', 'b', 'a', 'a']

        # Metric
        metric = BinaryClassificationMetrics.F1()

        # Score
        with self.assertRaises(ValueError):
            metric.get_score(actual, predicted)
    def test_f1_non_binary_input(self):

        # Data
        actual = [0, 1, 2, 0, 0, 0]
        predicted = [0, 0, 0, 0, 0, 0]

        # Metric
        metric = BinaryClassificationMetrics.F1()

        # Score
        with self.assertRaises(ValueError):
            metric.get_score(actual, predicted)
    def test_f1_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, 0])

        # Metric
        metric = BinaryClassificationMetrics.F1()

        # Score
        score = metric.get_score(actual, predicted)
        self.assertEqual(score, 0.6666666666666666)
    def test_f1_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, 0])

        # Metric
        metric = BinaryClassificationMetrics.F1()

        # Score
        score = metric.get_score(actual, predicted)
        self.assertEqual(score, 0.6666666666666666)
    def test_f1(self):

        # Data
        actual = [1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1]
        predicted = [1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0]

        # Metric
        metric = BinaryClassificationMetrics.F1()

        # Score
        score = metric.get_score(actual, predicted)
        self.assertEqual(score, 0.6666666666666666)