Skip to content

Commit 2347772

Browse files
committed
reorganize GLM penalties, added apdt lasso
1 parent 89e9cab commit 2347772

58 files changed

Lines changed: 2149 additions & 1660 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ EstCV(estimator=est).fit(X, y)
115115

116116
# Quantile regression with your favorite optimization algorithm
117117
# you can easily provide your own optimization algorithm to be the backend solver
118-
from ya_glm.backends.quantile_lp.glm_solver import solve_glm # Linear Programming formulation of quantile regression
118+
from ya_glm.backends.quantile_lp.glm_solver import solve_glm
119119

120120
Est, EstCV = get_pen_glm(loss_func='quantile',
121121
penalty='adpt_lasso',

docs/concave_penalties_compare_initializations.ipynb

Lines changed: 13 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
},
1717
{
1818
"cell_type": "code",
19-
"execution_count": 6,
19+
"execution_count": 3,
2020
"metadata": {},
2121
"outputs": [],
2222
"source": [
@@ -25,7 +25,7 @@
2525
"\n",
2626
"from ya_glm.toy_data import sample_sparse_lin_reg\n",
2727
"from ya_glm.backends.fista.LinearRegression import FcpLLA, FcpLLACV,\\\n",
28-
" LassoCV, RidgeCV, LassoENetCV"
28+
" LassoCV, RidgeCV, ENetCV"
2929
]
3030
},
3131
{
@@ -37,7 +37,7 @@
3737
},
3838
{
3939
"cell_type": "code",
40-
"execution_count": 2,
40+
"execution_count": 4,
4141
"metadata": {},
4242
"outputs": [],
4343
"source": [
@@ -49,7 +49,7 @@
4949
},
5050
{
5151
"cell_type": "code",
52-
"execution_count": 3,
52+
"execution_count": 5,
5353
"metadata": {},
5454
"outputs": [],
5555
"source": [
@@ -84,7 +84,7 @@
8484
},
8585
{
8686
"cell_type": "code",
87-
"execution_count": 4,
87+
"execution_count": 6,
8888
"metadata": {},
8989
"outputs": [],
9090
"source": [
@@ -96,48 +96,24 @@
9696
},
9797
{
9898
"cell_type": "code",
99-
"execution_count": 5,
99+
"execution_count": null,
100100
"metadata": {},
101101
"outputs": [
102102
{
103103
"name": "stdout",
104104
"output_type": "stream",
105105
"text": [
106-
"CPU times: user 152 ms, sys: 81.5 ms, total: 233 ms\n",
107-
"Wall time: 3.7 s\n",
106+
"CPU times: user 142 ms, sys: 75.6 ms, total: 218 ms\n",
107+
"Wall time: 3.16 s\n",
108108
"Lasso L2 to truth 0.5399115512254988 \n",
109109
"\n",
110-
"CPU times: user 246 ms, sys: 84 ms, total: 330 ms\n",
111-
"Wall time: 1.08 s\n",
110+
"CPU times: user 257 ms, sys: 117 ms, total: 374 ms\n",
111+
"Wall time: 836 ms\n",
112112
"Ridge L2 to truth 1.4667162260738444 \n",
113113
"\n",
114-
"CPU times: user 1.02 s, sys: 77.9 ms, total: 1.1 s\n",
115-
"Wall time: 18.1 s\n",
114+
"CPU times: user 823 ms, sys: 66.4 ms, total: 889 ms\n",
115+
"Wall time: 13.9 s\n",
116116
"ENet L2 to truth 0.5399115512254988 \n",
117-
"\n",
118-
"CPU times: user 1.92 s, sys: 221 ms, total: 2.14 s\n",
119-
"Wall time: 6.35 s\n",
120-
"FCP, lasso init, one step L2 to truth 0.2934270519442212 \n",
121-
"\n",
122-
"CPU times: user 2.01 s, sys: 205 ms, total: 2.21 s\n",
123-
"Wall time: 11.1 s\n",
124-
"FCP, ridge init, one step L2 to truth 0.3433528089934003 \n",
125-
"\n",
126-
"CPU times: user 2.65 s, sys: 196 ms, total: 2.85 s\n",
127-
"Wall time: 21.1 s\n",
128-
"FCP, enet init, one step L2 to truth 0.2934270519442212 \n",
129-
"\n",
130-
"CPU times: user 2.59 s, sys: 218 ms, total: 2.81 s\n",
131-
"Wall time: 18.4 s\n",
132-
"FCP, lasso init, many steps L2 to truth 0.2964122567536647 \n",
133-
"\n",
134-
"CPU times: user 2.56 s, sys: 265 ms, total: 2.83 s\n",
135-
"Wall time: 19.7 s\n",
136-
"FCP, ridge init, many steps L2 to truth 0.2964122567536647 \n",
137-
"\n",
138-
"CPU times: user 2.85 s, sys: 201 ms, total: 3.05 s\n",
139-
"Wall time: 28.5 s\n",
140-
"FCP, enet init, many steps L2 to truth 0.2964122567536647 \n",
141117
"\n"
142118
]
143119
}
@@ -157,7 +133,7 @@
157133
" np.linalg.norm(ridge.best_estimator_.coef_ - coef), '\\n')\n",
158134
"\n",
159135
"# ElasticNet\n",
160-
"%time enet = LassoENetCV(l1_ratio='tune', **cv_kws).fit(X, y)\n",
136+
"%time enet = ENetCV(l1_ratio='tune', **cv_kws).fit(X, y)\n",
161137
"print('ENet L2 to truth',\n",
162138
" np.linalg.norm(enet.best_estimator_.coef_ - coef), '\\n')\n",
163139
"\n",

docs/concave_penalty_two_stage_estimators.ipynb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
{
5454
"data": {
5555
"text/plain": [
56-
"<function ya_glm.fcp.GlmFcp.GlmFcpFitLLA.__init__(self, lla_n_steps=1, lla_kws={}, fit_intercept=True, standardize=False, opt_kws={}, pen_val=1, pen_func='scad', pen_func_kws={}, init='default')>"
56+
"<function ya_glm.pen_glms.GlmFcpLLA.GlmFcpLLA.__init__(self, pen_val=1, pen_func='scad', pen_func_kws={}, init='default', lla_n_steps=1, lla_kws={}, ridge_pen_val=None, ridge_weights=None, tikhonov=None, groups=None, fit_intercept=True, standardize=False, opt_kws={})>"
5757
]
5858
},
5959
"execution_count": 3,
@@ -160,6 +160,13 @@
160160
"est.fit(X, y)\n",
161161
"est.coef_"
162162
]
163+
},
164+
{
165+
"cell_type": "code",
166+
"execution_count": null,
167+
"metadata": {},
168+
"outputs": [],
169+
"source": []
163170
}
164171
],
165172
"metadata": {

0 commit comments

Comments
 (0)