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 7 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
6 changes: 5 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@
Changelog
=========

3.0.3 - unreleased
3.1.0 - unreleased
------------------

**New feature:**

- 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.

**Bug fix:

- Fixed a bug where :meth:`glum.GeneralizedLinearRegressor.fit` would raise a ``dtype`` mismatch error if fit with ``alpha_search=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 @@ -2682,6 +2685,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 @@ -2923,6 +2930,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 @@ -2964,6 +2972,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 @@ -332,6 +336,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 @@ -375,6 +380,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