Skip to content

Commit 7f714c2

Browse files
authored
FIX/MNT install R with conda and use python 3.10 on test workflow (#282)
1 parent 41792a0 commit 7f714c2

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

.github/workflows/main.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,21 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- uses: actions/checkout@v3
16-
- name: Set up Python 3.8
16+
- name: Set up Python 3.10
1717
uses: actions/setup-python@v3
1818
with:
19-
python-version: 3.8
19+
python-version: "3.10"
2020
- name: Install package and testing tools
2121
run: |
2222
python -m pip install --upgrade pip
2323
pip install .
2424
pip install .[test]
2525
- name: Install other dependencies
2626
run: |
27+
conda install rpy2 -c conda-forge
2728
pip install celer
2829
pip install statsmodels cvxopt
29-
pip install git+https://github.com/jolars/pyslope.git
30+
pip install git+https://github.com/jolars/sortedl1.git
3031
# for testing Cox estimator
3132
pip install lifelines
3233
pip install pandas

skglm/estimators.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from sklearn.utils.validation import (check_is_fitted, check_array,
1111
check_consistent_length)
1212
from sklearn.linear_model._base import (
13-
LinearModel, RegressorMixin,
13+
RegressorMixin, LinearModel,
1414
LinearClassifierMixin, SparseCoefMixin, BaseEstimator
1515
)
1616
from sklearn.utils.extmath import softmax
@@ -302,7 +302,7 @@ def get_params(self, deep=False):
302302
return params
303303

304304

305-
class Lasso(LinearModel, RegressorMixin):
305+
class Lasso(RegressorMixin, LinearModel):
306306
r"""Lasso estimator based on Celer solver and primal extrapolation.
307307
308308
The optimization objective for Lasso is:
@@ -449,7 +449,7 @@ def path(self, X, y, alphas, coef_init=None, return_n_iter=True, **params):
449449
return solver.path(X, y, datafit, penalty, alphas, coef_init, return_n_iter)
450450

451451

452-
class WeightedLasso(LinearModel, RegressorMixin):
452+
class WeightedLasso(RegressorMixin, LinearModel):
453453
r"""WeightedLasso estimator based on Celer solver and primal extrapolation.
454454
455455
The optimization objective for WeightedLasso is:
@@ -612,7 +612,7 @@ def fit(self, X, y):
612612
return _glm_fit(X, y, self, Quadratic(), penalty, solver)
613613

614614

615-
class ElasticNet(LinearModel, RegressorMixin):
615+
class ElasticNet(RegressorMixin, LinearModel):
616616
r"""Elastic net estimator.
617617
618618
The optimization objective for Elastic net is:
@@ -766,7 +766,7 @@ def fit(self, X, y):
766766
L1_plus_L2(self.alpha, self.l1_ratio, self.positive), solver)
767767

768768

769-
class MCPRegression(LinearModel, RegressorMixin):
769+
class MCPRegression(RegressorMixin, LinearModel):
770770
r"""Linear regression with MCP penalty estimator.
771771
772772
The optimization objective for MCPRegression is, with :math:`x >= 0`:
@@ -1381,7 +1381,7 @@ def fit(self, X, y):
13811381
return self
13821382

13831383

1384-
class MultiTaskLasso(LinearModel, RegressorMixin):
1384+
class MultiTaskLasso(RegressorMixin, LinearModel):
13851385
r"""MultiTaskLasso estimator.
13861386
13871387
The optimization objective for MultiTaskLasso is:
@@ -1557,7 +1557,7 @@ def path(self, X, Y, alphas, coef_init=None, return_n_iter=False, **params):
15571557
return solver.path(X, Y, datafit, penalty, alphas, coef_init, return_n_iter)
15581558

15591559

1560-
class GroupLasso(LinearModel, RegressorMixin):
1560+
class GroupLasso(RegressorMixin, LinearModel):
15611561
r"""GroupLasso estimator based on Celer solver and primal extrapolation.
15621562
15631563
The optimization objective for GroupLasso is:

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)