Skip to content

[BUG] TweedieGLM never passes alpha to TweedieRegressor #1584

Closed

Description

@scks1

Are you on the latest chainladder version?

  • Yes, this bug occurs on the latest version (main at 0e5a7a9: chainladder 0.10.1, Python 3.12.15, numpy 2.3.3, pandas 2.3.3, scikit-learn 1.7.2).

Describe the bug in words

TweedieGLM stores alpha (glm.py L208) but builds its TweedieRegressor without it (L227–L235), so every fit uses scikit-learn's default penalty of 1.0. alpha=0 therefore doesn't give the unpenalized GLM the docstring describes (L64–L68): on ukmotor its IBNR comes out 4.2% above chain ladder. No commit in the history has passed alpha.

How can the bug be reproduced?

import chainladder as cl

ukmotor = cl.load_sample("ukmotor")
glm = cl.TweedieGLM(alpha=0).fit(ukmotor)
print(glm.model_.estimator_ml.named_steps["model"].alpha)
print(cl.Chainladder().fit(glm.transform(ukmotor)).ibnr_.sum().round(1))
print(cl.Chainladder().fit(ukmotor).ibnr_.sum().round(1))
1.0
29866.2
28655.8

What is the expected behavior?

import chainladder as cl

ukmotor = cl.load_sample("ukmotor")
glm = cl.TweedieGLM(alpha=0).fit(ukmotor)
assert glm.model_.estimator_ml.named_steps["model"].alpha == 0
ibnr = cl.Chainladder().fit(glm.transform(ukmotor)).ibnr_.sum()
assert round(ibnr, 1) == round(cl.Chainladder().fit(ukmotor).ibnr_.sum(), 1)

With alpha=self.alpha passed, both asserts pass and the repro prints 0, 28655.8 and 28655.8. I have that one-line change locally with a regression test in test_glm.py. The default stays 1.0, so fits that don't set alpha are unchanged.

Would you be willing to contribute this ticket?

  • Yes, absolutely!
  • Yes, but I would like some help.
  • No.

(This issue was written with Árbol, an AI assistant, under my direction.)

Activity

  1. updated Priority Medium, Scope Codebase and Effort Low on Nov 13, 2026
  2. added this to the v0.11.0 milestone on Nov 13, 2026
  3. henrydingliu commented on Nov 18, 2026

    @henrydingliu
    Member

    is this a lie? or does alpha=0 fix it?

  4. scks1 commented on Nov 18, 2026

    @scks1
    ContributorAuthor

    It is close but not exact, and alpha=0 cannot fix it on main because TweedieGLM never passes alpha to the regressor. The gallery fit runs with a penalty of 1.0 whatever alpha says.

    On genins the penalty barely shows. The GLM 12-24 factor is 3.4910 against 3.4906 from Development, the largest gap across ages is 0.00042, and total ultimate is 53,041,750 against 53,038,946. On smaller amounts it matters more. On ukmotor the 12-24 factor is 1.9040 against 1.8892, and total ultimate is 105,538 against 104,328.

    With the fix in #1663, TweedieGLM(alpha=0) on genins gives a largest factor gap of 0.0000008 and total ultimate 53,038,955. On ukmotor it gives 1.8892 and 104,328. The default stays alpha=1.0, so #1663 also sets alpha=0 in the gallery example, and "shown to match" now holds to within 0.0000008.

    (This comment was written with Árbol, an AI assistant, under my direction.)

  5. added 2 commits that reference this issue on Nov 18, 2026
    7098fb0
    cbc3040
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    Medium

    Scope

    Codebase

    Effort

    Low

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions