Skip to content

Commit 0f21cdf

Browse files
author
hoodaty
committed
Include ElasticNet like regularization for SparseLogisticRegression
1 parent 4563f22 commit 0f21cdf

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

skglm/estimators.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,10 +1003,11 @@ class SparseLogisticRegression(LinearClassifierMixin, SparseCoefMixin, BaseEstim
10031003
Number of subproblems solved to reach the specified tolerance.
10041004
"""
10051005

1006-
def __init__(self, alpha=1.0, tol=1e-4, max_iter=20, max_epochs=1_000, verbose=0,
1006+
def __init__(self, alpha=1.0, l1ratio=0.5, tol=1e-4, max_iter=20, max_epochs=1_000, verbose=0,
10071007
fit_intercept=True, warm_start=False):
10081008
super().__init__()
10091009
self.alpha = alpha
1010+
self.l1ratio = l1ratio
10101011
self.tol = tol
10111012
self.max_iter = max_iter
10121013
self.max_epochs = max_epochs
@@ -1035,7 +1036,7 @@ def fit(self, X, y):
10351036
max_iter=self.max_iter, max_pn_iter=self.max_epochs, tol=self.tol,
10361037
fit_intercept=self.fit_intercept, warm_start=self.warm_start,
10371038
verbose=self.verbose)
1038-
return _glm_fit(X, y, self, Logistic(), L1(self.alpha), solver)
1039+
return _glm_fit(X, y, self, Logistic(), L1_plus_L2(self.alpha,self.l1ratio), solver)
10391040

10401041
def predict_proba(self, X):
10411042
"""Probability estimates.

0 commit comments

Comments
 (0)