示例#1
0
def test_summary_get_support():
    data = load_breast_cancer()

    variable_names = data.feature_names
    X = data.data
    y = data.target

    process = BinningProcess(variable_names, min_iv=0.1, max_iv=0.6)

    with raises(ValueError):
        process.summary()

    with raises(ValueError):
        process.get_support()

    process.fit(X, y, check_input=True)

    assert isinstance(process.summary(), pd.DataFrame)

    with raises(ValueError):
        process.get_support(indices=True, names=True)

    assert all(process.get_support() == [
        False, False, False, False, False, False, False, False, False, True,
        False, True, False, False, True, False, False, False, True, True,
        False, False, False, False, False, False, False, False, False, True
    ])
    assert process.get_support(indices=True) == approx([9, 11, 14, 18, 19, 29])
    assert all(
        process.get_support(names=True) == [
            'mean fractal dimension', 'texture error', 'smoothness error',
            'symmetry error', 'fractal dimension error',
            'worst fractal dimension'
        ])
def test_summary_get_support():
    data = load_breast_cancer()

    variable_names = data.feature_names
    X = data.data
    y = data.target

    selection_criteria = {"iv": {"min": 0.1, "max": 0.6,
                                 "strategy": "highest", "top": 10}}

    process = BinningProcess(variable_names=variable_names,
                             selection_criteria=selection_criteria)

    with raises(ValueError):
        process.summary()

    with raises(ValueError):
        process.get_support()

    process.fit(X, y, check_input=True)

    assert isinstance(process.summary(), pd.DataFrame)

    with raises(ValueError):
        process.get_support(indices=True, names=True)

    assert all(process.get_support() == [
        False, False, False, False, False, False, False, False, False, True,
        False,  True, False, False,  True, False, False, False, True,  True,
        False, False, False, False, False, False, False, False, False,  True])
    assert process.get_support(indices=True) == approx([9, 11, 14, 18, 19, 29])
    assert all(process.get_support(names=True) == [
        'mean fractal dimension', 'texture error', 'smoothness error',
        'symmetry error', 'fractal dimension error',
        'worst fractal dimension'])