Skip to content

Commit

Permalink
Print more informative logs when alpha-search is True. (#866)
Browse files Browse the repository at this point in the history
  • Loading branch information
mlondschien authored Oct 27, 2024
1 parent 3090ea2 commit 190b266
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
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 features:**

- :class:`~glum.GeneralizedLinearRegressor` now prints more informative logs when fitting with ``alpha_search=True`` and ``verbose=True``.

**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: 8 additions & 1 deletion src/glum/_glm.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
"""

# License: BSD 3 clause

import copy
import re
import sys
import warnings
from collections.abc import Iterable, Mapping, Sequence
from time import perf_counter
from typing import Any, NamedTuple, Optional, Union, cast

import numpy as np
Expand Down Expand Up @@ -1184,6 +1184,7 @@ def _solve_regularization_path(
P1 = P1_no_alpha * alpha
P2 = P2_no_alpha * alpha

tic = perf_counter()
coef = self._solve(
X=X,
y=y,
Expand All @@ -1197,6 +1198,12 @@ def _solve_regularization_path(
A_ineq=A_ineq,
b_ineq=b_ineq,
)
toc = perf_counter()

if self.verbose > 0:
print(
f"alpha={alpha:.3e}, time={toc - tic:.2f}s, n_iter={self.n_iter_}"
)

self.coef_path_[k, :] = coef

Expand Down

0 comments on commit 190b266

Please sign in to comment.