Skip to content

[BUG] TweedieGLM never passes alpha to TweedieRegressor #1584

Open

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Scope

    None yet

    Effort

    None yet

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions