Repository navigation
Charts: catch-model calibration and residual diagnostics - #151
Conversation
- Page weight: the diagnostics sent every set as an object with eight
unrounded fields for all three models, about 500 kB of JSON on every
/drivers load. Only what the charts draw goes out now, rounded and in
columns: 47 kB (12 kB with Brotli).
- Zero-catch charts show nursery names and formatted seasons instead of
raw ids; shares are percentages in the chart and table.
- The section sits after the model it checks, inside the model's {#if},
instead of above the single-variable correlations.
- Colours: the observed series takes the model's colour (species colours
for the species models) and expected is muted, instead of slots 1 and
2, which mean blacktip and lemon on this page.
- Plainer copy and axis labels; dates on the season axis; a log x axis
for residuals against the expected catch, with a note on the bands.
- The 20-set threshold is one constant used by the filter and the copy.
- Tests: the Poisson limit, labelled groups and failed fits; the e2e test
checks the section is absent without a model (the fixture can't fit
one) and exercises it when there is one.
- AGENTS.md note moved from School holidays to the catch model.
- Merged main; IMPORTER_VERSION already 9 there, no bump needed here.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Reviewed against the real data (aggregates only) and current
On the real data the model describes catches reasonably well:
The tenth of sets with the highest expected catch gets fewer sharks than the model expects: 1.51 vs 1.88 per net-hour for all sharks. Sicklefin lemons show the same pattern (1.57 vs 1.93). I pushed fixes in 3432eec, 3bf20cb and ef54789, after merging 1. Page weight. The diagnostics sent every set as an object with eight unrounded fields, for all three models: about 500 kB of JSON on every /drivers load, embedded in the HTML too. The rest of the model is 12 kB. Now only what the charts draw goes out, rounded and in columns: 47 kB, or 12 kB with Brotli. The AGENTS.md note says to keep it that way (#76). 2. Nursery ids. The zero-catch chart and table showed raw ids ("haapiti", "valorie"). They now show nursery names, seasons are formatted, and shares are percentages in both the chart and the table. 3. Placement. The section opened the page, above the single-variable correlations and before the model it checks. It now follows the model section, in its own 4. Colours. Observed and expected used series slots 1 and 2, which mean blacktip and sicklefin lemon on this page. Observed now takes the model's colour, which is the species colour for the species models, and expected is muted. 5. Copy and axes
6. Tests
7. Smaller fixes
Checks after the fixes:
|
Adds expandable in-sample diagnostics to /drivers: observed versus expected catch rates, zero-catch shares by nursery/season, and Pearson residuals versus fitted count and season day. Each uses its exact species-specific fitted rows, design matrix and effort offsets. Failed/unsupported fits show an explicit unavailable state. Calibration rates are ratios of summed counts to summed net-hours; NB2 zero probabilities and residual variance use the fitted dispersion.
Closes #125.
Validation: lint; svelte-check (0 errors/warnings); 87 unit tests; opt-in real-data import; an additional opt-in real-data diagnostic reconciliation test; production build; 31 existing browser tests and the new diagnostics selector/light/dark axe check (passed on focused rerun after fixing its locator). The synthetic browser fixture exercises the unsupported-model state; numerical tests and the real-data check exercise supported fits. No private data committed.