Repository navigation
feat(eval): the sink carries which protein each row is - #25
Merged
Merged
Conversation
The arrays were anonymous. Every axis they exist to support, sequence length, identity to the nearest donor, taxonomic relation, is keyed by protein, so arrays indexed by an opaque row number cannot be joined to any of them and the feature does not deliver what it was built for. Records now carry the ground truth's protein-to-index map and a row_index mapping array row to that numbering. Both are needed because two numberings are in play: the NK/LK kernel sees every row, so array row i is matrix row i, while the PK kernel can be handed a subset via pred[proteins_has_gt] and the two then disagree. compute_metrics knows which subsetting it performed, so it is what records the mapping rather than leaving the caller to reconstruct it. Getting this wrong would attribute one protein's score to another, which is precisely the failure the consuming project spent a week correcting in its neighbour search. It is worth a test rather than a comment, so there is one asserting row_index has exactly one entry per array row. Identity is absent rather than guessed when not supplied, and the id map is copied rather than aliased.
github-actions Bot
pushed a commit
to frapercan/PROTEA
that referenced
this pull request
Aug 19, 2026
…#784) The layer that makes stratification possible, plus the cafaeval pin that feeds it (frapercan/cafaeval-protea#25). ## Why the board can only stratify by two axes today Three of the axes this project is required to report are properties of a **protein**: sequence length, identity to the nearest donor, taxonomic relation to it. The stored evaluation is one number per `(category, aspect)` cell, so none of them is recoverable from it however it is sliced. Category and aspect are reportable only because cafaeval happens to partition the ground truth on them before aggregating. `PerProteinSink` hands over the vectors before `.sum(axis=0)` collapses them. This module turns one sink into rows keyed by accession, which join to `protein.length` and to `identity_nw` / `taxonomic_relation` in `go_prediction`. ## Three ways to be quietly wrong, each refused **Wrong threshold column.** cafaeval builds thresholds as `arange(th_step, 1, th_step)`. We rebuild that and assert the width matches the emitted arrays rather than trusting the reconstruction; an off-by-one would score every protein at a neighbouring threshold, which reads as a plausible number. The assertion earned itself immediately by catching a wrong fixture in its own test. **Wrong protein.** Two numberings are in play: the NK/LK kernel sees every row, the PK kernel is handed `pred[proteins_has_gt]`. A record lacking either the id map or the row index, or whose row index length disagrees with the arrays, is **dropped** rather than written under a guess. This is the positional misalignment that cost this project a fortnight in its neighbour search. **NaN.** A protein that predicted nothing, or that has no ground truth, scores zero rather than NaN, because a NaN propagates into every stratum mean that contains it and turns one empty cell into a blank row. ## Two deliberate narrowings Only the **weighted** variant is kept. `f_micro_w` is what every published cell here reports, and an unweighted row would be a different metric under the same column name. A **parquet artifact**, not a table. A table would need a migration, and migrations here are validated offline and never applied as a side effect of running an evaluation. ## Checks Eleven tests, one per failure mode above plus the arithmetic and a check that the per-protein rows sum to the totals the aggregate is built from. `ruff` clean, smell budget unchanged.
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.
Third and final piece of the per-protein sink. #23 emitted the arrays, #24 made
them reachable from
cafa_eval, and this makes them usable.The gap
The arrays were anonymous, indexed by an opaque row number. Every axis the sink
exists to support is keyed by protein:
None can be joined to a row number, so the feature as shipped could not do the
one thing it was built for. I found this while writing the consumer, at the point
of asking which protein row 0 was.
Two numberings, which is why this is not one line
The NK/LK kernel receives every row, so array row
iis matrix rowi. The PKkernel can be handed a subset:
after which the array numbering and the
idsnumbering disagree.compute_metricsis what performs that subsetting, so it is what records the mapping, rather than
leaving each caller to reconstruct it from state it does not have.
Getting this wrong would attribute one protein's score to another. That is
exactly the failure the consuming project spent a week correcting in its
neighbour search, where a positional misalignment produced plausible numbers for
a fortnight. So there is a test asserting
row_indexhas one entry per arrayrow, rather than a comment saying it should.
Also
Identity is
Nonewhen not supplied rather than guessed, and the id map iscopied rather than aliased, with tests for both.
pytest tests -q: 29 passed, 6 xfailed.ruffandmypyclean.