def test_fit_predict_binary(X_y_binary): X, y = X_y_binary sk_clf = SKElasticNetClassifier(loss="log", penalty="elasticnet", alpha=0.5, l1_ratio=0.5, n_jobs=-1, random_state=0) sk_clf.fit(X, y) y_pred_sk = sk_clf.predict(X) y_pred_proba_sk = sk_clf.predict_proba(X) clf = ElasticNetClassifier() clf.fit(X, y) y_pred = clf.predict(X) y_pred_proba = clf.predict_proba(X) np.testing.assert_almost_equal(y_pred_sk, y_pred.to_series().values, decimal=5) np.testing.assert_almost_equal(y_pred_proba_sk, y_pred_proba.to_dataframe().values, decimal=5)
def test_fit_predict_multi(X_y_multi): X, y = X_y_multi sk_clf = SKElasticNetClassifier(loss="log", penalty="elasticnet", alpha=0.5, l1_ratio=0.5, n_jobs=-1, random_state=0) sk_clf.fit(X, y) y_pred_sk = sk_clf.predict(X) y_pred_proba_sk = sk_clf.predict_proba(X) clf = ElasticNetClassifier() fitted = clf.fit(X, y) assert isinstance(fitted, ElasticNetClassifier) y_pred = clf.predict(X) y_pred_proba = clf.predict_proba(X) np.testing.assert_almost_equal(y_pred, y_pred_sk, decimal=5) np.testing.assert_almost_equal(y_pred_proba, y_pred_proba_sk, decimal=5)