Skip to content

[DOCS] Show origin-varying ldf_ from DevelopmentML in the user guide - #1621

Merged
henrydingliu merged 3 commits into
casact:mainfrom
scks1:docs-devml-origin
Nov 19, 2026
Merged

henrydingliu merged 3 commits into
casact:mainfrom
scks1:docs-devml-origin

Conversation

@scks1

@scks1 scks1 commented Nov 14, 2026

Copy link
Copy Markdown
Contributor

Summary of Changes

Adds a short "Origin-varying patterns" subsection to the DevelopmentML part of docs/user_guide/development.ipynb, after the PatsyFormula section. It shows that:

  • DevelopmentML.ldf_ has one row per origin (shape (1, 1, 10, 9) on genins), where Development.ldf_ has one row.
  • The ODP cross-classified GLM (C(development) + C(origin), log link, incrementals, alpha=0) gives the same row for every origin, matching Development().ldf_ (3.491, 1.747, 1.457 for the first three ages) (Taylor and McGuire 2016, CAS Monograph 3, already cited in the user guide).
  • Adding origin:I(development / 12) gives each origin its own factors (12-24 runs from 3.432 for 2001 to 3.560 for 2010), and Chainladder applies each origin's own row: ultimates rise by 0.1% for 2002 up to 13.5% for 2010 against the plain chainladder.

No code changes. The example avoids drop/drop_valuation (see #1619) and uses DevelopmentML directly so it can set alpha=0.

Related GitHub Issue(s)

None.

AI/LLM Usage

This example was made with Árbol, an AI assistant running on Muse, working under my direction. It wrote the cells, ran them and the notebook test on main 1457b76, and checked each origin's ultimate against its latest diagonal times the product of its own factors (largest relative gap 3.5e-16). I reviewed the text and the numbers before submitting.

Additional Context for Reviewers

The origin:I(development / 12) term is only an illustration of time-heterogeneity, and the note in the cell says so. It is not a model taken from Taylor and McGuire.

Submitter's Checklist

  • I have reviewed and am adhering to the standards outlined in the project Governing Doc.
  • The PR subject title summarizes the changes, with one proper prefix ([FIX], [FEAT], [DOCS], [TST], [CHORE], or [BRK]).
  • I am a human (not a bot), and this PR form is written by a human.

Reviewer's Checklist

  • The implementation addresses the associated issue(s).
  • The implementation is appropriate, maintainable, and follows ARCHITECTURE.md.
  • PR subject title has the proper prefix and the subject is appropriate.
  • Relevant issue(s) are linked.
  • AI/LLM usage is disclosed and appropriate.
  • Documentation and tests are appropriate.
  • CI tests passed, or any failures are acceptable.
  • Leave a comment with the final recommendation (e.g. approve as is, request a secondary review, or flag an area for more review).

Add an "Origin-varying patterns" subsection after PatsyFormula. The ODP
cross-classified GLM gives one identical row of ldf_ per origin, equal
to Development's pattern; an origin:I(development / 12) term gives each
origin its own factors, and Chainladder applies each origin's own row.

Developed with an AI assistant (Árbol, running Muse).
@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Pyright Type Completeness

View the full pyright --verifytypes output for this commit

Project (full chainladder package, at this PR's head): 18.1% of exported symbols fully typed (305 / 1682)

Known Ambiguous Unknown Total
Project (head) 305 96 1281 1682

Other symbols referenced but not exported by chainladder: 24

Known Ambiguous Unknown Total
Other (head) 11 1 12 24

Symbols without documentation:

  • Functions without docstring: 329
  • Functions without default param: 0
  • Classes without docstring: 10

Patch (exported symbols added or changed by this PR): no exported symbol type-completeness changes detected.

@codecov

codecov Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.03%. Comparing base (cc3335c) to head (cbc3040).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1621   +/-   ##
=======================================
  Coverage   95.03%   95.03%           
=======================================
  Files         100      100           
  Lines        6471     6471           
  Branches      819      819           
=======================================
  Hits         6150     6150           
  Misses        203      203           
  Partials      118      118           
Flag Coverage Δ
unittests 95.03% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@henrydingliu

Copy link
Copy Markdown
Member

any reason you are calling DevelopmentML(..., TweedieRegressor()) directly instead of the existing TweedieGLM from development/glm.py?

@henrydingliu

Copy link
Copy Markdown
Member

assuming this is another alpha issue, can we please prioritize #1584?

@scks1

scks1 commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

Yes, it is the alpha bug. TweedieGLM ignores alpha on main, so the example calls DevelopmentML directly to set alpha=0. With the #1584 fix, TweedieGLM(design_matrix=..., alpha=0, max_iter=1000) reproduces both genins fits in this example exactly, so I can switch the example to TweedieGLM once #1663 merges.

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

@henrydingliu

Copy link
Copy Markdown
Member

thanks for the quick turnaround on #1663!

With the casact#1584 fix merged in casact#1663, TweedieGLM passes alpha to its
regressor, so the example no longer needs a hand-built DevelopmentML
pipeline. Both genins fits and the ultimate ratios are unchanged.

Developed with an AI assistant (Árbol, running Muse).
@scks1

scks1 commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

Now that #1663 is in, the origin-varying example uses cl.TweedieGLM(design_matrix=..., alpha=0, max_iter=1000) in place of the hand-built DevelopmentML pipeline. I merged main at cc3335c into the branch and reran the cells. The outputs match the current ones exactly.

  • C(development) + C(origin) gives 3.491, 1.747 and 1.457 for every origin.
  • With origin:I(development / 12), 12-24 runs from 3.432 for 2001 to 3.560 for 2010.
  • Against the plain chainladder, ultimates rise from 0.1% for 2002 to 13.5% for 2010. 2001 rounds to 1.000.
Code
import chainladder as cl

genins = cl.load_sample("genins")

cross = cl.TweedieGLM(
    design_matrix="C(development) + C(origin)", alpha=0, max_iter=1000
).fit(genins)
drift = cl.TweedieGLM(
    design_matrix="C(development) + C(origin) + origin:I(development / 12)",
    alpha=0,
    max_iter=1000,
).fit(genins)

print(cross.ldf_.iloc[..., :3].round(3))
print(drift.ldf_.iloc[..., :3].round(3))

plain = cl.Chainladder().fit(cl.Development().fit_transform(genins))
drifted = cl.Chainladder().fit(drift.transform(genins))
print((drifted.ultimate_ / plain.ultimate_).round(3))
      12-24  24-36  36-48
2001  3.491  1.747  1.457
2002  3.491  1.747  1.457
2003  3.491  1.747  1.457
2004  3.491  1.747  1.457
2005  3.491  1.747  1.457
2006  3.491  1.747  1.457
2007  3.491  1.747  1.457
2008  3.491  1.747  1.457
2009  3.491  1.747  1.457
2010  3.491  1.747  1.457
      12-24  24-36  36-48
2001  3.432  1.727  1.443
2002  3.446  1.733  1.448
2003  3.460  1.738  1.452
2004  3.474  1.743  1.457
2005  3.488  1.749  1.461
2006  3.502  1.754  1.466
2007  3.516  1.760  1.471
2008  3.531  1.766  1.475
2009  3.545  1.771  1.480
2010  3.560  1.777  1.485
       2261
2001  1.000
2002  1.001
2003  1.004
2004  1.009
2005  1.018
2006  1.029
2007  1.043
2008  1.066
2009  1.095
2010  1.135

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

@henrydingliu
henrydingliu merged commit 687e329 into casact:main Nov 19, 2026
11 checks passed
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.

2 participants