gallery.GalleryEntry
Usage
gallery.GalleryEntry()Methods
| Name | Description |
|---|---|
| card() | The model card (card.md next to the entry’s module). |
| cohort_index() |
Which of cohorts() a segment= argument names, or None.
|
| cohorts() | Every cohort this fit answers for, in predict()’s target order. |
| evaluate() | Score realized outcomes against the predictive distribution. |
| fit() | Fit on a training triangle (already sliced with as_of). |
| predict() | Predictive distribution of the fitted quantities (e.g. ultimates). |
| realized_ultimates() |
Outcomes aligned, element for element, to predict(segment)’s targets.
|
card()
The model card (card.md next to the entry’s module).
Usage
card()cohort_index()
Which of cohorts() a segment= argument names, or None.
Usage
cohort_index(segment)None in, None out - the entry then does whatever segment=None means for it. Otherwise every supplied pair must match and exactly one cohort must survive: segment is a filter on this fit’s cohorts, not a description of a triangle. A subset that identifies one cohort is accepted, which is what lets one loop pass the same dict to a fit keyed on (company_code, company_name, line_of_business) and to a pooled fit keyed on (company_code, line_of_business).
Implemented once here and used by all 15 entries, which is why a mismatch reports the same way everywhere: naming the fit’s own cohort key, and never silently scoring the fitted cohort for a typo’d one.
cohorts()
Every cohort this fit answers for, in predict()’s target order.
Usage
cohorts()Length 1 for a single-cohort fit, one entry per pooled cohort otherwise, so for seg in entry.cohorts(): entry.predict(segment=seg) loops over any entry in the gallery with no knowledge of its family.
Each dict is the cohort’s FULL segment identity as the triangle carried it - including any column the fit’s own cohort KEY does not carry (kernels.nn_contract.DISPLAY_COLUMNS: a pooled NN fit is keyed on company_code and drops company_name, so that two spellings of one company do not become two cohorts). A caller must not be told a cohort is unidentifiable when the fit knows exactly which one it is.
Abstract rather than defaulted to contract_["segment"]: a pooled entry that forgot to override would then get a plausible answer from a key that happens to exist, which is the entries-cloned-from-stale-templates failure. register() refuses an entry that skips it.
evaluate()
Score realized outcomes against the predictive distribution.
Usage
evaluate(observed, segment=None)Default implementation (kernels-backed): the Meyers-style summary table plus the outcome percentile of each target. Richer harnesses (ELPD, stacking) extend this in kernels, not in entries.
segment is passed straight to predict(), so it selects exactly the same cohort here as there. Without it a pooled fit could only ever be evaluated on its whole panel.
fit()
Fit on a training triangle (already sliced with as_of).
Usage
fit(triangle, **kwargs)predict()
Predictive distribution of the fitted quantities (e.g. ultimates).
Usage
predict(segment=None, **kwargs)segment names one cohort of this fit (see cohorts()), and means the same thing on every entry in the gallery: the returned targets describe that cohort and nothing else. A single-cohort fit accepts None or a matching key and returns the identical object either way; a pooled fit returns that one cohort’s targets plus its total, and returns the whole panel (no total - a total across companies is not a quantity) when the segment is omitted.
A segment that names no cohort of this fit raises rather than being ignored: accepting and discarding it would make a typo’d cohort key score the fitted cohort and return a plausible number.
realized_ultimates()
Outcomes aligned, element for element, to predict(segment)’s targets.
Usage
realized_ultimates(full_triangle, segment=None)Read from the FULL (unsliced) triangle, restricted to the origins the training slice actually had - the Schedule P mart carries accident years past the study window and an unrestricted aggregate is silently inflated (measured at 2.4x once, in scripts/compare_gallery.py).
On the ABC because it is what makes a cross-model outcome table possible: it was implemented on all 15 entries under a convention nothing enforced, and the convention had already drifted across two families.