@@ -502,6 +502,21 @@ def enet_path(X, y, l1_ratio=0.5, eps=1e-3, n_alphas=100, alphas=None,
502
502
return alphas , coefs , dual_gaps
503
503
504
504
505
+ class _LassoStaticMixin :
506
+ """Mixin to add lasso_path as a staticmethod named path"""
507
+
508
+ @staticmethod
509
+ def path (X , y , eps = 1e-3 , n_alphas = 100 , alphas = None ,
510
+ precompute = 'auto' , Xy = None , copy_X = True , coef_init = None ,
511
+ verbose = False , return_n_iter = False , positive = False , ** params ):
512
+ return lasso_path (X , y , eps , n_alphas , alphas ,
513
+ precompute , Xy , copy_X , coef_init ,
514
+ verbose , return_n_iter , positive , ** params )
515
+
516
+
517
+ _LassoStaticMixin .path .__doc__ = lasso_path .__doc__
518
+
519
+
505
520
###############################################################################
506
521
# ElasticNet model
507
522
@@ -1242,7 +1257,7 @@ def fit(self, X, y):
1242
1257
return self
1243
1258
1244
1259
1245
- class LassoCV (LinearModelCV , RegressorMixin ):
1260
+ class LassoCV (LinearModelCV , RegressorMixin , _LassoStaticMixin ):
1246
1261
"""Lasso linear model with iterative fitting along a regularization path.
1247
1262
1248
1263
See glossary entry for :term:`cross-validation estimator`.
@@ -1406,17 +1421,6 @@ def __init__(self, eps=1e-3, n_alphas=100, alphas=None, fit_intercept=True,
1406
1421
cv = cv , verbose = verbose , n_jobs = n_jobs , positive = positive ,
1407
1422
random_state = random_state , selection = selection )
1408
1423
1409
- @staticmethod
1410
- def path (X , y , eps = 1e-3 , n_alphas = 100 , alphas = None ,
1411
- precompute = 'auto' , Xy = None , copy_X = True , coef_init = None ,
1412
- verbose = False , return_n_iter = False , positive = False , ** params ):
1413
- return lasso_path (
1414
- X , y , eps , n_alphas , alphas , precompute , Xy , copy_X , coef_init ,
1415
- verbose , return_n_iter , positive , ** params )
1416
-
1417
-
1418
- LassoCV .path .__doc__ = lasso_path .__doc__
1419
-
1420
1424
1421
1425
class ElasticNetCV (LinearModelCV , RegressorMixin ):
1422
1426
"""Elastic Net model with iterative fitting along a regularization path.
@@ -2140,7 +2144,7 @@ def __init__(self, l1_ratio=0.5, eps=1e-3, n_alphas=100, alphas=None,
2140
2144
self .selection = selection
2141
2145
2142
2146
2143
- class MultiTaskLassoCV (LinearModelCV , RegressorMixin ):
2147
+ class MultiTaskLassoCV (LinearModelCV , RegressorMixin , _LassoStaticMixin ):
2144
2148
"""Multi-task Lasso model trained with L1/L2 mixed-norm as regularizer.
2145
2149
2146
2150
See glossary entry for :term:`cross-validation estimator`.
@@ -2295,14 +2299,3 @@ def __init__(self, eps=1e-3, n_alphas=100, alphas=None, fit_intercept=True,
2295
2299
max_iter = max_iter , tol = tol , copy_X = copy_X ,
2296
2300
cv = cv , verbose = verbose , n_jobs = n_jobs , random_state = random_state ,
2297
2301
selection = selection )
2298
-
2299
- @staticmethod
2300
- def path (X , y , eps = 1e-3 , n_alphas = 100 , alphas = None ,
2301
- precompute = 'auto' , Xy = None , copy_X = True , coef_init = None ,
2302
- verbose = False , return_n_iter = False , positive = False , ** params ):
2303
- return lasso_path (
2304
- X , y , eps , n_alphas , alphas , precompute , Xy , copy_X , coef_init ,
2305
- verbose , return_n_iter , positive , ** params )
2306
-
2307
-
2308
- MultiTaskLassoCV .path .__doc__ = lasso_path .__doc__
0 commit comments