Ejemplo n.º 1
0
def test_error_when_regression_is_false_and_target_is_continuous(
        df_discretise):
    np.random.seed(42)
    mu, sigma = 0, 3
    y = np.random.normal(mu, sigma, len(df_discretise))
    with pytest.raises(ValueError):
        transformer = DecisionTreeDiscretiser(regression=False)
        transformer.fit(df_discretise[["var_A", "var_B"]], y)
def test_error_if_y_not_passed(df_normal_dist):
    # test case 3: raises error if target is not passed
    with pytest.raises(TypeError):
        encoder = DecisionTreeDiscretiser()
        encoder.fit(df_normal_dist)
Ejemplo n.º 3
0
def test_error_when_regression_is_true_and_target_is_binary(df_discretise):
    with pytest.raises(ValueError):
        transformer = DecisionTreeDiscretiser(regression=True)
        transformer.fit(df_discretise[["var_A", "var_B"]],
                        df_discretise["target"])