Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Commit ·
580f4e5
1
Parent(s): 2026d3e
score bindingdb on only exact == measurements, accept partial submissions (single or few function only) with unsubmitted set to chance)
Browse files- README.md +5 -4
- config.py +12 -7
- docs/scoring.md +11 -5
- docs/submission-format.md +6 -4
- plug_challenge/aggregate.py +26 -18
- plug_challenge/benchmarks.py +5 -3
- plug_challenge/cli.py +5 -4
- plug_challenge/validation.py +9 -2
- scripts/build_challenge_data.py +5 -0
- tests/test_aggregate.py +36 -13
- tests/test_submission_flow.py +15 -1
- tests/test_validation.py +11 -1
README.md
CHANGED
|
@@ -15,8 +15,8 @@ short_description: Leakage-free protein function prediction, eleven benchmarks
|
|
| 15 |
**P**rotein **L**eakage-free evaluation for **U**nbiased **G**enerators of function.
|
| 16 |
|
| 17 |
A public leaderboard for protein-function prediction on [PLUG](https://github.com/PrismScienceOrg/plug)'s
|
| 18 |
-
leakage-free Lo-Hi splits. Participants submit predictions for all
|
| 19 |
-
one bundle, with a required link describing their method; the Space validates and scores
|
| 20 |
it on the spot and adds it to one of two leaderboards:
|
| 21 |
|
| 22 |
- **Supervised**: trained on the Lo-Hi train/val splits, scored on the held-out,
|
|
@@ -83,8 +83,9 @@ number and a published baseline number are the same arithmetic. Each benchmark i
|
|
| 83 |
on its own, and the headline **PLUG Score** is the improvement over random chance across
|
| 84 |
all eleven: each primary metric is normalised so that chance is 0 and perfect is 1
|
| 85 |
(Spearman as |ρ|, so a ρ of −0.99 scores 0.99; AUROC as 2 × (AUROC − 0.5); Fmax as is),
|
| 86 |
-
nothing is clipped, and the PLUG Score is their mean
|
| 87 |
-
|
|
|
|
| 88 |
[`docs/scoring.md`](docs/scoring.md).
|
| 89 |
|
| 90 |
## Where the data lives
|
|
|
|
| 15 |
**P**rotein **L**eakage-free evaluation for **U**nbiased **G**enerators of function.
|
| 16 |
|
| 17 |
A public leaderboard for protein-function prediction on [PLUG](https://github.com/PrismScienceOrg/plug)'s
|
| 18 |
+
leakage-free Lo-Hi splits. Participants submit predictions for any or all of the eleven
|
| 19 |
+
benchmarks in one bundle, with a required link describing their method; the Space validates and scores
|
| 20 |
it on the spot and adds it to one of two leaderboards:
|
| 21 |
|
| 22 |
- **Supervised**: trained on the Lo-Hi train/val splits, scored on the held-out,
|
|
|
|
| 83 |
on its own, and the headline **PLUG Score** is the improvement over random chance across
|
| 84 |
all eleven: each primary metric is normalised so that chance is 0 and perfect is 1
|
| 85 |
(Spearman as |ρ|, so a ρ of −0.99 scores 0.99; AUROC as 2 × (AUROC − 0.5); Fmax as is),
|
| 86 |
+
nothing is clipped, and the PLUG Score is their mean, with a benchmark left out of the
|
| 87 |
+
bundle counting as chance (0). The board ranks by it, and each benchmark's tab ranks by
|
| 88 |
+
that benchmark's normalised score, so a method built for one benchmark is compared there. See
|
| 89 |
[`docs/scoring.md`](docs/scoring.md).
|
| 90 |
|
| 91 |
## Where the data lives
|
config.py
CHANGED
|
@@ -42,10 +42,10 @@ HOURS_BETWEEN_SUBMISSIONS = 12
|
|
| 42 |
# computes intervals offline. cafa5's Fmax never bootstraps — see scoring.py.
|
| 43 |
BOOTSTRAP_SAMPLES = int(os.environ.get("BOOTSTRAP_SAMPLES", "0"))
|
| 44 |
|
| 45 |
-
#
|
| 46 |
-
#
|
| 47 |
-
#
|
| 48 |
-
REQUIRE_COMPLETE_BUNDLE =
|
| 49 |
|
| 50 |
# ------------------------------- Links ------------------------------------------------
|
| 51 |
|
|
@@ -231,7 +231,9 @@ The headline number: the improvement over random chance, averaged over the
|
|
| 231 |
is 0 and perfect is 1 — Spearman's ρ as |ρ|, AUROC as 2 × (AUROC − 0.5), Fmax as is — and
|
| 232 |
the PLUG Score is their mean. A correlation is taken by its magnitude because its sign is a
|
| 233 |
convention of which way a label was written: a ρ of −0.99 is a very predictive model once
|
| 234 |
-
reversed. Nothing is clipped, so an AUROC below 0.5 counts against you.
|
|
|
|
|
|
|
| 235 |
|
| 236 |
It depends only on your own predictions, so it does not move as other entries arrive and is
|
| 237 |
safe to quote. `Mean rank` is shown beside it as the relative view. Each benchmark's tab
|
|
@@ -265,8 +267,11 @@ _COMPLETENESS_ANSWER = (
|
|
| 265 |
f"Yes — a bundle must carry all {BENCHMARK_COUNT} files. This keeps the PLUG Score "
|
| 266 |
"an apples-to-apples comparison between complete methods."
|
| 267 |
if REQUIRE_COMPLETE_BUNDLE
|
| 268 |
-
else "No —
|
| 269 |
-
"
|
|
|
|
|
|
|
|
|
|
| 270 |
)
|
| 271 |
|
| 272 |
FAQ_MD = f"""
|
|
|
|
| 42 |
# computes intervals offline. cafa5's Fmax never bootstraps — see scoring.py.
|
| 43 |
BOOTSTRAP_SAMPLES = int(os.environ.get("BOOTSTRAP_SAMPLES", "0"))
|
| 44 |
|
| 45 |
+
# Partial bundles are accepted: a benchmark left out counts as chance (0) in the PLUG
|
| 46 |
+
# Score, so the overall board is not inflated, and the entry still ranks on the tab of
|
| 47 |
+
# every benchmark it did cover. Set True to require all eleven files.
|
| 48 |
+
REQUIRE_COMPLETE_BUNDLE = False
|
| 49 |
|
| 50 |
# ------------------------------- Links ------------------------------------------------
|
| 51 |
|
|
|
|
| 231 |
is 0 and perfect is 1 — Spearman's ρ as |ρ|, AUROC as 2 × (AUROC − 0.5), Fmax as is — and
|
| 232 |
the PLUG Score is their mean. A correlation is taken by its magnitude because its sign is a
|
| 233 |
convention of which way a label was written: a ρ of −0.99 is a very predictive model once
|
| 234 |
+
reversed. Nothing is clipped, so an AUROC below 0.5 counts against you. A benchmark you
|
| 235 |
+
leave out counts as chance (0), so the overall board rewards coverage; sort by a
|
| 236 |
+
benchmark's own tab to compare methods built for that one task.
|
| 237 |
|
| 238 |
It depends only on your own predictions, so it does not move as other entries arrive and is
|
| 239 |
safe to quote. `Mean rank` is shown beside it as the relative view. Each benchmark's tab
|
|
|
|
| 267 |
f"Yes — a bundle must carry all {BENCHMARK_COUNT} files. This keeps the PLUG Score "
|
| 268 |
"an apples-to-apples comparison between complete methods."
|
| 269 |
if REQUIRE_COMPLETE_BUNDLE
|
| 270 |
+
else "No — submit only the benchmarks your method covers. Each one you leave out "
|
| 271 |
+
"counts as chance (0) in your PLUG Score, so the overall board is not inflated, but "
|
| 272 |
+
"you are ranked on the tab of every benchmark you did submit, and the Benchmarks "
|
| 273 |
+
"column shows how many you covered. Only your latest submission per track is "
|
| 274 |
+
"ranked, so a later partial bundle replaces an earlier complete one."
|
| 275 |
)
|
| 276 |
|
| 277 |
FAQ_MD = f"""
|
docs/scoring.md
CHANGED
|
@@ -57,10 +57,10 @@ NaN (`metrics.UNDEFINED`), and:
|
|
| 57 |
counts once regardless of size.
|
| 58 |
- `macro_auroc` skips single-class modes — a STRING mode that no test pair carries says
|
| 59 |
nothing about the submission either way.
|
| 60 |
-
- A benchmark whose primary metric is NaN shows blank on the board and
|
| 61 |
-
the PLUG Score
|
| 62 |
-
split (55 PASSerRank proteins, 139 SHS27k
|
| 63 |
-
track than the unsupervised one.
|
| 64 |
|
| 65 |
### CAFA Fmax
|
| 66 |
|
|
@@ -92,6 +92,11 @@ with `chance` taken from each metric's `MetricSpec`: 0 for Spearman, 0.5 for AUR
|
|
| 92 |
Fmax. The PLUG Score is therefore the **improvement over random chance**, averaged over
|
| 93 |
the eleven benchmarks: 0 is chance, 1 is perfect.
|
| 94 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 95 |
| Raw | Normalised |
|
| 96 |
|---|---|
|
| 97 |
| ρ = 1.0 | 1.0 |
|
|
@@ -123,7 +128,8 @@ A random submission scores about 0 overall. A perfect one scores 1.0.
|
|
| 123 |
|
| 124 |
The PLUG Score depends **only on your own predictions**, so it does not move as other
|
| 125 |
entries arrive and it is safe to quote. `Mean rank` — the mean of your per-benchmark
|
| 126 |
-
ranks
|
|
|
|
| 127 |
tab ranks by its normalised score, so a strong negative correlation ranks above a weaker
|
| 128 |
positive one there too.
|
| 129 |
|
|
|
|
| 57 |
counts once regardless of size.
|
| 58 |
- `macro_auroc` skips single-class modes — a STRING mode that no test pair carries says
|
| 59 |
nothing about the submission either way.
|
| 60 |
+
- A benchmark whose primary metric is NaN shows blank on the board and counts as chance
|
| 61 |
+
(0) in the PLUG Score, as a benchmark left out of the bundle does, with `Benchmarks`
|
| 62 |
+
showing the reduced count. A small Lo-Hi test split (55 PASSerRank proteins, 139 SHS27k
|
| 63 |
+
pairs) makes this likelier in the supervised track than the unsupervised one.
|
| 64 |
|
| 65 |
### CAFA Fmax
|
| 66 |
|
|
|
|
| 92 |
Fmax. The PLUG Score is therefore the **improvement over random chance**, averaged over
|
| 93 |
the eleven benchmarks: 0 is chance, 1 is perfect.
|
| 94 |
|
| 95 |
+
The mean is always over all eleven. A bundle may leave benchmarks out, and each one left
|
| 96 |
+
out counts as 0, so a method that covers one benchmark well cannot top the overall board
|
| 97 |
+
on it. It is ranked on that benchmark's own tab, which lists only the entries that covered
|
| 98 |
+
it, so methods built for one task can be compared there.
|
| 99 |
+
|
| 100 |
| Raw | Normalised |
|
| 101 |
|---|---|
|
| 102 |
| ρ = 1.0 | 1.0 |
|
|
|
|
| 128 |
|
| 129 |
The PLUG Score depends **only on your own predictions**, so it does not move as other
|
| 130 |
entries arrive and it is safe to quote. `Mean rank` — the mean of your per-benchmark
|
| 131 |
+
ranks, with a benchmark you did not cover ranked last — is shown beside it as the relative
|
| 132 |
+
view; that one does move. Each benchmark's own
|
| 133 |
tab ranks by its normalised score, so a strong negative correlation ranks above a weaker
|
| 134 |
positive one there too.
|
| 135 |
|
docs/submission-format.md
CHANGED
|
@@ -73,7 +73,7 @@ nothing outside the track, every row present:
|
|
| 73 |
| `passerrank.csv` | `datapoint_id`, `pred` | As above |
|
| 74 |
| `ppi.csv` | `datapoint_id`, `pred` | Score that the pair interacts. Pairs are undirected — your score should not depend on partner order |
|
| 75 |
| `lp-pdbbind.csv` | `datapoint_id`, `pred` | Binding affinity of the complex |
|
| 76 |
-
| `bindingdb.csv` | `datapoint_id`, `pred` | Binding affinity of the measurement |
|
| 77 |
| `atlas.csv` | `datapoint_id`, `pred` | Per-residue RMSF |
|
| 78 |
|
| 79 |
Only the ranking of a regression prediction is scored, and a Spearman correlation counts by
|
|
@@ -101,9 +101,11 @@ is a real strategy. Predict each `(protein, aspect, term)` at most once.
|
|
| 101 |
|
| 102 |
## Rules
|
| 103 |
|
| 104 |
-
1. **
|
| 105 |
-
|
| 106 |
-
|
|
|
|
|
|
|
| 107 |
3. **A method link.** Every submission needs a reachable `https://` link describing how
|
| 108 |
the predictions were made — a report, preprint or repository. It is shown on the
|
| 109 |
leaderboard.
|
|
|
|
| 73 |
| `passerrank.csv` | `datapoint_id`, `pred` | As above |
|
| 74 |
| `ppi.csv` | `datapoint_id`, `pred` | Score that the pair interacts. Pairs are undirected — your score should not depend on partner order |
|
| 75 |
| `lp-pdbbind.csv` | `datapoint_id`, `pred` | Binding affinity of the complex |
|
| 76 |
+
| `bindingdb.csv` | `datapoint_id`, `pred` | Binding affinity of the measurement; only exact (`=`) measurements are scored |
|
| 77 |
| `atlas.csv` | `datapoint_id`, `pred` | Per-residue RMSF |
|
| 78 |
|
| 79 |
Only the ranking of a regression prediction is scored, and a Spearman correlation counts by
|
|
|
|
| 101 |
|
| 102 |
## Rules
|
| 103 |
|
| 104 |
+
1. **Any of the eleven files, at least one.** A benchmark you leave out counts as chance
|
| 105 |
+
(0) in your PLUG Score; you are still ranked on the tab of each benchmark you include.
|
| 106 |
+
2. **Exactly your track's ids** in each row-per-datapoint file you include — nothing
|
| 107 |
+
missing, nothing extra, no duplicates. (`cafa5.csv` may cover fewer proteins, never
|
| 108 |
+
more.) For `bindingdb` that is the exact (`=`) measurements only.
|
| 109 |
3. **A method link.** Every submission needs a reachable `https://` link describing how
|
| 110 |
the predictions were made — a report, preprint or repository. It is shown on the
|
| 111 |
leaderboard.
|
plug_challenge/aggregate.py
CHANGED
|
@@ -11,6 +11,11 @@ Spearman correlation is the exception, normalised on its magnitude: its sign is
|
|
| 11 |
a convention of which way a label was written, and a model scoring -0.99 is as
|
| 12 |
predictive as one scoring 0.99 once reversed.
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
The PLUG Score is deterministic: it depends only on a submission's own
|
| 15 |
predictions, so a number stays the same as other entries arrive and is safe to
|
| 16 |
quote in a paper. It is recomputed from the stored per-benchmark metrics every
|
|
@@ -88,20 +93,17 @@ def plug_score(
|
|
| 88 |
Returns
|
| 89 |
-------
|
| 90 |
float
|
| 91 |
-
Mean over
|
| 92 |
-
chance and 1 is perfect
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
not silently rewarded for what it skipped.
|
| 96 |
|
| 97 |
"""
|
| 98 |
values = [
|
| 99 |
-
normalise(scores
|
| 100 |
for spec in specs
|
| 101 |
-
if spec.name in scores and f"{spec.primary.key}_mean" in scores[spec.name]
|
| 102 |
]
|
| 103 |
-
|
| 104 |
-
return float(np.mean(finite)) if finite else float("nan")
|
| 105 |
|
| 106 |
|
| 107 |
def flatten(scores: dict[str, dict[str, float]]) -> dict[str, float]:
|
|
@@ -214,23 +216,29 @@ def build_leaderboard(
|
|
| 214 |
rank_columns, normalised_columns = [], []
|
| 215 |
for spec in specs:
|
| 216 |
metric_column = column(spec.name, spec.primary)
|
| 217 |
-
if metric_column not in df.columns:
|
| 218 |
-
continue
|
| 219 |
normalised = score_column(spec.name)
|
| 220 |
-
df[normalised] =
|
| 221 |
-
|
| 222 |
-
|
| 223 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 224 |
normalised_columns.append(normalised)
|
| 225 |
rank_column = f"{spec.name}{SEP}rank"
|
| 226 |
-
|
|
|
|
|
|
|
|
|
|
| 227 |
rank_columns.append(rank_column)
|
| 228 |
|
| 229 |
# Recomputed rather than read back, so a stored score from an older
|
| 230 |
# normalisation can never disagree with the per-benchmark columns beside it.
|
| 231 |
-
|
|
|
|
| 232 |
|
| 233 |
-
df["mean_rank"] = df[rank_columns].mean(axis=1)
|
| 234 |
primary_columns = [
|
| 235 |
column(spec.name, spec.primary)
|
| 236 |
for spec in specs
|
|
|
|
| 11 |
a convention of which way a label was written, and a model scoring -0.99 is as
|
| 12 |
predictive as one scoring 0.99 once reversed.
|
| 13 |
|
| 14 |
+
The mean is always over every benchmark. One a submission left out (or could not
|
| 15 |
+
be scored on) counts as chance, 0, so a bundle covering a single benchmark cannot
|
| 16 |
+
top the overall board on that benchmark alone; it is ranked on that benchmark's
|
| 17 |
+
own tab, where only the entries that covered it appear.
|
| 18 |
+
|
| 19 |
The PLUG Score is deterministic: it depends only on a submission's own
|
| 20 |
predictions, so a number stays the same as other entries arrive and is safe to
|
| 21 |
quote in a paper. It is recomputed from the stored per-benchmark metrics every
|
|
|
|
| 93 |
Returns
|
| 94 |
-------
|
| 95 |
float
|
| 96 |
+
Mean over **every** benchmark in ``specs`` of the normalised primary
|
| 97 |
+
metric, where 0 is chance and 1 is perfect. A benchmark that is absent,
|
| 98 |
+
or whose metric is not finite, counts as 0 (chance), so a partial
|
| 99 |
+
bundle is not rewarded for what it skipped.
|
|
|
|
| 100 |
|
| 101 |
"""
|
| 102 |
values = [
|
| 103 |
+
normalise(scores.get(spec.name, {}).get(f"{spec.primary.key}_mean", np.nan), spec.primary)
|
| 104 |
for spec in specs
|
|
|
|
| 105 |
]
|
| 106 |
+
return float(np.mean([v if np.isfinite(v) else 0.0 for v in values]))
|
|
|
|
| 107 |
|
| 108 |
|
| 109 |
def flatten(scores: dict[str, dict[str, float]]) -> dict[str, float]:
|
|
|
|
| 216 |
rank_columns, normalised_columns = [], []
|
| 217 |
for spec in specs:
|
| 218 |
metric_column = column(spec.name, spec.primary)
|
|
|
|
|
|
|
| 219 |
normalised = score_column(spec.name)
|
| 220 |
+
df[normalised] = (
|
| 221 |
+
[
|
| 222 |
+
normalise(value, spec.primary)
|
| 223 |
+
for value in pd.to_numeric(df[metric_column], errors="coerce")
|
| 224 |
+
]
|
| 225 |
+
if metric_column in df.columns
|
| 226 |
+
else np.nan
|
| 227 |
+
)
|
| 228 |
normalised_columns.append(normalised)
|
| 229 |
rank_column = f"{spec.name}{SEP}rank"
|
| 230 |
+
# An entrant with no score here ranks last, behind everyone who has one.
|
| 231 |
+
df[rank_column] = (
|
| 232 |
+
df[normalised].rank(ascending=False, method="min").fillna(len(df))
|
| 233 |
+
)
|
| 234 |
rank_columns.append(rank_column)
|
| 235 |
|
| 236 |
# Recomputed rather than read back, so a stored score from an older
|
| 237 |
# normalisation can never disagree with the per-benchmark columns beside it.
|
| 238 |
+
# A benchmark with no score counts as chance (0) — see the module docstring.
|
| 239 |
+
df["plug_score"] = df[normalised_columns].fillna(0.0).mean(axis=1)
|
| 240 |
|
| 241 |
+
df["mean_rank"] = df[rank_columns].mean(axis=1)
|
| 242 |
primary_columns = [
|
| 243 |
column(spec.name, spec.primary)
|
| 244 |
for spec in specs
|
plug_challenge/benchmarks.py
CHANGED
|
@@ -6,8 +6,9 @@ Submit tab and its per-benchmark leaderboard tabs, the participant-facing format
|
|
| 6 |
docs — is generated from ``BENCHMARKS`` rather than restating it, so a benchmark
|
| 7 |
cannot be described one way on the Space and scored another way by the backend.
|
| 8 |
|
| 9 |
-
Each benchmark contributes one file to the submission bundle. A bundle
|
| 10 |
-
|
|
|
|
| 11 |
|
| 12 |
Rows and tracks
|
| 13 |
---------------
|
|
@@ -455,7 +456,8 @@ BENCHMARKS: tuple[BenchmarkSpec, ...] = (
|
|
| 455 |
manifest_columns=("target_key", "uniprot"),
|
| 456 |
description=(
|
| 457 |
"Predicted binding affinity for one (target, ligand) measurement from "
|
| 458 |
-
"BindingDB. `
|
|
|
|
| 459 |
),
|
| 460 |
),
|
| 461 |
# ------------------------------------------------------------------- MD/RMSF
|
|
|
|
| 6 |
docs — is generated from ``BENCHMARKS`` rather than restating it, so a benchmark
|
| 7 |
cannot be described one way on the Space and scored another way by the backend.
|
| 8 |
|
| 9 |
+
Each benchmark contributes one file to the submission bundle. A bundle may leave
|
| 10 |
+
benchmarks out; each one missing counts as chance in the PLUG Score (see
|
| 11 |
+
``config.REQUIRE_COMPLETE_BUNDLE``).
|
| 12 |
|
| 13 |
Rows and tracks
|
| 14 |
---------------
|
|
|
|
| 456 |
manifest_columns=("target_key", "uniprot"),
|
| 457 |
description=(
|
| 458 |
"Predicted binding affinity for one (target, ligand) measurement from "
|
| 459 |
+
"BindingDB. Only exact (`=`) measurements are scored. `target_key` is "
|
| 460 |
+
"plug's id for the target's sequence."
|
| 461 |
),
|
| 462 |
),
|
| 463 |
# ------------------------------------------------------------------- MD/RMSF
|
plug_challenge/cli.py
CHANGED
|
@@ -49,9 +49,10 @@ def _add_common(parser: argparse.ArgumentParser) -> None:
|
|
| 49 |
help="Directory holding <benchmark>/manifest.parquet (default: fetch from the Hub)",
|
| 50 |
)
|
| 51 |
parser.add_argument(
|
| 52 |
-
"--
|
| 53 |
action="store_true",
|
| 54 |
-
help="
|
|
|
|
| 55 |
)
|
| 56 |
|
| 57 |
|
|
@@ -139,7 +140,7 @@ def command_validate(args: argparse.Namespace) -> int:
|
|
| 139 |
result = validate_bundle(
|
| 140 |
args.bundle,
|
| 141 |
expected_ids=_expected_ids(args.track, args.data_dir),
|
| 142 |
-
require_complete=
|
| 143 |
)
|
| 144 |
if result.ok:
|
| 145 |
print(f"OK — {len(result.frames)} benchmark file(s) validated.")
|
|
@@ -179,7 +180,7 @@ def command_score(args: argparse.Namespace) -> int:
|
|
| 179 |
result = validate_bundle(
|
| 180 |
args.bundle,
|
| 181 |
expected_ids={name: set(frame[ID_COLUMN]) for name, frame in truth.items()},
|
| 182 |
-
require_complete=
|
| 183 |
)
|
| 184 |
if not result.ok:
|
| 185 |
print("Bundle is not valid:")
|
|
|
|
| 49 |
help="Directory holding <benchmark>/manifest.parquet (default: fetch from the Hub)",
|
| 50 |
)
|
| 51 |
parser.add_argument(
|
| 52 |
+
"--require-complete",
|
| 53 |
action="store_true",
|
| 54 |
+
help="Fail on a bundle missing any benchmark (the Space accepts partial bundles, "
|
| 55 |
+
"and counts each missing benchmark as chance)",
|
| 56 |
)
|
| 57 |
|
| 58 |
|
|
|
|
| 140 |
result = validate_bundle(
|
| 141 |
args.bundle,
|
| 142 |
expected_ids=_expected_ids(args.track, args.data_dir),
|
| 143 |
+
require_complete=args.require_complete,
|
| 144 |
)
|
| 145 |
if result.ok:
|
| 146 |
print(f"OK — {len(result.frames)} benchmark file(s) validated.")
|
|
|
|
| 180 |
result = validate_bundle(
|
| 181 |
args.bundle,
|
| 182 |
expected_ids={name: set(frame[ID_COLUMN]) for name, frame in truth.items()},
|
| 183 |
+
require_complete=args.require_complete,
|
| 184 |
)
|
| 185 |
if not result.ok:
|
| 186 |
print("Bundle is not valid:")
|
plug_challenge/validation.py
CHANGED
|
@@ -223,6 +223,13 @@ def validate_bundle(
|
|
| 223 |
result.add("bundle", f"Could not read the zip archive — {exc}")
|
| 224 |
return result
|
| 225 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 226 |
missing = [name for name in BENCHMARK_NAMES if name not in members]
|
| 227 |
if missing:
|
| 228 |
message = (
|
|
@@ -234,8 +241,8 @@ def validate_bundle(
|
|
| 234 |
result.add("bundle", message)
|
| 235 |
return result
|
| 236 |
# Partial bundles are allowed here, so an absent benchmark is something to
|
| 237 |
-
# report rather than a reason to refuse: the rest still scores, and
|
| 238 |
-
#
|
| 239 |
result.warn("bundle", message)
|
| 240 |
|
| 241 |
with zipfile.ZipFile(bundle_path) as archive:
|
|
|
|
| 223 |
result.add("bundle", f"Could not read the zip archive — {exc}")
|
| 224 |
return result
|
| 225 |
|
| 226 |
+
if not members:
|
| 227 |
+
result.add(
|
| 228 |
+
"bundle",
|
| 229 |
+
"The archive holds none of the benchmark files. Expected one file per "
|
| 230 |
+
"benchmark, named <benchmark>.csv or <benchmark>.parquet.",
|
| 231 |
+
)
|
| 232 |
+
return result
|
| 233 |
missing = [name for name in BENCHMARK_NAMES if name not in members]
|
| 234 |
if missing:
|
| 235 |
message = (
|
|
|
|
| 241 |
result.add("bundle", message)
|
| 242 |
return result
|
| 243 |
# Partial bundles are allowed here, so an absent benchmark is something to
|
| 244 |
+
# report rather than a reason to refuse: the rest still scores, and each
|
| 245 |
+
# absent benchmark counts as chance in the PLUG Score.
|
| 246 |
result.warn("bundle", message)
|
| 247 |
|
| 248 |
with zipfile.ZipFile(bundle_path) as archive:
|
scripts/build_challenge_data.py
CHANGED
|
@@ -112,6 +112,11 @@ def per_row(name: str, rows: list[dict]) -> list[dict]:
|
|
| 112 |
elif name == "lp-pdbbind":
|
| 113 |
out.append({**base, "pdb": row["pdb"], "value": row["value"]})
|
| 114 |
elif name == "bindingdb":
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
out.append(
|
| 116 |
{
|
| 117 |
**base,
|
|
|
|
| 112 |
elif name == "lp-pdbbind":
|
| 113 |
out.append({**base, "pdb": row["pdb"], "value": row["value"]})
|
| 114 |
elif name == "bindingdb":
|
| 115 |
+
# Only exact measurements are scored. A ">" or "<" row is a bound, not a value,
|
| 116 |
+
# so it cannot be ranked against the others; figure 4 drops it the same way.
|
| 117 |
+
# The row keeps its row_index, so the datapoint ids are unchanged.
|
| 118 |
+
if str(row.get("relation") or "").strip() != "=":
|
| 119 |
+
continue
|
| 120 |
out.append(
|
| 121 |
{
|
| 122 |
**base,
|
tests/test_aggregate.py
CHANGED
|
@@ -8,6 +8,7 @@ from plug_challenge.benchmarks import BENCHMARKS, get
|
|
| 8 |
|
| 9 |
from .conftest import make_predictions
|
| 10 |
|
|
|
|
| 11 |
SPEARMAN = get("megascale").primary
|
| 12 |
AUROC = get("ppi").primary
|
| 13 |
FMAX = get("cafa5").primary
|
|
@@ -44,16 +45,19 @@ def test_plug_score_of_a_perfect_submission_is_one(truth):
|
|
| 44 |
assert aggregate.plug_score(scores) == pytest.approx(1.0)
|
| 45 |
|
| 46 |
|
| 47 |
-
def
|
| 48 |
full = scoring.score_bundle(predictions, truth, BENCHMARKS)
|
| 49 |
partial = {name: value for name, value in full.items() if name != "atlas"}
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
|
| 55 |
-
def
|
| 56 |
-
assert
|
| 57 |
|
| 58 |
|
| 59 |
def test_flatten_and_column_agree_on_naming(predictions, truth):
|
|
@@ -100,7 +104,7 @@ def test_only_the_latest_submission_per_user_is_ranked():
|
|
| 100 |
]
|
| 101 |
)
|
| 102 |
assert len(board) == 1
|
| 103 |
-
assert board.loc[0, "plug_score"] == pytest.approx(0.3)
|
| 104 |
|
| 105 |
|
| 106 |
def test_plug_score_is_recomputed_from_the_metrics_not_read_back():
|
|
@@ -110,7 +114,7 @@ def test_plug_score_is_recomputed_from_the_metrics_not_read_back():
|
|
| 110 |
board = aggregate.build_leaderboard(
|
| 111 |
[_entry("a", "2026-01-01T00:00:00Z", 0.6, **{spearman: -0.4, auroc: 0.7})]
|
| 112 |
)
|
| 113 |
-
assert board.loc[0, "plug_score"] == pytest.approx((0.4 + 0.4) /
|
| 114 |
assert board.loc[0, "megascale__score"] == pytest.approx(0.4)
|
| 115 |
assert board.loc[0, "ppi__score"] == pytest.approx(0.4)
|
| 116 |
|
|
@@ -133,7 +137,7 @@ def test_a_below_chance_auroc_lowers_the_plug_score():
|
|
| 133 |
board = aggregate.build_leaderboard(
|
| 134 |
[_entry("a", "2026-01-01T00:00:00Z", 0.0, **{auroc: 0.3})]
|
| 135 |
)
|
| 136 |
-
assert board.loc[0, "plug_score"] == pytest.approx(-0.4)
|
| 137 |
|
| 138 |
|
| 139 |
def test_tracks_are_ranked_separately():
|
|
@@ -147,7 +151,7 @@ def test_tracks_are_ranked_separately():
|
|
| 147 |
unsupervised = aggregate.build_leaderboard(entries, track="unsupervised")
|
| 148 |
# One user's later entry to another track does not replace their entry here.
|
| 149 |
assert list(supervised["username"]) == ["a"]
|
| 150 |
-
assert supervised.loc[0, "plug_score"] == pytest.approx(0.2)
|
| 151 |
assert list(unsupervised["username"]) == ["a", "b"]
|
| 152 |
|
| 153 |
|
|
@@ -170,9 +174,28 @@ def test_per_benchmark_rank_and_mean_rank_are_added():
|
|
| 170 |
by_user = board.set_index("username")
|
| 171 |
assert by_user.loc["a", "megascale__rank"] == 1
|
| 172 |
assert by_user.loc["b", "ppi__rank"] == 1
|
| 173 |
-
# Each is first on one benchmark and second on the other
|
| 174 |
-
|
| 175 |
-
assert by_user.loc["
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 176 |
|
| 177 |
|
| 178 |
def test_benchmarks_scored_counts_only_finite_metrics():
|
|
|
|
| 8 |
|
| 9 |
from .conftest import make_predictions
|
| 10 |
|
| 11 |
+
N = len(BENCHMARKS)
|
| 12 |
SPEARMAN = get("megascale").primary
|
| 13 |
AUROC = get("ppi").primary
|
| 14 |
FMAX = get("cafa5").primary
|
|
|
|
| 45 |
assert aggregate.plug_score(scores) == pytest.approx(1.0)
|
| 46 |
|
| 47 |
|
| 48 |
+
def test_plug_score_counts_an_absent_benchmark_as_chance(predictions, truth):
|
| 49 |
full = scoring.score_bundle(predictions, truth, BENCHMARKS)
|
| 50 |
partial = {name: value for name, value in full.items() if name != "atlas"}
|
| 51 |
+
atlas = get("atlas").primary
|
| 52 |
+
dropped = aggregate.normalise(full["atlas"][f"{atlas.key}_mean"], atlas)
|
| 53 |
+
# The mean stays over all eleven: atlas now contributes 0 instead of its score.
|
| 54 |
+
assert aggregate.plug_score(partial) == pytest.approx(
|
| 55 |
+
aggregate.plug_score(full) - dropped / N
|
| 56 |
+
)
|
| 57 |
|
| 58 |
|
| 59 |
+
def test_plug_score_of_nothing_is_chance():
|
| 60 |
+
assert aggregate.plug_score({}) == pytest.approx(0.0)
|
| 61 |
|
| 62 |
|
| 63 |
def test_flatten_and_column_agree_on_naming(predictions, truth):
|
|
|
|
| 104 |
]
|
| 105 |
)
|
| 106 |
assert len(board) == 1
|
| 107 |
+
assert board.loc[0, "plug_score"] == pytest.approx(0.3 / N)
|
| 108 |
|
| 109 |
|
| 110 |
def test_plug_score_is_recomputed_from_the_metrics_not_read_back():
|
|
|
|
| 114 |
board = aggregate.build_leaderboard(
|
| 115 |
[_entry("a", "2026-01-01T00:00:00Z", 0.6, **{spearman: -0.4, auroc: 0.7})]
|
| 116 |
)
|
| 117 |
+
assert board.loc[0, "plug_score"] == pytest.approx((0.4 + 0.4) / N)
|
| 118 |
assert board.loc[0, "megascale__score"] == pytest.approx(0.4)
|
| 119 |
assert board.loc[0, "ppi__score"] == pytest.approx(0.4)
|
| 120 |
|
|
|
|
| 137 |
board = aggregate.build_leaderboard(
|
| 138 |
[_entry("a", "2026-01-01T00:00:00Z", 0.0, **{auroc: 0.3})]
|
| 139 |
)
|
| 140 |
+
assert board.loc[0, "plug_score"] == pytest.approx(-0.4 / N)
|
| 141 |
|
| 142 |
|
| 143 |
def test_tracks_are_ranked_separately():
|
|
|
|
| 151 |
unsupervised = aggregate.build_leaderboard(entries, track="unsupervised")
|
| 152 |
# One user's later entry to another track does not replace their entry here.
|
| 153 |
assert list(supervised["username"]) == ["a"]
|
| 154 |
+
assert supervised.loc[0, "plug_score"] == pytest.approx(0.2 / N)
|
| 155 |
assert list(unsupervised["username"]) == ["a", "b"]
|
| 156 |
|
| 157 |
|
|
|
|
| 174 |
by_user = board.set_index("username")
|
| 175 |
assert by_user.loc["a", "megascale__rank"] == 1
|
| 176 |
assert by_user.loc["b", "ppi__rank"] == 1
|
| 177 |
+
# Each is first on one benchmark and second on the other, and both rank last (2nd)
|
| 178 |
+
# on the nine benchmarks neither covered.
|
| 179 |
+
assert by_user.loc["a", "mean_rank"] == pytest.approx((1 + 2 + 2 * (N - 2)) / N)
|
| 180 |
+
assert by_user.loc["b", "mean_rank"] == pytest.approx(by_user.loc["a", "mean_rank"])
|
| 181 |
+
|
| 182 |
+
|
| 183 |
+
def test_a_single_benchmark_entry_leads_its_tab_but_not_the_overall_board():
|
| 184 |
+
mega = aggregate.column("megascale", SPEARMAN)
|
| 185 |
+
broad = {aggregate.column(spec.name, spec.primary): 0.7 if spec.primary.chance == 0.5
|
| 186 |
+
else 0.4 for spec in BENCHMARKS}
|
| 187 |
+
board = aggregate.build_leaderboard(
|
| 188 |
+
[
|
| 189 |
+
_entry("specialist", "2026-01-01T00:00:00Z", 0.0, **{mega: 0.95}),
|
| 190 |
+
_entry("generalist", "2026-01-01T00:00:00Z", 0.0, **broad),
|
| 191 |
+
]
|
| 192 |
+
)
|
| 193 |
+
by_user = board.set_index("username")
|
| 194 |
+
assert list(board["username"]) == ["generalist", "specialist"]
|
| 195 |
+
assert by_user.loc["specialist", "plug_score"] == pytest.approx(0.95 / N)
|
| 196 |
+
assert by_user.loc["specialist", "megascale__rank"] == 1
|
| 197 |
+
assert by_user.loc["specialist", "ppi__rank"] == 2
|
| 198 |
+
assert by_user.loc["specialist", "benchmarks_scored"] == 1
|
| 199 |
|
| 200 |
|
| 201 |
def test_benchmarks_scored_counts_only_finite_metrics():
|
tests/test_submission_flow.py
CHANGED
|
@@ -12,7 +12,8 @@ import pandas as pd
|
|
| 12 |
import pytest
|
| 13 |
|
| 14 |
import submission as submit_module
|
| 15 |
-
from plug_challenge
|
|
|
|
| 16 |
|
| 17 |
from .conftest import write_bundle
|
| 18 |
|
|
@@ -227,3 +228,16 @@ def test_a_storage_failure_is_reported_with_the_submission_id(fake_store, bundle
|
|
| 227 |
def test_a_missing_ground_truth_blocks_submissions(fake_store, bundle):
|
| 228 |
fake_store.truth = {}
|
| 229 |
assert "No ground truth" in _text(_submit(bundle))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
import pytest
|
| 13 |
|
| 14 |
import submission as submit_module
|
| 15 |
+
from plug_challenge import aggregate
|
| 16 |
+
from plug_challenge.benchmarks import BENCHMARKS, ID_COLUMN, get, select_track
|
| 17 |
|
| 18 |
from .conftest import write_bundle
|
| 19 |
|
|
|
|
| 228 |
def test_a_missing_ground_truth_blocks_submissions(fake_store, bundle):
|
| 229 |
fake_store.truth = {}
|
| 230 |
assert "No ground truth" in _text(_submit(bundle))
|
| 231 |
+
|
| 232 |
+
|
| 233 |
+
def test_a_single_benchmark_bundle_is_accepted_and_the_rest_count_as_chance(
|
| 234 |
+
fake_store, predictions, tmp_path
|
| 235 |
+
):
|
| 236 |
+
one = write_bundle({"megascale": predictions["megascale"]}, tmp_path / "one.zip")
|
| 237 |
+
result = _text(_submit(one))
|
| 238 |
+
assert "Submission accepted" in result
|
| 239 |
+
entry = fake_store.entries[0]
|
| 240 |
+
spec = get("megascale")
|
| 241 |
+
covered = aggregate.normalise(entry[f"megascale__{spec.primary.key}_mean"], spec.primary)
|
| 242 |
+
assert entry["plug_score"] == pytest.approx(covered / len(BENCHMARKS))
|
| 243 |
+
assert "ppi__auroc_mean" not in entry
|
tests/test_validation.py
CHANGED
|
@@ -51,7 +51,7 @@ def test_partial_bundle_allowed_when_not_required(predictions, tmp_path: Path, e
|
|
| 51 |
|
| 52 |
|
| 53 |
def test_partial_bundle_still_rejects_a_real_error(predictions, tmp_path: Path, expected_ids):
|
| 54 |
-
"""
|
| 55 |
del predictions["megascale"]
|
| 56 |
predictions["atlas"]["pred"] = 1.0 # constant column
|
| 57 |
result = validate_bundle(
|
|
@@ -181,3 +181,13 @@ def test_constant_predictions_are_still_rejected_for_rank_metrics():
|
|
| 181 |
assert get("megascale").needs_varying_predictions
|
| 182 |
assert get("ppi").needs_varying_predictions
|
| 183 |
assert not get("cafa5").needs_varying_predictions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
|
| 53 |
def test_partial_bundle_still_rejects_a_real_error(predictions, tmp_path: Path, expected_ids):
|
| 54 |
+
"""A partial bundle is forgiven an absent benchmark, never a malformed one."""
|
| 55 |
del predictions["megascale"]
|
| 56 |
predictions["atlas"]["pred"] = 1.0 # constant column
|
| 57 |
result = validate_bundle(
|
|
|
|
| 181 |
assert get("megascale").needs_varying_predictions
|
| 182 |
assert get("ppi").needs_varying_predictions
|
| 183 |
assert not get("cafa5").needs_varying_predictions
|
| 184 |
+
|
| 185 |
+
|
| 186 |
+
def test_a_bundle_with_no_benchmark_file_is_rejected(tmp_path: Path, expected_ids):
|
| 187 |
+
"""Partial bundles are allowed, but one covering nothing is not a submission."""
|
| 188 |
+
path = tmp_path / "b.zip"
|
| 189 |
+
with zipfile.ZipFile(path, "w") as archive:
|
| 190 |
+
archive.writestr("notes.txt", "nothing here")
|
| 191 |
+
result = validate_bundle(path, expected_ids, require_complete=False)
|
| 192 |
+
assert not result.ok
|
| 193 |
+
assert "none of the benchmark files" in result.report()
|