Skip to content

Commit

Permalink
New argument: max_inner_iter (#865)
Browse files Browse the repository at this point in the history
  • Loading branch information
mlondschien authored Nov 8, 2024
1 parent 245d8b3 commit df6f372
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
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:**

- 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

0 comments on commit df6f372

Please sign in to comment.