Skip to content

Commit

Permalink
also set alpha in golden master
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthiasSchmidtblaicherQC committed Jan 31, 2024
1 parent e82f597 commit d70e2a6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
5 changes: 4 additions & 1 deletion tests/glm/test_glm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
19 changes: 13 additions & 6 deletions tests/glm/test_golden_master.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
}


Expand Down

0 comments on commit d70e2a6

Please sign in to comment.