responsibly.fairness.metrics.utils   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 21
rs 10
c 0
b 0
f 0
wmc 4

2 Functions

Rating   Name   Duplication   Size   Complexity  
A _assert_binary() 0 9 3
A _groupby_y_x_sens() 0 5 1
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