From d70e2a655acd2d2c1112fe148761e0b12c8858b4 Mon Sep 17 00:00:00 2001 From: Matthias Schmidtblaicher Date: Wed, 31 Jan 2024 19:19:17 +0100 Subject: [PATCH] also set alpha in golden master --- tests/glm/test_glm.py | 5 ++++- tests/glm/test_golden_master.py | 19 +++++++++++++------ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/tests/glm/test_glm.py b/tests/glm/test_glm.py index fe552d79..08080212 100644 --- a/tests/glm/test_glm.py +++ b/tests/glm/test_glm.py @@ -430,7 +430,10 @@ def test_glm_fit_intercept_argument(estimator, fit_intercept): ) def test_glm_solver_argument(estimator, solver, l1_ratio, y, X): """Test GLM for invalid solver argument.""" - glm = estimator(solver=solver, l1_ratio=l1_ratio, alpha=1.0) + kwargs = {"solver": solver, "l1_ratio": l1_ratio} + if estimator == GeneralizedLinearRegressor: + kwargs["alpha"] = 1.0 + glm = estimator(**kwargs) with pytest.raises(ValueError): glm.fit(X, y) diff --git a/tests/glm/test_golden_master.py b/tests/glm/test_golden_master.py index ac00f91b..8626256d 100644 --- a/tests/glm/test_golden_master.py +++ b/tests/glm/test_golden_master.py @@ -100,25 +100,32 @@ def expected_all(): gm_model_parameters = { - "default": {}, # default params - "half-regularization": {"alpha": 0.5}, # regularization (other than alpha = 1) - "elastic-net": {"l1_ratio": 0.5}, # elastic-net - "lasso": {"l1_ratio": 1}, # lasso + "regularization": {"alpha": 1.0}, # regularization with alpha = 1 + "half-regularization": {"alpha": 0.5}, # regularization with alpha = 0 + "elastic-net": {"l1_ratio": 0.5, "alpha": 1.0}, # elastic-net + "lasso": {"l1_ratio": 1, "alpha": 1.0}, # lasso "variable_p1": { "l1_ratio": 1, "P1": np.arange(30) / 10, + "alpha": 1.0, }, # lasso with variable penalty "variable_p2": { "l1_ratio": 0, "P2": _make_P2(), + "alpha": 1.0, }, # ridge with Tikhonov regularization "variable_p1_p2": { "l1_ratio": 0.5, "P1": np.arange(30) / 10, "P2": _make_P2(), + "alpha": 1.0, }, # elastic net with P1 and P2 variable penalty - "fit_intercept": {"fit_intercept": False}, # do not fit the intercept - "bounds": {"lower_bounds": np.full(30, 0), "upper_bounds": np.full(30, 0.4)}, + "fit_intercept": {"fit_intercept": False, "alpha": 1.0}, # do not fit the intercept + "bounds": { + "lower_bounds": np.full(30, 0), + "upper_bounds": np.full(30, 0.4), + "alpha": 1.0, + }, }