You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Readme.md
+62-47Lines changed: 62 additions & 47 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,19 +12,22 @@ We currently support the following loss functions
12
12
- Quantile regression
13
13
- Multiple response versions of the linear, huber and poisson losses
14
14
15
-
and the following penalties
15
+
the following basic penalties
16
16
17
17
- Lasso
18
18
-[Group Lasso](https://rss.onlinelibrary.wiley.com/doi/pdfdirect/10.1111/j.1467-9868.2005.00532.x?casa_token=wN_F5iYwNK4AAAAA:4PVnAz4icP5hR9FIRviV0zqnp_QAibv55uYkptKQKezvDoqtMzrSpFyHh15lL4IO1yFJ3Sfl4OwOuA) with user specified groups
19
19
-[Multi-task Lasso](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.MultiTaskLasso.html#sklearn.linear_model.MultiTaskLasso) (i.e. L1 to L2 norm)
-[Elastic net](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.ElasticNet.html) versions of the above Lasso penalties
24
-
- Weighted versions of all of the above
25
-
- Concave penalties such as [SCAD](https://fan.princeton.edu/papers/01/penlike.pdf)
26
24
27
-
The concave penalties are fit by applying the *local linear approximation* (LLA) algorithm to a "good enough" initializer such as the Lasso fit. See [(Fan et al, 2014)](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4295817/) for details. We provide concave versions of the group Lasso, multi-task Lasso and nuclear norm that are not discussed in the original paper.
25
+
and the following more sophisticated penalties
26
+
27
+
-[Elastic net](https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.ElasticNet.html) versions of the above
28
+
- Adaptive Lasso versions of the above (including multi-task, group and nuclear norm)
29
+
- Folded concave penalties (FCP) such as [SCAD](https://fan.princeton.edu/papers/01/penlike.pdf) fit by applying the *local linear approximation* (LLA) algorithm to a "good enough" initializer such as the Lasso fit ([Zou and Li, 2008](http://www.personal.psu.edu/ril4/research/AOS0316.pdf); [Fan et al, 2014](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4295817/)). We also provide concave versions of the group Lasso, multi-task Lasso and nuclear norm that are not discussed in the original paper.
30
+
28
31
29
32
The built in cross-validation functionality supports
30
33
@@ -33,9 +36,9 @@ The built in cross-validation functionality supports
33
36
- custom evaluation metrics
34
37
- custom selection rules such as the '1se' rule from the glmnet package
35
38
36
-
We provide a built in FISTA algorithm [(Beck and Teboulle, 2009)](https://epubs.siam.org/doi/pdf/10.1137/080716542?casa_token=cjyK5OxcbSoAAAAA:lQOp0YAVKIOv2-vgGUd_YrnZC9VhbgWvZgj4UPbgfw8I7NV44K82vbIu0oz2-xAACBz9k0Lclw) that covers most glm loss + non-smooth penalty combinations (the ya_glm.opt module is inspired by [pyunlocbox](https://github.com/epfl-lts2/pyunlocbox), [copt](https://github.com/openopt/copt), and [lightning](https://github.com/scikit-learn-contrib/lightning)). **It is straightforward for you to plug in your favorite penalized GLM optimization algorithm.**
39
+
We provide a built in FISTA algorithm [(Beck and Teboulle, 2009)](https://epubs.siam.org/doi/pdf/10.1137/080716542?casa_token=cjyK5OxcbSoAAAAA:lQOp0YAVKIOv2-vgGUd_YrnZC9VhbgWvZgj4UPbgfw8I7NV44K82vbIu0oz2-xAACBz9k0Lclw) that covers most glm loss + non-smooth penalty combinations (`ya_glm.opt`is inspired by [pyunlocbox](https://github.com/epfl-lts2/pyunlocbox) and [lightning](https://github.com/scikit-learn-contrib/lightning)). **It is straightforward for you to plug in your favorite penalized GLM optimization algorithm.**
37
40
38
-
We aim to add additional loss functions (e.g. quantile, gamma, cox regression) and penalties (e.g. generalized Lasso, TV1)
41
+
We aim to add additional loss functions (e.g. gamma, cox regression) and penalties (e.g. generalized Lasso, TV1)
39
42
40
43
41
44
**Beware**: this is a preliminary release of the package; the documentation and testing may leave you wanting and the code may be subject to breaking changes in the near future.
@@ -56,61 +59,71 @@ To use the backend from [andersoncd](https://github.com/mathurinm/andersoncd) yo
56
59
57
60
58
61
```python
59
-
from ya_glm.backends.fista.LinearRegression import Lasso, LassoCV, RidgeCV, LassoENetCV, \
60
-
GroupLassoENet, GroupLassoENetCV, \
61
-
FcpLLA, FcpLLACV
62
+
from ya_glm.estimator_getter import get_pen_glm
63
+
from ya_glm.toy_data import sample_sparse_multinomial, sample_sparse_lin_reg
62
64
63
-
from ya_glm.toy_data import sample_sparse_lin_reg
65
+
# multinomial regression model with a row sparse coefficient matrix
66
+
X, y = sample_sparse_multinomial(n_samples=100, n_features=10, n_classes=3)[0:2]
64
67
65
-
# sample some linear regression data
66
-
X, y = sample_sparse_lin_reg(n_samples=100, n_features=20)[0:2]
68
+
# programatically generate any loss + penalty combination
We can programmatically generate estimators for any loss + penalty combination (this avoids writing a ton of code by hand).
98
102
99
-
```python
100
-
from ya_glm.estimator_getter import get_pen_glm, get_fcp_glm
101
-
from ya_glm.toy_data import sample_sparse_log_reg
103
+
# Here we an Elastic Net version of the Adaptive Lasso
104
+
# with user specified groups for a liner regression example
105
+
Est, EstCV = get_pen_glm(loss_func='lin_reg', penalty='adpt_enet')
106
+
X, y = sample_sparse_lin_reg(n_samples=100, n_features=10, n_nonzero=5)[0:2]
107
+
108
+
groups = [range(5), range(5, 10)]
109
+
est = Est(groups=groups)
110
+
EstCV(estimator=est).fit(X, y)
102
111
103
-
# sample some logistic regression data
104
-
X, y = sample_sparse_log_reg(n_samples=100, n_features=20)[0:2]
105
112
106
-
# Get a penalized logistic regression estimator and corresponding cross-validation object
107
-
Est, EstCV = get_pen_glm(loss_func='log_reg', penalty='lasso')
113
+
# we provide a penalized qunatile regression solve based on
114
+
# Linear Programming for Lasso penalties or Quadratic Programming for Ridge type penalties
115
+
from ya_glm.backends.quantile_lp.glm_solver import solve_glm
108
116
109
-
# Or a concave penalized logistic regression estimator
110
-
# Est, EstCV = get_fcp_glm(loss_func='log_reg', penalty='lasso')
117
+
# Quantile regression with your favorite optimzation algorithm
118
+
# you can easily provide your own optimization algorithm to be the backend solver
119
+
Est, EstCV = get_pen_glm(loss_func='quantile',
120
+
penalty='adpt_lasso',
121
+
backend= {'solve_glm': solve_glm # solves a single penalize GLM problem
122
+
# 'solve_glm_path': None # path algorithm
123
+
}
124
+
)
111
125
112
-
est = Est().fit(X, y) # single fit
113
-
est_cv = EstCV().fit(X, y) # cross-validation
126
+
Est(quantile=0.5).fit(X, y)
114
127
```
115
128
116
129
@@ -137,5 +150,7 @@ bug fixes, spelling errors, new features, etc.
137
150
138
151
Beck, A. and Teboulle, M., 2009. [A fast iterative shrinkage-thresholding algorithm for linear inverse problems](https://epubs.siam.org/doi/pdf/10.1137/080716542?casa_token=cjyK5OxcbSoAAAAA:lQOp0YAVKIOv2-vgGUd_YrnZC9VhbgWvZgj4UPbgfw8I7NV44K82vbIu0oz2-xAACBz9k0Lclw). SIAM journal on imaging sciences, 2(1), pp.183-202.
139
152
153
+
Zou, H. and Li, R., 2008. [One-step sparse estimates in nonconcave penalized likelihood models](http://www.personal.psu.edu/ril4/research/AOS0316.pdf). Annals of statistics, 36(4), p.1509.
154
+
140
155
141
156
Fan, J., Xue, L. and Zou, H., 2014. [Strong oracle optimality of folded concave penalized estimation](https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4295817/). Annals of statistics, 42(3), p.819.
0 commit comments