示例#1
0
 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)
示例#2
0
    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__
示例#3
0
    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__
示例#4
0
 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
         })
示例#5
0
def test_default_score_func(test_input, test_output):
    kbest = SelectKBest()
    kbest.fit(params=test_input)
    assert kbest.score_func.__name__ == test_output
示例#6
0
def test_score_func(test_input):
    with pytest.raises(TypeError):
        kbest = SelectKBest()
        kbest.fit(params=test_input)