Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include ElasticNet like regularization for SparseLogisticRegression #244

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions skglm/estimators.py
Original file line number Diff line number Diff line change
Expand Up @@ -1003,10 +1003,11 @@ class SparseLogisticRegression(LinearClassifierMixin, SparseCoefMixin, BaseEstim
Number of subproblems solved to reach the specified tolerance.
"""

def __init__(self, alpha=1.0, tol=1e-4, max_iter=20, max_epochs=1_000, verbose=0,
def __init__(self, alpha=1.0, l1ratio=0.5, tol=1e-4, max_iter=20, max_epochs=1_000, verbose=0,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to add a description of this parameter in the docstring above; also, call it l1_ratio for compatibility with sklearn.

fit_intercept=True, warm_start=False):
super().__init__()
self.alpha = alpha
self.l1ratio = l1ratio
self.tol = tol
self.max_iter = max_iter
self.max_epochs = max_epochs
Expand Down Expand Up @@ -1035,7 +1036,7 @@ def fit(self, X, y):
max_iter=self.max_iter, max_pn_iter=self.max_epochs, tol=self.tol,
fit_intercept=self.fit_intercept, warm_start=self.warm_start,
verbose=self.verbose)
return _glm_fit(X, y, self, Logistic(), L1(self.alpha), solver)
return _glm_fit(X, y, self, Logistic(), L1_plus_L2(self.alpha,self.l1ratio), solver)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not PEP8 compliant, by convention you need to add a space after the comma. You can configure your editor to do it automatically : https://github.com/mathurinm/github-assignment/?tab=readme-ov-file#vscode-configuration


def predict_proba(self, X):
"""Probability estimates.
Expand Down
Loading