---
name: ibnr
description: >
  Gallery-centric probabilistic loss reserving: Bayesian MCMC and neural network methods with mandatory evaluation, over a long-format triangle data layer. Use when writing Python code that uses the ibnr package.
license: MPL-2.0
compatibility: Requires Python >=3.11,<3.13.
---

# ibnr

Gallery-centric probabilistic loss reserving: Bayesian MCMC and neural network methods with mandatory evaluation, over a long-format triangle data layer.

## Installation

```bash
pip install ibnr
```

## API overview

### 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`: A reserving triangle over an ibis table expression
- `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_chainladder`
- `Triangle.to_chainladder`
- `Triangle.from_bermuda`
- `Triangle.to_bermuda`
- `Triangle.to_cumulative`
- `Triangle.to_incremental`
- `Triangle.with_dev_grain`
- `Triangle.with_origin_grain`
- `Triangle.as_of`
- `Triangle.latest_diagonal`
- `Triangle.filter`
- `Triangle.select_fields`
- `Triangle.to_wide`
- `Triangle.to_pandas`
- `Triangle.to_polars`
- `Triangle.execute`
- `Triangle.count`
- `Triangle.with_expr`
- `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.get`
- `gallery.fit`
- `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.CohortForecast`
- `gallery.Absence`
- `gallery.align_panel`
- `gallery.leaderboard`
- `gallery.SCORE_DIRECTION`
- `gallery.stack`

### 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.fit_mack`
- `kernels.simulate_ultimates`
- `kernels.cdr_methods`
- `kernels.get_cdr_method`
- `kernels.one_year_cdr`
- `kernels.simulate_one_year_cdr`
- `kernels.rereserve`
- `kernels.cdr_risk_measures`
- `kernels.CDRResult`
- `kernels.MackDiagonal`
- `kernels.ODPBootstrapDiagonal`
- `gallery.GalleryDiagonal`

### Evaluation kernels

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


- `kernels.PredictiveDistribution`
- `kernels.ParityReport`
- `kernels.compare_posteriors`

### 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.from_arrow`
- `kernels.peek_kind`
- `kernels.to_summary`
- `kernels.CODEC_VERSION`
- `kernels.CONTENT_TYPE_ARROW`
- `kernels.CONTENT_TYPE_JSON`
- `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_task`
- `kernels.harness.RetroTask`
- `kernels.harness.SamplerSettings`
- `kernels.harness.ConvergenceGates`
- `kernels.harness.precompile`
- `kernels.harness.default_max_workers`

## Resources

- [Full documentation](https://ekthesage.github.io/ibnr/)
- [llms.txt](llms.txt) — Indexed API reference for LLMs
- [llms-full.txt](llms-full.txt) — Comprehensive documentation for LLMs
- [Source code](https://github.com/EKtheSage/ibnr)
