Skip to content

initial implementation of TriangleSelector#1113

Merged
henrydingliu merged 1 commit into
casact:TriangleSelectorfrom
henrydingliu:tri_sel
Jul 13, 2026
Merged

initial implementation of TriangleSelector#1113
henrydingliu merged 1 commit into
casact:TriangleSelectorfrom
henrydingliu:tri_sel

Conversation

@henrydingliu

@henrydingliu henrydingliu commented Jul 13, 2026

Copy link
Copy Markdown
Member

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 how voting ultimates are weighted and aggregated; incorrect weight slicing could affect ensemble results when pipelines return different column counts, though existing same-shape paths should behave similarly.

Overview
Adds TriangleSelector, a sklearn-style pipeline step that keeps a single triangle column (e.g. paid vs incurred) so VotingChainladder can blend estimators built on different columns from the same multi-column triangle. It is exported on chainladder and covered by public API tests.

VotingChainladder._get_ultimate now gathers each estimator’s ultimate_, raises ValueError when shapes disagree (with a hint about misconfigured TriangleSelector), and slices the weight tensor to the ultimate’s column size instead of assuming it matches the full input X shape.

New voting tests cover TriangleSelector.fit_transform and the mismatch case when one pipeline selects a column and another does not.

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

@henrydingliu henrydingliu merged commit dfba575 into casact:TriangleSelector Jul 13, 2026
9 checks passed
@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): 14.6% of exported symbols fully typed (187 / 1280)

Known Ambiguous Unknown Total
Project (head) 187 106 987 1280

Other symbols referenced but not exported by chainladder: 13

Known Ambiguous Unknown Total
Other (head) 3 1 9 13

Symbols without documentation:

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

Patch (exported symbols added or changed by this PR): 25.0% fully typed (2 / 8)

Known Ambiguous Unknown Total
Patch 2 0 6 8
Patch symbol details
Symbol Status Change
chainladder.workflow.TriangleSelector ❌ unknown new
chainladder.workflow.tests.test_voting.test_mismatching_tri_sel ❌ unknown new
chainladder.workflow.tests.test_voting.test_tri_sel ❌ unknown new
chainladder.workflow.voting.TriangleSelector ❌ unknown new
chainladder.workflow.voting.TriangleSelector.__init__ ✅ known new
chainladder.workflow.voting.TriangleSelector.col ✅ known new
chainladder.workflow.voting.TriangleSelector.fit ❌ unknown new
chainladder.workflow.voting.TriangleSelector.transform ❌ unknown new

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 4892df9. Configure here.

for i, _ in enumerate(ultimates)
]
) / weights.sum(axis=-2)
) / weights[...,:shape_check[0][1], :, :, :].sum(axis=-2)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Weight slice wrong broadcast axis

High Severity

_get_ultimate trims the weight array with ultimate_.shape[1], treating that size as the value-column count. After _broadcast_weights expands 4D weights_ by repeating along X.shape[0], the second axis is index replication, not columns. Slicing it to 1 drops most index-level weights and skews the voted ultimate for multi-index triangles.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 4892df9. Configure here.

@codecov

codecov Bot commented Jul 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.55%. Comparing base (32ae098) to head (4892df9).
⚠️ Report is 1 commits behind head on TriangleSelector.

Additional details and impacted files
@@                 Coverage Diff                  @@
##           TriangleSelector    #1113      +/-   ##
====================================================
+ Coverage             90.50%   90.55%   +0.04%     
====================================================
  Files                    91       91              
  Lines                  5289     5306      +17     
  Branches                671      672       +1     
====================================================
+ Hits                   4787     4805      +18     
  Misses                  359      359              
+ Partials                143      142       -1     
Flag Coverage Δ
unittests 90.55% <100.00%> (+0.04%) ⬆️

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.

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