Repository navigation
Conversation
The new gallery notebook builds a GridSearch param_grid that drops each observed link ratio in turn through Development(drop=...), keeping every age, and scores each refit on total IBNR and ldf_. On raa the largest move is 1985 at 60, at +3,363 or 6.5% of IBNR. On genins the largest row drops the only ratio at 108-120, which leaves that ldf_ as NaN, and the notebook explains what that row measures. A heatmap shows the change for every cell of both triangles. Closes casact#1658. Developed with an AI assistant (Árbol, running Muse).
Pyright Type CompletenessView the full Project (full
Other symbols referenced but not exported by
Symbols without documentation:
Patch (exported symbols added or changed by this PR): 21.1% fully typed (4 / 19)
Patch symbol details
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1673 +/- ##
==========================================
+ Coverage 95.16% 95.30% +0.14%
==========================================
Files 100 100
Lines 6593 6693 +100
Branches 828 842 +14
==========================================
+ Hits 6274 6379 +105
+ Misses 202 199 -3
+ Partials 117 115 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
good stuff. should i have some small edits once we nail down the scope of the PR. |
|
Thanks. I'm happy to move them into GridSearch in this PR. Here is the shape I have in mind.
The first version would take a triangle with one index and one column and raise a ValueError otherwise. The estimator has to end in a reserving method such as Does that shape work, or would you rather have a standalone (This comment was written with Árbol, an AI assistant, under my direction.) |
would this classmethod be called by fit() or parallel to fit()? GridSearch is still a sklearn estimator at the end of the day. I was originally thinking that we only have two ways to play the sklearn game:
can we also have ibnr and ldf be defined under GridSearch?
i was thinking a compare_results(base, head) classmethod to generalize summary_ across other param_grids and scores.
i think it'll connect with readers more if we called it "sensitivity of individual age-to-age factors", and setup the narrative that way. |
|
Thanks, this helps. It would run parallel to Here is the shape I'd build.
The notebook would then call search = cl.GridSearch(
pipe,
cl.GridSearch.leave_one_out_grid(raa),
scoring={"ibnr": cl.GridSearch.ibnr, "ldf": cl.GridSearch.ldf},
).fit(raa)
search.compare_results("base")On The first version takes one index and one column and raises a ValueError otherwise. Tests check the base row against a plain fit, the grid length against the observed link ratios, the ValueError, and I'll retitle the notebook around the sensitivity of individual age-to-age factors and rebuild the story that way. A prototype on raa reproduces the notebook's top rows with (This comment was written with Árbol, an AI assistant, under my direction.) |
|
yes, i did mean head like Dataframe.head. on second thought, it's probably not necessary. everything else checks out. i quite liked what's in this notebook already. just putting in some suggestions on making this into a repeatable framework that we can expand upon. |
# Conflicts: # docs/gallery/index.md
…rs and compare_results
GridSearch.leave_one_out_grid builds a {step}__drop grid with the base fit
and one (origin, age) entry per observed link ratio. The grid is a dict
subclass that carries a label table, so GridSearch stores it as param_grid
and get_params and clone keep working without a new constructor argument.
GridSearch.ibnr and GridSearch.ldf are built-in scorers. compare_results
compares every candidate with a base row, adds the IBNR change and share
and the factor at the dropped age before and after, and sorts by the first
built-in scorer. Other grids keep the results_ index, and other scorers
keep their columns.
The leave-one-out gallery notebook now uses these helpers in place of its
local leave_one_out_grid and summarize functions.
Developed with an AI assistant (Árbol, running Muse).
|
You didn't miss anything. The GridSearch version is up now in 16c5c71.
On raa the top three rows match the notebook. Snippetimport chainladder as cl
raa = cl.load_sample("raa")
pipe = cl.Pipeline([("dev", cl.Development()), ("model", cl.Chainladder())])
search = cl.GridSearch(
pipe,
cl.GridSearch.leave_one_out_grid(raa),
scoring={"ibnr": cl.GridSearch.ibnr, "ldf": cl.GridSearch.ldf},
).fit(raa)
print(search.compare_results("base").head(3).round(4).to_string())On 16c5c71 this prints One question. (This comment was written with Árbol, an AI assistant, under my direction.) |
Add two tests for the compare_results paths the leave-one-out tests did not reach. One fits the ldf scorer on an ordinary grid, where no dropped age exists and both ldf columns are NaN. The other passes a single scoring callable, which keeps its score column and the results_ order. Developed with an AI assistant (Árbol, running Muse).
|
@scks1 this is tremendously slick.
a couple macro thoughts I'd like to get your feedback.
raa_table = raa_search.compare_results(
base="base",
result_labels=cl.GridSearch.leave_one_out_grid_labels,
result_metrics={
"ibnr": [cl.GridSearch.metrics.change, cl.GridSearch.metrics.share],
"ldf": [cl.GridSearch.metrics.before, cl.GridSearch.metrics.after],
},
) |
|
Thanks! I agree with both alternatives. They are simpler, and plain callables leave room for other grids without a class for each one. Three details to settle before I rework it.
(This comment was written with Árbol, an AI assistant, under my direction.) |

Summary of Changes
This PR adds a gallery notebook,
docs/gallery/plot_leave_one_out.ipynb, that drops each observed link ratio in turn and refits. A helper builds theGridSearchparam_grid{"dev__drop": [None, (origin, age), ...]}and keeps every age. Two scoring callables return total IBNR and theldf_array. The notebook tabulates the largest moves onraaandgeninsand draws a heatmap of the change in total IBNR for every cell. The PR also adds the gallery card, the card image and averdonck2011entry inreferences.bib.Related GitHub Issue(s)
Closes #1658
AI/LLM Usage
This change was made with Árbol, an AI assistant running on Muse, working under my direction. It wrote the notebook, the helper and the plot, ran the checks below and drafted this description.
Additional Context for Reviewers
The notebook keeps all ages, as you asked in the issue. Both sample triangles have one ratio at 108-120, so the 2001 at 108 row on
geninsand the 1981 at 108 row onraaleave thatldf_as NaN.cdf_at 108 then reads 1, andChainladdertreats the factor as 1. The notebook says that row measures setting the last factor to 1, and the heatmap boxes those cells. [BUG]Development(drop=...)can remove every link ratio at an age, andChainladderthen uses a factor of 1 without a warning #1661 covers the docstring side.Values from the executed notebook on main at 687e329:
raageninsgenins, without the single-ratio rowruff@0.16.1 checkandformat --checkpass on it. I did not run the fulljb build.Submitter's Checklist
[FIX],[FEAT],[DOCS],[TST],[CHORE], or[BRK]).Reviewer's Checklist