Skip to content

[FIX] Build DevelopmentML projected valuations from an integer index - #1634

Open
scks1 wants to merge 1 commit into
casact:mainfrom
scks1:fix-devml-monthly-valuation
Open

scks1 wants to merge 1 commit into
casact:mainfrom
scks1:fix-devml-monthly-valuation

Conversation

@scks1

@scks1 scks1 commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Summary of Changes

DevelopmentML._get_triangle_ml now builds projected valuations from the integer valuation index instead of adding dgrain / 12 at each step. The repeated float addition drifted away from valuation_encoder_'s values on monthly triangles, so the exact lookup returned NaN and .dropna() removed most of the projected cells. BarnettZehnwirth uses the same function and is fixed too.

test_monthly_poisson_glm_matches_chainladder fits a Poisson GLM with origin and development factors to an 8×8 monthly triangle with an exact multiplicative pattern, and checks that triangle_ml_ has no NaN and that the ultimates match Chainladder (Renshaw and Verrall, 1998). It fails on main at the NaN check and passes with the change.

Related GitHub Issue(s)

Closes #1633

AI/LLM Usage

This change was made with Árbol, an AI assistant running on Muse, working under my direction. It found the bug, wrote the change and the test, ran the checks below and drafted this description.

Additional Context for Reviewers

  1. Largest relative difference from the true ultimates on exact-pattern triangles, before and after:
Triangle DevelopmentML BarnettZehnwirth
Monthly 24×24 0.599 → 1.7e-5 0.599 → 2.9e-15
Monthly 12×12 0.356 → 1.2e-6 0.356 → 1.3e-15
Monthly 8×8 0.587 → 1.3e-6 0.587 → 6.5e-16
Quarterly 12×12 1.2e-6, unchanged 1.3e-15, unchanged
Semiannual 8×8 1.3e-6, unchanged 6.5e-16, unchanged
Annual 10×10 1.9e-6, unchanged 7.2e-16, unchanged

The DevelopmentML values left after the fix are the Tweedie solver's tolerance. genins's ldf_ is unchanged.

  1. No open PR touches learning.py or barnzehn.py.

The chainladder/development tests pass (167 passed), and ruff check and format are clean on the changed files.

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

_get_triangle_ml stepped projected valuations by adding dgrain / 12 in
floating point and then looked them up in valuation_encoder_ by exact
match. For monthly grain the sums drift from the encoder's values, so
most projected cells became NaN and were dropped, and DevelopmentML and
BarnettZehnwirth ultimates no longer matched chain ladder on exact data.

Projected valuations now come from the integer valuation index, divided
once in the same way as the encoder. The new test fits a Poisson GLM to a
monthly triangle with an exact multiplicative pattern and checks the
square is complete and the ultimates match Chainladder.

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

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 (303 / 1675)

Known Ambiguous Unknown Total
Project (head) 303 96 1276 1675

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: 331
  • Functions without default param: 0
  • Classes without docstring: 10

Patch (exported symbols added or changed by this PR): 0.0% fully typed (0 / 1)

Known Ambiguous Unknown Total
Patch 0 0 1 1
Patch symbol details
Symbol Status Change
chainladder.development.tests.test_learning.test_monthly_poisson_glm_matches_chainladder ❌ unknown new

@codecov

codecov Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.00%. Comparing base (c113fd9) to head (e30648c).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1634   +/-   ##
=======================================
  Coverage   95.00%   95.00%           
=======================================
  Files         100      100           
  Lines        6461     6465    +4     
  Branches      820      820           
=======================================
+ Hits         6138     6142    +4     
  Misses        204      204           
  Partials      119      119           
Flag Coverage Δ
unittests 95.00% <100.00%> (+<0.01%) ⬆️

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
  • i recall that one of the developmentML subclasses recreates wtd-all vanilla chainladder. if i'm not hallucinating, you can swap the synthetic data for the monthly fixture
  • since we are already here, let's make sure all the non-square (e.g. OYDM) grains also work
  • speaking of grains, is the current test_grain test in test_learning broken? why didn't it catch this bug?

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.

[BUG] DevelopmentML and BarnettZehnwirth drop projected cells on monthly triangles

2 participants