Пример #1
0
    def test_unequal_y_sizes(self):
        y_true = [0, 1, 0, 1, 0, 1, 1]
        y_pred = [0, 0, 1, 1]
        expected_msg = "Found input variables with inconsistent numbers of samples: [7, 4]"

        with pytest.raises(ValueError) as error:
            metrics.count(y_true, y_pred)
        assert str(error.value) == expected_msg
Пример #2
0
    def test_multi_group(self):
        y_true = [
            0,
            1,
            0,
            1,
            0,
            1,
            1,
            1,
            1,
            0,
            0,
            1,
            1,
            0,
            1,
            0,
            1,
            1,
            0,
            1,
            0,
            1,
            0,
            0,
            1,
            0,
        ]
        y_pred = [
            0,
            0,
            1,
            1,
            1,
            1,
            0,
            1,
            1,
            1,
            0,
            0,
            0,
            0,
            1,
            1,
            1,
            1,
            1,
            0,
            1,
            1,
            1,
            0,
            0,
            0,
        ]

        assert 26 == metrics.count(y_true, y_pred)
Пример #3
0
    def test_group_of_one(self):
        y_true = [1]
        y_pred = [0]

        assert 1 == metrics.count(y_true, y_pred)
Пример #4
0
    def test_empty_group(self):
        y_true = []
        y_pred = []

        assert 0 == metrics.count(y_true, y_pred)