Ejemplo n.º 1
0
def test_invalid_input():
    kbest = SelectKBest()
    with pytest.raises(TypeError):
        kbest.fit_transform({})
def test_fit_transform():
    kbest = SelectKBest()
    params = {"score_func": f_regression, "k": 5, "X": X_reg, "y": y_reg}
    kbest.fit_transform(params)
    assert params["X_best"].shape[1] == 5
Ejemplo n.º 3
0
def test_fit_transform(params, split_size):
    kbest = SelectKBest()
    kbest.fit_transform(params)
    assert params["train_df"].shape == (split_size, params["k"] + 1)
    if "test_df" in params.keys():
        assert params["test_df"].shape == (1000 - split_size, params["k"] + 1)
Ejemplo n.º 4
0
 def test_fit_transform(self):
     kbest = SelectKBest(score_func=f_regression, k=5)
     X_new = kbest.fit_transform(X_reg, y_reg)
     assert X_new.shape[1] == 5