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

New argument: max_inner_iter #865

Merged
merged 8 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Changelog

**New features:**
mlondschien marked this conversation as resolved.
Show resolved Hide resolved

- New argument ``max_inner_iter`` for classes :class:`~glum.GeneralizedLinearRegressor` and :class:`~glum.GeneralizedLinearRegressorCV` to control the maximum number of iterations of the inner solver in the IRLS-CD algorithm.
- New fitted attributes ``col_means_`` and ``col_stds_`` for classes :class:`~glum.GeneralizedLinearRegressor` and :class:`~glum.GeneralizedLinearRegressorCV`.
- :class:`~glum.GeneralizedLinearRegressor` now prints more informative logs when fitting with ``alpha_search=True`` and ``verbose=True``.

Expand Down
9 changes: 9 additions & 0 deletions src/glum/_glm.py
Original file line number Diff line number Diff line change
Expand Up @@ -730,6 +730,7 @@ def __init__(
link: Union[str, Link] = "auto",
solver: str = "auto",
max_iter=100,
max_inner_iter=100000,
gradient_tol: Optional[float] = None,
step_size_tol: Optional[float] = None,
hessian_approx: float = 0.0,
Expand Down Expand Up @@ -767,6 +768,7 @@ def __init__(
self.link = link
self.solver = solver
self.max_iter = max_iter
self.max_inner_iter = max_inner_iter
self.gradient_tol = gradient_tol
self.step_size_tol = step_size_tol
self.hessian_approx = hessian_approx
Expand Down Expand Up @@ -1102,6 +1104,7 @@ def _solve(
family=self._family_instance,
link=self._link_instance,
max_iter=max_iter,
max_inner_iter=self.max_inner_iter,
gradient_tol=self._gradient_tol,
step_size_tol=self.step_size_tol,
fixed_inner_tol=fixed_inner_tol,
Expand Down Expand Up @@ -2695,6 +2698,10 @@ class GeneralizedLinearRegressor(GeneralizedLinearRegressorBase):
max_iter : int, optional (default=100)
The maximal number of iterations for solver algorithms.

max_inner_iter: int, optional (default=100000)
The maximal number of iterations for the inner solver in the IRLS-CD
algorithm. This parameter is only used when ``solver='irls-cd'``.

gradient_tol : float, optional (default=None)
Stopping criterion. If ``None``, solver-specific defaults will be used.
The default value for most solvers is ``1e-4``, except for
Expand Down Expand Up @@ -2942,6 +2949,7 @@ def __init__(
link: Union[str, Link] = "auto",
solver: str = "auto",
max_iter=100,
max_inner_iter=100000,
gradient_tol: Optional[float] = None,
step_size_tol: Optional[float] = None,
hessian_approx: float = 0.0,
Expand Down Expand Up @@ -2983,6 +2991,7 @@ def __init__(
link=link,
solver=solver,
max_iter=max_iter,
max_inner_iter=max_inner_iter,
gradient_tol=gradient_tol,
step_size_tol=step_size_tol,
hessian_approx=hessian_approx,
Expand Down
6 changes: 6 additions & 0 deletions src/glum/_glm_cv.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ class GeneralizedLinearRegressorCV(GeneralizedLinearRegressorBase):
max_iter : int, optional (default=100)
The maximal number of iterations for solver algorithms.

max_inner_iter: int, optional (default=100000)
The maximal number of iterations for the inner solver in the IRLS-CD
algorithm. This parameter is only used when ``solver='irls-cd'``.

gradient_tol : float, optional (default=None)
Stopping criterion. If ``None``, solver-specific defaults will be used.
The default value for most solvers is ``1e-4``, except for
Expand Down Expand Up @@ -338,6 +342,7 @@ def __init__(
link: Union[str, Link] = "auto",
solver: str = "auto",
max_iter=100,
max_inner_iter=100000,
gradient_tol: Optional[float] = None,
step_size_tol: Optional[float] = None,
hessian_approx: float = 0.0,
Expand Down Expand Up @@ -381,6 +386,7 @@ def __init__(
link=link,
solver=solver,
max_iter=max_iter,
max_inner_iter=max_inner_iter,
gradient_tol=gradient_tol,
step_size_tol=step_size_tol,
hessian_approx=hessian_approx,
Expand Down
Loading