Beispiel #1
0
def test_compare_sklearn_mod_0():
    X, y = data_gen(nrows = 99)
    function_scores = cross_validation(lm(), X = X, y = y, shuffle = False)
    sklearn_scores = cross_val_score(lm(), X = X, y = y, cv = 3)
    assert max(function_scores - sklearn_scores) < 0.000001, "results doesn't match sklearn"
Beispiel #2
0
def test_y_one_column():
    X, y = data_gen()
    y = X
    with pytest.raises(TypeError):
        cross_validation(lm(), X=X, y=y)
Beispiel #3
0
def test_X_y_Nrows():
    X, y = data_gen(nrows = 2)
    with pytest.raises(TypeError):
        cross_validation(lm(), X=X, y=y)
Beispiel #4
0
def test_random_state_range():
    X, y = data_gen()
    with pytest.raises(TypeError):
        cross_validation(lm, X=X, y=y, random_state=-10)
Beispiel #5
0
def test_X_y_match():
    X, y = data_gen()
    y = y[0:90]
    with pytest.raises(TypeError):
        cross_validation(lm(), X=X, y=y)
Beispiel #6
0
def test_model_linear_regression():
    X, y = data_gen()
    with pytest.raises(TypeError):
        cross_validation("LINEAR MODEL", X = X, y = y, random_state = 10)
Beispiel #7
0
def test_k_range():
    X, y = data_gen(nrows = 5)
    with pytest.raises(TypeError):
        cross_validation(lm(), X=X, y=y, k = 1)
    with pytest.raises(TypeError):
        cross_validation(lm(), X=X, y=y, k = 40)
Beispiel #8
0
def test_random_state_as_number():
    X, y = data_gen()
    with pytest.raises(TypeError):
        cross_validation(lm(), X = X, y = y, random_state = '10')
Beispiel #9
0
def test_shuffle_as_boolean():
    X, y = data_gen()
    with pytest.raises(TypeError):
        cross_validation(lm(), X = X, y = y, shuffle = '1')
    with pytest.raises(TypeError):
        cross_validation(lm(), X=X, y=y, shuffle=1.0)
Beispiel #10
0
def test_k_as_number():
    X, y = data_gen()
    with pytest.raises(TypeError):
        cross_validation(lm(), X = X, y = y, k = '3')
Beispiel #11
0
def test_y_as_dataframe():
    X, y = data_gen()
    with pytest.raises(TypeError):
        train_test_split(lm(), X = X, y = "y")
Beispiel #12
0
def test_X_as_dataframe():
    X, y = data_gen()
    with pytest.raises(TypeError):
        cross_validation(lm(), X = "X", y = y)