Skip to content

[BUG] TweedieGLM ignores drop and drop_valuation unless sample_weight is passed #1619

Closed

Description

@scks1

Describe the bug in words

TweedieGLM accepts drop and drop_valuation, but on main they change nothing unless sample_weight is also passed. The fit uses no weights when sample_weight is None (glm.py L217–L220), and DevelopmentML sets sample_weights = {} when weighted_step is None (learning.py L341–L342), so the weights that TriangleWeight builds from the exclusions are never applied. No warning is raised.

How to reproduce

import chainladder as cl
genins = cl.load_sample("genins")
base = cl.TweedieGLM().fit(genins).ldf_.values[0, 0, 0, :4].round(4)
dv = cl.TweedieGLM(drop_valuation="2005").fit(genins).ldf_.values[0, 0, 0, :4].round(4)
dr = cl.TweedieGLM(drop=("2001", 12)).fit(genins).ldf_.values[0, 0, 0, :4].round(4)
print(base, dv, dr)

Observed: all three are [3.491, 1.7474, 1.4574, 1.1739].

With sample_weight set to a triangle of ones (genins * 0 + 1), the same exclusions do take effect: drop_valuation="2005" gives [3.5057, 1.7861, 1.4546, 1.1711].

These outputs are from ee2c24d; the commits since, up to 1457b76, don't touch chainladder/development or chainladder/core.

Expected

Either the exclusions apply without sample_weight (as they do in Development and BarnettZehnwirth), or fit raises or warns that they are ignored.

Notes

  • A search of open and closed issues and PRs for "TweedieGLM drop", "TweedieGLM drop_valuation", "TweedieGLM sample_weight" and "weighted_step" found no report. [BUG] TweedieGLM never passes alpha to TweedieRegressor #1584 is a separate TweedieGLM bug (alpha is never passed to TweedieRegressor).
  • BarnettZehnwirth applies TriangleWeight to the cell triangle, so it drops the named valuation's cells, while Development drops link ratios keyed by their starting valuation (cl.Development(), drop_valuation not behaving as expected #168). This issue doesn't propose changing either keying.
  • Not checked: DevelopmentML used directly with a pipeline and no weighted_step.

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

Activity

  1. henrydingliu commented on Nov 14, 2026

    @henrydingliu
    Member

    oops, i think i'm personally responsible for this.

  2. Huyvux12 commented on Nov 16, 2026

    @Huyvux12
    Contributor

    Reproduced on main at c113fd9: drop and drop_valuation change nothing in TweedieGLM.fit unless sample_weight is also passed (all three LDFs come out identical). The weights built from the exclusions in DevelopmentML._prep_w_ml are only passed to the estimator when weighted_step is set, which TweedieGLM only does when sample_weight is given.

    I plan to fix it in chainladder/development/glm.py so the exclusion weights are applied even when sample_weight is None (matching BarnettZehnwirth, which always passes weighted_step="model"), and add a regression test in chainladder/development/tests/test_glm.py.

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

    None yet

    Scope

    None yet

    Effort

    None yet

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions