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

Add "solver" and "max_iter" parameters to class LogisticRegression #435

Merged
merged 7 commits into from
Mar 25, 2022
Merged
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
16 changes: 15 additions & 1 deletion skfda/ml/classification/_logistic_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ class LogisticRegression(
p:
number of points (and coefficients) to be selected by
the algorithm.
solver:
Algorithm to use in the multivariate logistic regresion

Choose a reason for hiding this comment

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

[pep8] reported by reviewdog 🐶
W291 trailing whitespace

optimization problem. For more info check the parameter
"solver" in sklearn.linear_model.LogisticRegression.
max_iter:
Maximum number of iterations taken for the solver to converge.

Attributes:
classes\_: A list containing the name of the classes
Expand Down Expand Up @@ -73,9 +79,13 @@ class LogisticRegression(
def __init__(
self,
p: int = 5,
solver: str = 'lbfgs',
Copy link
Member

Choose a reason for hiding this comment

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

This should have a Literal type with the acceptable values.

max_iter: int = 100,
) -> None:

self.p = p
self.max_iter = 100
self.solver = solver

def fit( # noqa: D102
self,
Expand All @@ -93,7 +103,11 @@ def fit( # noqa: D102
selected_indexes = np.zeros(self.p, dtype=np.intc)

# multivariate logistic regression
mvlr = mvLogisticRegression(penalty='l2')
mvlr = mvLogisticRegression(
penalty='l2',
solver=self.solver,
max_iter=self.max_iter,
)

x_mv = np.zeros((n_samples, self.p))
LL = np.zeros(n_features)
Expand Down