_assert_binary()   A
last analyzed

Complexity

Conditions 3

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 6
nop 2
dl 0
loc 9
rs 10
c 0
b 0
f 0
1
import pandas as pd
2
from sklearn.metrics._classification import _check_targets
3
4
5
def _assert_binary(y1, y2=None):
6
7
    if y2 is None:
8
        y2 = y1
9
10
    y_type, _, _ = _check_targets(y1, y2)
11
12
    if y_type != 'binary':
13
        raise ValueError('y_true and y_pred must be binary.')
14
15
16
def _groupby_y_x_sens(y_true, y_score, x_sens):
17
    return (pd.DataFrame({'y_true': y_true,
18
                          'y_score': y_score,
19
                          'x_sens': x_sens})
20
            .groupby('x_sens'))
21