Skip to content

fix and enhance utils.model_diagnostics#913

Merged
henrydingliu merged 10 commits into
casact:#839_model_summaryfrom
henrydingliu:util_summary
Jun 4, 2026
Merged

fix and enhance utils.model_diagnostics#913
henrydingliu merged 10 commits into
casact:#839_model_summaryfrom
henrydingliu:util_summary

Conversation

@henrydingliu
Copy link
Copy Markdown
Collaborator

@henrydingliu henrydingliu commented Jun 4, 2026

Summary of Changes

Related GitHub Issue(s)

Additional Context for Reviewers

  • I passed tests locally for both code (uv run pytest) and documentation changes (uv run jb build docs --builder=custom --custom-builder=doctest)

Note

Medium Risk
Changes a widely used diagnostics helper and moves shared CDF alignment logic; Benktander now errors without sample_weight, which may break callers that relied on optional weights.

Overview
This PR refactors CDF/LDF vertical alignment into Triangle.align_pattern (pattern triangles only) and wires MethodBase._align_cdf through it, with a guard test when called on non-pattern triangles.

model_diagnostics is tightened and extended: it now accepts a fitted Triangle, MethodBase, or Pipeline, rejects inputs missing ultimate_ / ibnr_ / ldf_, builds diagnostics from cum_to_incr on the model triangle (or the passed Triangle), and when groupby is unset adds LDF and CDF columns via align_pattern. groupby aggregation for IBNR (and related paths) is adjusted so summarized diagnostics stay consistent with grouped fits.

Benktander fit and predict now require sample_weight, matching other exposure-based estimators. Tests consolidate predict / weight validation across estimators and add model_diagnostics error and groupby parity coverage.

Reviewed by Cursor Bugbot for commit e9d0640. Bugbot is set up for automated code reviews on this repo. Configure here.

Comment thread chainladder/utils/utility_functions.py Outdated
Comment thread chainladder/utils/utility_functions.py Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.42%. Comparing base (25e1192) to head (e9d0640).

Additional details and impacted files
@@                  Coverage Diff                   @@
##           #839_model_summary     #913      +/-   ##
======================================================
+ Coverage               88.16%   88.42%   +0.26%     
======================================================
  Files                      87       87              
  Lines                    4952     4969      +17     
  Branches                  629      635       +6     
======================================================
+ Hits                     4366     4394      +28     
+ Misses                    443      436       -7     
+ Partials                  143      139       -4     
Flag Coverage Δ
unittests 88.42% <100.00%> (+0.26%) ⬆️

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.

Comment thread chainladder/core/triangle.py Outdated
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 90c4c0a. Configure here.

Comment thread chainladder/utils/utility_functions.py Outdated
@henrydingliu henrydingliu merged commit bcb9d6b into casact:#839_model_summary Jun 4, 2026
10 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.

1 participant