# API Reference


## Triangle


The long-format triangle data layer - a tidy table of origin_period / dev_lag / eval_date cells over an ibis expression (duckdb or polars backend), carrying grain, cumulative/incremental, and units metadata.


[Triangle](Triangle.md#ibnr.Triangle)  
A reserving triangle over an ibis table expression.

[TriangleMeta](TriangleMeta.md#ibnr.TriangleMeta)  
Triangle-level metadata. Carried through every transformation.


## Triangle transforms & interop


Cumulative/incremental conversion, grain changes, as_of() backtest slicing, and lossless round-trips with chainladder-python and bermuda.


[Triangle.from_long()](Triangle.from_long.md#ibnr.Triangle.from_long)  

[Triangle.from_chainladder()](Triangle.from_chainladder.md#ibnr.Triangle.from_chainladder)  

[Triangle.to_chainladder()](Triangle.to_chainladder.md#ibnr.Triangle.to_chainladder)  

[Triangle.from_bermuda()](Triangle.from_bermuda.md#ibnr.Triangle.from_bermuda)  

[Triangle.to_bermuda()](Triangle.to_bermuda.md#ibnr.Triangle.to_bermuda)  

[Triangle.to_cumulative()](Triangle.to_cumulative.md#ibnr.Triangle.to_cumulative)  

[Triangle.to_incremental()](Triangle.to_incremental.md#ibnr.Triangle.to_incremental)  

[Triangle.with_dev_grain()](Triangle.with_dev_grain.md#ibnr.Triangle.with_dev_grain)  

[Triangle.with_origin_grain()](Triangle.with_origin_grain.md#ibnr.Triangle.with_origin_grain)  

[Triangle.as_of()](Triangle.as_of.md#ibnr.Triangle.as_of)  

[Triangle.latest_diagonal()](Triangle.latest_diagonal.md#ibnr.Triangle.latest_diagonal)  

[Triangle.filter()](Triangle.filter.md#ibnr.Triangle.filter)  
Filter rows with ibis deferred predicates, e.g. `t.filter(ibis._.lob == 'wkcomp')`.

[Triangle.select_fields()](Triangle.select_fields.md#ibnr.Triangle.select_fields)  

[Triangle.to_wide()](Triangle.to_wide.md#ibnr.Triangle.to_wide)  
Pivot one field to an origin x dev_lag matrix (materializes; for display).

[Triangle.to_pandas()](Triangle.to_pandas.md#ibnr.Triangle.to_pandas)  

[Triangle.to_polars()](Triangle.to_polars.md#ibnr.Triangle.to_polars)  

[Triangle.execute()](Triangle.execute.md#ibnr.Triangle.execute)  

[Triangle.count()](Triangle.count.md#ibnr.Triangle.count)  

[Triangle.with_expr()](Triangle.with_expr.md#ibnr.Triangle.with_expr)  
New Triangle with a replaced expression and optional meta updates.

[Triangle.validate()](Triangle.validate.md#ibnr.Triangle.validate)  


## Gallery


Discover, retrieve, and fit reserving models through the GalleryEntry contract. Every entry - Bayesian, neural, or statistical - produces a PredictiveDistribution.


[gallery.list()](gallery.list.md#ibnr.gallery.list)  
Names of all registered gallery entries.

[gallery.get](gallery.get.md#ibnr.gallery.get)  

[gallery.fit](gallery.fit.md#ibnr.gallery.fit)  

[gallery.GalleryEntry](gallery.GalleryEntry.md#ibnr.gallery.GalleryEntry)  


## Held-out evaluation


The four steps between a fitted entry and a leaderboard row: which cells a fit at as_of is scored on, one model's arrays at those cells, the cross-model intersection, and the board.


[gallery.next_diagonal()](gallery.next_diagonal.md#ibnr.gallery.next_diagonal)  
Cells that first become observable on the diagonal after `as_of`.

[gallery.CohortForecast](gallery.CohortForecast.md#ibnr.gallery.CohortForecast)  
One model, one cohort, one cutoff, one field, at the held-out cells.

[gallery.Absence](gallery.Absence.md#ibnr.gallery.Absence)  
Why an array is missing, from a closed vocabulary.

[gallery.align_panel()](gallery.align_panel.md#ibnr.gallery.align_panel)  
Put every model on the SAME cells - per score - and report what fell out.

[gallery.leaderboard()](gallery.leaderboard.md#ibnr.gallery.leaderboard)  
The board. One row per model, ordered by model name. No sort key.

[gallery.SCORE_DIRECTION](gallery.SCORE_DIRECTION.md#ibnr.gallery.SCORE_DIRECTION)  

[gallery.stack()](gallery.stack.md#ibnr.gallery.stack)  
Fit stacking weights on one panel, build stacked forecasts at a later one.


## Chain ladder & reserve risk


The distribution-free chain ladder (Mack 1993) and its run-off MSEP, plus the one-year claims development result - the Solvency II reserve-risk view. cdr_methods() is the option surface: which model generates next year's diagonal, how the reserve is re-estimated once it exists, and what each route has actually been validated against.


[kernels.MackFit](kernels.MackFit.md#ibnr.kernels.MackFit)  
A fitted distribution-free chain ladder on one cohort.

[kernels.fit_mack()](kernels.fit_mack.md#ibnr.kernels.fit_mack)  
Fit the distribution-free chain ladder on a single-cohort Triangle.

[kernels.simulate_ultimates()](kernels.simulate_ultimates.md#ibnr.kernels.simulate_ultimates)  
Simulate FULL run-off ultimates from a fitted Mack model.

[kernels.cdr_methods()](kernels.cdr_methods.md#ibnr.kernels.cdr_methods)  
Every way to get a one-year CDR, and the terms of each.

[kernels.get_cdr_method()](kernels.get_cdr_method.md#ibnr.kernels.get_cdr_method)  
The `CDRMethod` descriptor for one route, or a KeyError naming the

[kernels.one_year_cdr()](kernels.one_year_cdr.md#ibnr.kernels.one_year_cdr)  
Merz-Wuthrich (2008) closed-form msep of the one-year CDR.

[kernels.simulate_one_year_cdr()](kernels.simulate_one_year_cdr.md#ibnr.kernels.simulate_one_year_cdr)  
Actuary in the box: the one-year CDR distribution by re-reserving.

[kernels.rereserve()](kernels.rereserve.md#ibnr.kernels.rereserve)  
`(n_draws, n_w)` one-year CDR draws from simulated next-diagonal values.

[kernels.cdr_risk_measures()](kernels.cdr_risk_measures.md#ibnr.kernels.cdr_risk_measures)  
VaR and TVaR of the one-year LOSS, from simulated CDR draws.

[kernels.CDRResult](kernels.CDRResult.md#ibnr.kernels.CDRResult)  
One-year CDR uncertainty for one cohort, per accident year and in total.

[kernels.MackDiagonal](kernels.MackDiagonal.md#ibnr.kernels.MackDiagonal)  
Next year's diagonal from Mack's conditional moments.

[kernels.ODPBootstrapDiagonal](kernels.ODPBootstrapDiagonal.md#ibnr.kernels.ODPBootstrapDiagonal)  
Next year's diagonal from an England-Verrall ODP residual bootstrap.

[gallery.GalleryDiagonal](gallery.GalleryDiagonal.md#ibnr.gallery.GalleryDiagonal)  
Next year's diagonal from a fitted gallery entry's posterior predictive.


## Evaluation kernels


The unifying predictive-distribution output type and the cross-backend posterior-parity tooling.


[kernels.PredictiveDistribution](kernels.PredictiveDistribution.md#ibnr.kernels.PredictiveDistribution)  
Sampled predictive distribution over a set of targets.

[kernels.ParityReport](kernels.ParityReport.md#ibnr.kernels.ParityReport)  
Result of comparing one or more ported posteriors to a reference.

[kernels.compare_posteriors()](kernels.compare_posteriors.md#ibnr.kernels.compare_posteriors)  
Compare each non-reference posterior in `idatas` to `idatas[reference]`.


## Wire format


The single place an ibnr result becomes bytes - one Arrow IPC stream per artifact, uncompressed by default, plus a one-way JSON summary for callers that cannot take the draws.


[kernels.to_arrow()](kernels.to_arrow.md#ibnr.kernels.to_arrow)  
Serialize one ibnr result to an Arrow IPC stream.

[kernels.from_arrow()](kernels.from_arrow.md#ibnr.kernels.from_arrow)  
Reconstruct whatever `to_arrow()` wrote, dispatching on `ibnr.kind`.

[kernels.peek_kind()](kernels.peek_kind.md#ibnr.kernels.peek_kind)  
The artifact type, read from the stream's schema message.

[kernels.to_summary()](kernels.to_summary.md#ibnr.kernels.to_summary)  
A JSON-safe digest for callers that cannot take the draws.

[kernels.CODEC_VERSION](kernels.CODEC_VERSION.md#ibnr.kernels.CODEC_VERSION)  

[kernels.CONTENT_TYPE_ARROW](kernels.CONTENT_TYPE_ARROW.md#ibnr.kernels.CONTENT_TYPE_ARROW)  

[kernels.CONTENT_TYPE_JSON](kernels.CONTENT_TYPE_JSON.md#ibnr.kernels.CONTENT_TYPE_JSON)  

[kernels.DEFAULT_QUANTILES](kernels.DEFAULT_QUANTILES.md#ibnr.kernels.DEFAULT_QUANTILES)  


## Retrospective harness


Parallel company x line backtesting with staged sampler escalation - the compute seam behind the study scripts.


[kernels.harness.run_retro()](kernels.harness.run_retro.md#ibnr.kernels.harness.run_retro)  
Run every task through the staged escalation, in parallel.

[kernels.harness.run_task()](kernels.harness.run_task.md#ibnr.kernels.harness.run_task)  
Fit + score one task: the worker function. Never raises - a failure

[kernels.harness.RetroTask](kernels.harness.RetroTask.md#ibnr.kernels.harness.RetroTask)  
One unit of work: fit one model to one company x line cohort as of a

[kernels.harness.SamplerSettings](kernels.harness.SamplerSettings.md#ibnr.kernels.harness.SamplerSettings)  
One escalation stage's MCMC budget.

[kernels.harness.ConvergenceGates](kernels.harness.ConvergenceGates.md#ibnr.kernels.harness.ConvergenceGates)  
Pass/fail thresholds on an entry's `convergence()` diagnostics.

[kernels.harness.precompile()](kernels.harness.precompile.md#ibnr.kernels.harness.precompile)  
Compile the Stan program of every (given, else registered) entry that

[kernels.harness.default_max_workers()](kernels.harness.default_max_workers.md#ibnr.kernels.harness.default_max_workers)  
Worker-pool size when the caller does not choose one: the
