예제 #1
0
def test_feature_importance(X_y_regression):
    X, y = X_y_regression

    sk_clf = SKElasticNetRegressor(alpha=0.5,
                                   l1_ratio=0.5,
                                   random_state=0,
                                   normalize=False,
                                   max_iter=1000)
    sk_clf.fit(X, y)

    clf = ElasticNetRegressor()
    clf.fit(X, y)

    np.testing.assert_almost_equal(sk_clf.coef_, clf.feature_importance, decimal=5)
예제 #2
0
def test_fit_predict(X_y_regression):
    X, y = X_y_regression

    sk_clf = SKElasticNetRegressor(alpha=0.5,
                                   l1_ratio=0.5,
                                   random_state=0,
                                   normalize=False,
                                   max_iter=1000)
    sk_clf.fit(X, y)
    y_pred_sk = sk_clf.predict(X)

    clf = ElasticNetRegressor()
    fitted = clf.fit(X, y)
    assert isinstance(fitted, ElasticNetRegressor)

    y_pred = clf.predict(X)
    np.testing.assert_almost_equal(y_pred, y_pred_sk, decimal=5)
예제 #3
0
def test_en_parameters():
    clf = ElasticNetRegressor(alpha=0.75, l1_ratio=0.5, random_state=2)
    expected_parameters = {
        "alpha": 0.75,
        "l1_ratio": 0.5,
        'max_iter': 1000,
        'normalize': False
    }
    assert clf.parameters == expected_parameters