Prediction reports: training-set membership, novelty and conformal intervals (v4.4.0) - #118
Open
RobbinBouwmeester wants to merge 2 commits into
Open
Prediction reports: training-set membership, novelty and conformal intervals (v4.4.0)#118RobbinBouwmeester wants to merge 2 commits into
RobbinBouwmeester wants to merge 2 commits into
Conversation
A prediction is a number with no way to tell whether the model has seen the peptidoform, merely something like it, or nothing like it, and no statement of how far off it may be. prediction_report answers all three per PSM. Membership and novelty: exact match against the calibration reference and the Levenshtein distance to its closest sequence, always; with a TrainingIndex also exact match against the 10,105,640-peptidoform corpus behind the bundled multitask model, membership within the training sets of the setups the calibration selected, and the distance to the closest training sequence (exact to ten edits, capped beyond; the error is flat in this distance, so the cap costs nothing but keeps the search fast). Canonical keys reproduce the corpus format: peprec positions, Unimod accessions, lowercased unmapped names. Uncertainty: cross-fitted split-conformal intervals on the reference. Each reference fold is predicted by a calibration fitted on the other folds and the half-width is a finite-sample quantile of those honest residuals per predicted-RT bin. On eight held-out PRIDE setups the 90 % interval covered 0.88 to 0.97 per setup (median 0.91), 4 % of the gradient wide on well-behaved setups and honestly wide (79 %) on a run that pools fractions. Chosen over quantile regression because it needs no retraining and carries a finite-sample guarantee; coverage is marginal, not per-peptide. The TrainingIndex (~400 MB: sorted key hashes, per-setup membership CSR, unique sequences) is built offline from the training cache and distributed separately; the report works without it and then carries the reference columns only. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Member
Author
|
Index size addressed in 39b621e: the artifact is now a single 105 MB |
The directory form was 400 MB across seven files, most of it uncompressed structure: raw 64-bit hashes, int64 pointers, plain text. The packed .dlcidx is a stdlib LZMA zip that exploits what each component actually is. Sorted hashes are truncated to 40 bits and stored as 2^24 bucket counts plus 16-bit remainders, which costs a false positive about once per 100,000 membership queries and nothing else; a provenance flag does not need exactness beyond that. CSR pointers become uint16 row lengths (5x under LZMA), the setup lists and the sorted sequences compress 2.8x and 3.1x. Loading rebuilds the sorted hash array in about a second; answers are bit-identical to the directory form on membership, per-setup membership and distances, which the tests now check by running every index test against both formats. TrainingIndex reads both forms; the builder emits both. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
prediction_report(psm_list, psm_list_reference=..., coverage=0.90, training_index=...)returns predictions together with what a bare number cannot say, one row per PSM:predicted_rtpredict_and_calibrateci_lower,ci_upperin_referencedist_to_referencein_training*in_selected_heads_training*dist_to_training** with a
TrainingIndex, a ~400 MB memory-mapped artifact (sorted key hashes, per-setup membership CSR, 6.16 M unique sequences) built offline from the training cache bybuild_training_index.pyin the research repo. The report works without it. Hosting to be decided (HF hub?).The interval
Cross-fitted split-conformal on the reference: five folds, each predicted by a calibration fitted on the other four, half-width = finite-sample quantile of those honest |residuals| per predicted-RT bin (peak width varies along a gradient). No retraining, works for any model and calibration, finite-sample marginal coverage guarantee. Chosen over quantile regression (pinball) for exactly those reasons.
Validated on the eight held-out PRIDE setups (Figure 1b corpus), nominal 90 %:
End-to-end through this API on three held-out setups: coverage@90 = 0.914 / 0.898 / 0.974, and the membership columns behave (PXD079927: 60 % of test peptidoforms in the corpus but only 1.2 % in the 80 selected setups; PXD081880: 100 % / 95 %).
Canonical keys
canonical_peptidoform_keyreproduces the corpus key format (peprec positions,U:<unimod id>, lowercased unmapped names, position-sorted, charge ignored) — verified against real corpus keys, including modified ones.Verification
tests/test_report.py(key format, interval coverage / adaptivity / thin-bin fallback on synthetic data, index membership global and per-setup, capped distances, non-index directory refused, report end-to-end with and without index, pre-fitted calibration refused, multi-head head listing).ruff check/formatclean on the new files.rapidfuzz(pure wheel).🤖 Generated with Claude Code