Registry Mirror
Skip to content

Conversation

@mtantaoui

Copy link
Copy Markdown
Contributor

On master, TweedieRegressor::params().fit(..) (Poisson, log link: the defaults)
never returns on 10 000 samples, and on smaller data it stops early with wrong
coefficients. Two bugs:

  • Poisson deviance: unit_deviance computed 2 y ln(y/μ) - y + μ instead of
    2 (y ln(y/μ) - y + μ), so the cost disagreed with its gradient and L-BFGS stopped
    with a non-zero gradient (on exact data, intercept 0.31 instead of 0.2).
  • Hang: the objective summed the deviance over the samples, so the gradient grew
    with n. L-BFGS's first step (along the gradient, no curvature yet) overflowed exp,
    the cost became NaN, and the More–Thuente line search, which has no iteration
    limit, kept extrapolating. The objective and gradient are now divided by n: same
    minimum, same meaning of alpha, but the gradient tolerance now applies per sample.

Tests

  • test_gradient_matches_cost: the gradient matches finite differences of the cost
    for powers 0, 1, 1.5, 2, 3 (only Poisson failed before).
  • test_glm_poisson_many_samples: 2000 samples, recovers the exact coefficients;
    hangs on master.

Against scikit-learn

n = 10 000, 8 features, noisy data, alpha = 1 in linfa and 1/n in scikit-learn 1.9.1:

distribution max coefficient difference
normal (identity link) 7.7e-8
Poisson 3.1e-8
Tweedie 1.5 3.0e-7
gamma 1.5e-7

@codecov

codecov Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.98%. Comparing base (935c437) to head (e9af22d).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #478      +/-   ##
==========================================
+ Coverage   76.95%   76.98%   +0.02%     
==========================================
  Files         105      105              
  Lines        7612     7612              
==========================================
+ Hits         5858     5860       +2     
+ Misses       1754     1752       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mtantaoui mtantaoui mentioned this pull request Nov 23, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant