-
Notifications
You must be signed in to change notification settings - Fork 38
ENH Add SLOPE penalty #92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
67 commits
Select commit
Hold shift + click to select a range
0868b0f
POC FISTA
PABannier 8584299
CLN
PABannier c82e32e
changed obj_freq from 100 to 10
PABannier 4940a0d
WIP Lipschitz
PABannier e47c68a
ADD global lipschitz constants
PABannier 3635f24
FISTA with global lipschitz
PABannier 82795b5
WIP slope
PABannier 4880112
writing tests
PABannier 22150dc
Merge branch 'fista' of https://github.com/PABannier/skglm into slope
PABannier 5764501
working SLOPE
PABannier 46a9a76
better tests
PABannier 9f0653a
support sparse matrices
PABannier fe159be
fix mistake
PABannier ef5187c
Merge branch 'fista' of https://github.com/PABannier/skglm into slope
PABannier 8e74e8a
RM toy_fista
PABannier d8ab26b
Merge branch 'fista' of https://github.com/PABannier/skglm into slope
PABannier a24ed9c
green
PABannier 4362c2c
mv `_prox_vec` to utils
PABannier 2665d5d
rm `opt_freq`
PABannier 2e408bc
fix tests
PABannier 8524cf7
Update skglm/solvers/fista.py
PABannier dd658f8
huber comment
PABannier 7c9fbe1
Merge branch 'fista' of https://github.com/PABannier/skglm into fista
PABannier cbc5418
WIP
PABannier b6c664c
Merge branch 'main' of https://github.com/scikit-learn-contrib/skglm …
Badr-MOUFAD e76dfb1
implement power method
Badr-MOUFAD 2a4bce3
private ``prox_vec``
Badr-MOUFAD cd39a62
random init in power method && default args
Badr-MOUFAD 0e4d42a
use power method for ``global_lipschitz``
Badr-MOUFAD 2bbc8f5
fix && refactor unittest
Badr-MOUFAD ed3686a
add docs for tol and max_iter && clean ups
Badr-MOUFAD aa15c46
remove square form spectral norm
Badr-MOUFAD 27b918d
refactor ``_prox_vec`` function
Badr-MOUFAD 9d8e3c0
fix bug segmentation fault
Badr-MOUFAD e5ce21b
add Fista to docs && fix unittest
Badr-MOUFAD e8ee57a
Merge branch 'fista' into slope
PABannier 23ab37e
added SLOPE to penalty submodule
PABannier 77180b8
moved prox_SLOPE to utils
PABannier 9592512
WIP dirty hack for FISTA
PABannier b9cfc84
add test slope
PABannier b869393
added references to SLOPE
PABannier 96f88af
added ref to SLOPE algo
PABannier edb0e34
Merge branch 'main' of https://github.com/PABannier/skglm into slope
PABannier 4924604
more robust design with not implemented error
PABannier 817c6a9
debugging WIP
PABannier 46ca4e8
Merge branch 'main' of https://github.com/PABannier/skglm into slope
PABannier 8c83d94
passing tests
PABannier b389ad5
green
PABannier ade38e0
CLN
PABannier 049b599
ditto
PABannier 2830306
pydocstyle
PABannier 04819ed
fix ref
PABannier 71e0e96
np.full
PABannier 1d0bee7
valueerror
PABannier 7f84104
fix ref in doc && add to api
Badr-MOUFAD 06260a5
docs ``prox_SLOPE``
Badr-MOUFAD ab4d192
Merge branch 'main' of https://github.com/scikit-learn-contrib/skglm …
Badr-MOUFAD 3668e05
create ``non_seperable`` module
Badr-MOUFAD 48e82d4
remove SLOPE from separable penalties
Badr-MOUFAD d55c232
added docstring for alphas
PABannier a3480bb
fix typos non_seperable -> non_separable
PABannier eb41e20
added pyslope as an additional test
PABannier 7317e25
added pyslope as test dependency
PABannier 5910445
Update skglm/solvers/fista.py
PABannier 6266e65
fix exception in fista
Badr-MOUFAD 3921b42
xfail when import slope in test
Badr-MOUFAD 0f79cba
format test
Badr-MOUFAD File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,7 @@ Penalties | |
WeightedGroupL2 | ||
SCAD | ||
BlockSCAD | ||
SLOPE | ||
|
||
|
||
Datafits | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import numpy as np | ||
from numba import float64 | ||
|
||
from skglm.penalties.base import BasePenalty | ||
from skglm.utils import prox_SLOPE | ||
|
||
|
||
class SLOPE(BasePenalty): | ||
"""Sorted L-One Penalized Estimation (SLOPE) penalty. | ||
|
||
Attributes | ||
---------- | ||
alphas : array, shape (n_features,) | ||
Contain regularization levels for every feature. | ||
When ``alphas`` contain a single unique value, ``SLOPE`` | ||
is equivalent to the ``L1``penalty. | ||
|
||
References | ||
---------- | ||
.. [1] M. Bogdan, E. van den Berg, C. Sabatti, W. Su, E. Candes | ||
"SLOPE - Adaptive Variable Selection via Convex Optimization", | ||
The Annals of Applied Statistics 9 (3): 1103-40 | ||
https://doi.org/10.1214/15-AOAS842 | ||
""" | ||
|
||
def __init__(self, alphas): | ||
self.alphas = alphas | ||
|
||
def get_spec(self): | ||
spec = ( | ||
('alphas', float64[:]), | ||
) | ||
return spec | ||
|
||
def params_to_dict(self): | ||
return dict(alphas=self.alphas) | ||
|
||
def value(self, w): | ||
"""Compute the value of SLOPE at w.""" | ||
return np.sum(np.sort(np.abs(w)) * self.alphas[::-1]) | ||
|
||
def prox_vec(self, x, stepsize): | ||
def _prox(_x, _alphas): | ||
sign_x = np.sign(_x) | ||
_x = np.abs(_x) | ||
sorted_indices = np.argsort(_x)[::-1] | ||
prox = prox_SLOPE(_x[sorted_indices], _alphas) | ||
prox[sorted_indices] = prox | ||
return prox * sign_x | ||
return _prox(x, self.alphas * stepsize) | ||
|
||
def prox_1d(self, value, stepsize, j): | ||
raise ValueError( | ||
"No coordinate-wise proximal operator for SLOPE. Use `prox_vec` instead." | ||
) | ||
|
||
def subdiff_distance(self, w, grad, ws): | ||
return ValueError( | ||
"No subdifferential distance for SLOPE. Use `opt_strategy='fixpoint'`" | ||
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.