Skip to content

Commit ee85da8

Browse files
committed
ENH sparsify and densify methods for CD models
1 parent 3c543bf commit ee85da8

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

sklearn/linear_model/coordinate_descent.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import numpy as np
1313
from scipy import sparse
1414

15-
from .base import LinearModel, _pre_fit
15+
from .base import LinearModel, _pre_fit, SparseCoefMixin
1616
from ..base import RegressorMixin
1717
from .base import center_data, sparse_center_data
1818
from ..utils import array2d, atleast2d_or_csc
@@ -515,7 +515,7 @@ def enet_path(X, y, l1_ratio=0.5, eps=1e-3, n_alphas=100, alphas=None,
515515
# ElasticNet model
516516

517517

518-
class ElasticNet(LinearModel, RegressorMixin):
518+
class ElasticNet(LinearModel, RegressorMixin, SparseCoefMixin):
519519
"""Linear Model trained with L1 and L2 prior as regularizer
520520
521521
Minimizes the objective function::
@@ -699,7 +699,10 @@ def fit(self, X, y):
699699

700700
@property
701701
def sparse_coef_(self):
702-
""" sparse representation of the fitted coef """
702+
"""Sparse representation of the fitted coef_."""
703+
warnings.warn("sparse_coef_ is deprecated and will be removed in 0.17."
704+
" Call the sparsify method instead.",
705+
DeprecationWarning)
703706
return sparse.csr_matrix(self.coef_)
704707

705708
def decision_function(self, X):

0 commit comments

Comments
 (0)