コード例 #1
0
def test_get_roc():
    for sensitive_feature_value in sensitive_feature_names_ex1:
        grouped_data, base_points, ignore_for_base_points, x_grid = \
            _get_grouped_data_and_base_points(sensitive_feature_value)

        roc_convex_hull = _get_roc(grouped_data, x_grid, sensitive_feature_value)
        curve = _interpolate_curve(roc_convex_hull, 'x', 'y', 'operation', x_grid)

        _assert_interpolated_points_are_between_base_points(base_points, curve,
                                                            ignore_for_base_points)
コード例 #2
0
def test_assert_interpolated_curve():
    # An easily interpretable test to make sure the assertion method works as expected
    base_points = pd.DataFrame({
        "x":         [0, 5, 10],
        "y":         [0, 2.5, 5],
        "operation": ["a", "b", "c"]  # irrelevant
    })
    x_grid = np.linspace(0, 10, 333)
    curve = _interpolate_curve(base_points, "x", "y", "operation", x_grid)

    _assert_interpolated_points_are_between_base_points(base_points, curve)
コード例 #3
0
def test_interpolate_curve():
    # The operation is irrelevant in this case since its semantics are not
    # used within _interpolate_curve.
    base_points = pd.DataFrame({
        "x":         [0,    1,   2,   3,   4,   5,   6,   7,   8,   9],
        "y":         [-5,  -2, -1.5, -1,   0,  0.5, 0.8, 1.0, 1.1, 1.15],
        "operation": ["i", "r", "r", "e", "l", "e", "v", "a", "n", "t"]
    })
    x_grid = np.linspace(0, 9, 100)
    curve = _interpolate_curve(base_points, "x", "y", "operation", x_grid)

    _assert_interpolated_points_are_between_base_points(base_points, curve)