def test_score_func(self): with pytest.raises(TypeError): kbest = SelectKBest(score_func=10, k=10) kbest.fit(X_class, y_reg) with pytest.raises(TypeError): kbest = SelectKBest(score_func="chi2", k=10) kbest.fit(X_class, y_reg)
def test_default_score_func(self): kbest = SelectKBest(k=10) kbest.fit(X_reg, y_reg) assert kbest.score_func.__name__ == f_regression.__name__ kbest = SelectKBest() kbest.fit(X_class, y_class) assert kbest.score_func.__name__ == f_classif.__name__
def test_default_score_func(self): kbest = SelectKBest() kbest.fit({"k": 10, "X": X_reg, "y": y_reg}) assert kbest.score_func.__name__ == f_regression.__name__ kbest = SelectKBest() kbest.fit({"X": X_class, "y": y_class}) assert kbest.score_func.__name__ == f_classif.__name__
def test_score_func(self): with pytest.raises(TypeError): kbest = SelectKBest() kbest.fit({"score_func": 10, "k": 10, "X": X_class, "y": y_reg}) with pytest.raises(TypeError): kbest = SelectKBest() kbest.fit({ "score_func": "chi2", "k": 10, "X": X_class, "y": y_reg })
def test_default_score_func(test_input, test_output): kbest = SelectKBest() kbest.fit(params=test_input) assert kbest.score_func.__name__ == test_output
def test_score_func(test_input): with pytest.raises(TypeError): kbest = SelectKBest() kbest.fit(params=test_input)