Skip to content

Commit 97faf9e

Browse files
committed
update test SLOPE
1 parent 7a2a4e3 commit 97faf9e

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

skglm/tests/test_penalties.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,25 +86,24 @@ def test_slope_lasso():
8686

8787

8888
def test_slope():
89-
# compare solutions with `pyslope`: https://github.com/jolars/pyslope
89+
# compare solutions with `sortedl1`: https://github.com/jolars/sortedl1
9090
try:
91-
from slope.solvers import pgd_slope # noqa
92-
from slope.utils import lambda_sequence # noqa
91+
from sortedl1 import Slope as SlopeEst # noqa
9392
except ImportError:
9493
pytest.xfail(
9594
"This test requires slope to run.\n"
96-
"https://github.com/jolars/pyslope")
95+
"https://github.com/jolars/sortedl1")
9796

98-
q = 0.1
99-
alphas = lambda_sequence(
100-
X, y, fit_intercept=False, reg=alpha / alpha_max, q=q)
97+
# q = 0.1
98+
# alphas = lambda_sequence(
99+
# X, y, fit_intercept=False, reg=alpha / alpha_max, q=q)
100+
clf = SlopeEst(alpha=0.01, fit_intercept=False).fit(X, y)
101+
alphas = clf.lambda_
101102
ours = GeneralizedLinearEstimator(
102-
penalty=SLOPE(alphas),
103+
penalty=SLOPE(clf.alpha * alphas),
103104
solver=FISTA(max_iter=1000, tol=tol, opt_strategy="fixpoint"),
104105
).fit(X, y)
105-
pyslope_out = pgd_slope(
106-
X, y, alphas, fit_intercept=False, max_it=1000, gap_tol=tol)
107-
np.testing.assert_allclose(ours.coef_, pyslope_out["beta"], rtol=1e-5)
106+
np.testing.assert_allclose(ours.coef_, clf.coef_, rtol=1e-5)
108107

109108

110109
@pytest.mark.parametrize("fit_intercept", [True, False])

0 commit comments

Comments
 (0)