Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Commit ·
b78ff28
1
Parent(s): e8a6ef2
initial commit with test setup
Browse files- .dockerignore +15 -0
- .github/workflows/checks.yml +46 -0
- .gitignore +27 -0
- Dockerfile +19 -0
- README.md +116 -5
- app.py +90 -0
- config.py +300 -0
- data/README.md +51 -0
- data/atlas/plug_entities.csv +1939 -0
- data/bindingdb/plug_entities.csv +0 -0
- data/lp-pdbbind/plug_entities.csv +0 -0
- docs/SETUP.md +178 -0
- docs/architecture.md +109 -0
- docs/scoring.md +132 -0
- docs/submission-format.md +107 -0
- index.html +0 -19
- leaderboards.py +297 -0
- models.py +122 -0
- plug_challenge/__init__.py +26 -0
- plug_challenge/aggregate.py +197 -0
- plug_challenge/benchmarks.py +458 -0
- plug_challenge/cli.py +285 -0
- plug_challenge/metrics.py +453 -0
- plug_challenge/scoring.py +268 -0
- plug_challenge/store.py +463 -0
- plug_challenge/validation.py +434 -0
- pyproject.toml +56 -0
- requirements.txt +15 -0
- scripts/build_challenge_data.py +507 -0
- style.css +0 -28
- submission.py +391 -0
- tests/__init__.py +0 -0
- tests/conftest.py +196 -0
- tests/test_aggregate.py +139 -0
- tests/test_leaderboard_views.py +125 -0
- tests/test_metrics.py +135 -0
- tests/test_real_data.py +195 -0
- tests/test_scoring.py +144 -0
- tests/test_submission_flow.py +190 -0
- tests/test_validation.py +183 -0
- utils.py +274 -0
.dockerignore
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Only matters for a local `docker build`; Hugging Face builds from the git repo,
|
| 2 |
+
# where everything below is either gitignored or absent.
|
| 3 |
+
.challenge-data/
|
| 4 |
+
.venv/
|
| 5 |
+
.git/
|
| 6 |
+
.github/
|
| 7 |
+
.pytest_cache/
|
| 8 |
+
.mypy_cache/
|
| 9 |
+
.ruff_cache/
|
| 10 |
+
__pycache__/
|
| 11 |
+
*.egg-info/
|
| 12 |
+
tests/
|
| 13 |
+
docs/
|
| 14 |
+
scripts/
|
| 15 |
+
data/
|
.github/workflows/checks.yml
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Lint, type-check and test the scoring library and the Space's modules.
|
| 2 |
+
#
|
| 3 |
+
# Hugging Face Spaces do not run GitHub Actions, and this repository *is* the
|
| 4 |
+
# Space — so this workflow only does anything if you also mirror the repo to
|
| 5 |
+
# GitHub. It is committed because the checks are worth having available, and it
|
| 6 |
+
# is inert otherwise.
|
| 7 |
+
name: checks
|
| 8 |
+
|
| 9 |
+
on:
|
| 10 |
+
push:
|
| 11 |
+
branches: [main]
|
| 12 |
+
pull_request:
|
| 13 |
+
workflow_dispatch:
|
| 14 |
+
|
| 15 |
+
jobs:
|
| 16 |
+
checks:
|
| 17 |
+
runs-on: ubuntu-latest
|
| 18 |
+
steps:
|
| 19 |
+
- uses: actions/checkout@v4
|
| 20 |
+
|
| 21 |
+
- uses: actions/setup-python@v5
|
| 22 |
+
with:
|
| 23 |
+
python-version: "3.12"
|
| 24 |
+
|
| 25 |
+
- name: Install
|
| 26 |
+
run: |
|
| 27 |
+
python -m pip install --upgrade pip
|
| 28 |
+
pip install -e ".[space,dev]"
|
| 29 |
+
|
| 30 |
+
- name: Lint
|
| 31 |
+
run: ruff check .
|
| 32 |
+
|
| 33 |
+
- name: Type-check
|
| 34 |
+
run: mypy plug_challenge/ app.py config.py submission.py leaderboards.py models.py utils.py
|
| 35 |
+
|
| 36 |
+
- name: Test
|
| 37 |
+
# No HF_TOKEN: the suite is synthetic and must never need the Hub. If a
|
| 38 |
+
# test starts failing here but passing locally, it has grown a dependency
|
| 39 |
+
# on real data or real credentials — fix the test, don't add a secret.
|
| 40 |
+
run: pytest tests/ -q
|
| 41 |
+
|
| 42 |
+
- name: Check the Space's app graph builds in every phase
|
| 43 |
+
run: |
|
| 44 |
+
for phase in 0 1 2; do
|
| 45 |
+
CURRENT_PHASE=$phase python -c "import app; print(f'phase {app.CURRENT_PHASE} OK')"
|
| 46 |
+
done
|
.gitignore
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Generated challenge data. `public/` is uploaded to the public dataset repo and
|
| 2 |
+
# `private/` holds the held-back test labels — neither belongs in this repo's
|
| 3 |
+
# git history, and this Space is public.
|
| 4 |
+
.challenge-data/
|
| 5 |
+
|
| 6 |
+
# Python
|
| 7 |
+
__pycache__/
|
| 8 |
+
*.py[cod]
|
| 9 |
+
*.egg-info/
|
| 10 |
+
build/
|
| 11 |
+
dist/
|
| 12 |
+
.venv/
|
| 13 |
+
venv/
|
| 14 |
+
.eggs/
|
| 15 |
+
|
| 16 |
+
# Tooling
|
| 17 |
+
.pytest_cache/
|
| 18 |
+
.mypy_cache/
|
| 19 |
+
.ruff_cache/
|
| 20 |
+
.coverage
|
| 21 |
+
htmlcov/
|
| 22 |
+
|
| 23 |
+
# Local secrets. The Space reads HF_TOKEN from its Space secrets, never a file.
|
| 24 |
+
.env
|
| 25 |
+
|
| 26 |
+
# macOS
|
| 27 |
+
.DS_Store
|
Dockerfile
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.12-slim
|
| 2 |
+
|
| 3 |
+
RUN useradd -m -u 1000 user
|
| 4 |
+
USER user
|
| 5 |
+
|
| 6 |
+
ENV HOME=/home/user \
|
| 7 |
+
PATH=/home/user/.local/bin:$PATH
|
| 8 |
+
|
| 9 |
+
WORKDIR $HOME/app
|
| 10 |
+
|
| 11 |
+
RUN pip install --no-cache-dir --upgrade pip
|
| 12 |
+
COPY --chown=user requirements.txt $HOME/app/requirements.txt
|
| 13 |
+
RUN pip install --no-cache-dir -r requirements.txt
|
| 14 |
+
COPY --chown=user . $HOME/app
|
| 15 |
+
|
| 16 |
+
EXPOSE 7860
|
| 17 |
+
ENV GRADIO_SERVER_NAME="0.0.0.0"
|
| 18 |
+
|
| 19 |
+
CMD ["python", "app.py"]
|
README.md
CHANGED
|
@@ -1,12 +1,123 @@
|
|
| 1 |
---
|
| 2 |
title: PLUG Challenge
|
| 3 |
-
emoji:
|
| 4 |
colorFrom: purple
|
| 5 |
colorTo: green
|
| 6 |
-
sdk:
|
|
|
|
| 7 |
pinned: false
|
| 8 |
-
license:
|
| 9 |
-
short_description:
|
| 10 |
---
|
| 11 |
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
title: PLUG Challenge
|
| 3 |
+
emoji: 🧬
|
| 4 |
colorFrom: purple
|
| 5 |
colorTo: green
|
| 6 |
+
sdk: docker
|
| 7 |
+
app_port: 7860
|
| 8 |
pinned: false
|
| 9 |
+
license: apache-2.0
|
| 10 |
+
short_description: Leakage-free protein function prediction, eleven benchmarks
|
| 11 |
---
|
| 12 |
|
| 13 |
+
# PLUG Challenge
|
| 14 |
+
|
| 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 splits. Participants submit predictions for all eleven benchmarks in one
|
| 19 |
+
bundle; the Space validates and scores it on the spot and adds it to the board.
|
| 20 |
+
|
| 21 |
+
This repository **is** the Hugging Face Space
|
| 22 |
+
([PrismScienceOrg/PLUG-challenge](https://huggingface.co/spaces/PrismScienceOrg/PLUG-challenge)) —
|
| 23 |
+
pushing to `main` deploys it. It is structured after
|
| 24 |
+
[OpenADMET's blind-challenge-template](https://github.com/OpenADMET/blind-challenge-template),
|
| 25 |
+
with the template's AWS backend (S3 + scheduled scoring Lambdas + OpenTofu + ECR) replaced
|
| 26 |
+
by Hub dataset repos and synchronous in-Space scoring, which the challenge can do because
|
| 27 |
+
PLUG is not blinded. See [`docs/architecture.md`](docs/architecture.md) for what changed and why.
|
| 28 |
+
|
| 29 |
+
## What participants do
|
| 30 |
+
|
| 31 |
+
```bash
|
| 32 |
+
pip install "plug-challenge @ git+https://huggingface.co/spaces/PrismScienceOrg/PLUG-challenge"
|
| 33 |
+
|
| 34 |
+
plug-challenge template ./my_submission # one CSV per benchmark, ids pre-filled
|
| 35 |
+
# ...fill in the prediction columns...
|
| 36 |
+
cd my_submission && zip ../plug_submission.zip *.csv && cd ..
|
| 37 |
+
plug-challenge validate plug_submission.zip # the exact checks the Space runs
|
| 38 |
+
```
|
| 39 |
+
|
| 40 |
+
Then upload the zip on the Space's **Submit** tab. Scoring is immediate.
|
| 41 |
+
|
| 42 |
+
## Repository structure
|
| 43 |
+
|
| 44 |
+
| Path | Contents |
|
| 45 |
+
|------|----------|
|
| 46 |
+
| `app.py`, `config.py`, `submission.py`, `leaderboards.py`, `models.py`, `utils.py` | The Gradio Space. `config.py` holds every piece of challenge-specific copy and the phase switch |
|
| 47 |
+
| [`plug_challenge/`](plug_challenge/) | The scoring library: benchmark specs, metrics, validation, scoring, aggregation, Hub storage, CLI |
|
| 48 |
+
| [`data/`](data/) | The committed per-benchmark entity lists (`<benchmark>/plug_entities.csv`) — which entity is in which split |
|
| 49 |
+
| [`scripts/`](scripts/) | `build_challenge_data.py`, which turns a local `plug` checkout into the public data and the private labels |
|
| 50 |
+
| [`docs/`](docs/) | Setup runbook, architecture, scoring reference, submission format |
|
| 51 |
+
| [`tests/`](tests/) | pytest suite over the whole pipeline, on synthetic data |
|
| 52 |
+
|
| 53 |
+
`plug_challenge/benchmarks.py` is the single source of truth: the Space's copy, the
|
| 54 |
+
validator, the scorer and the docs are all generated from it, so a benchmark cannot be
|
| 55 |
+
described one way and scored another.
|
| 56 |
+
|
| 57 |
+
## The eleven benchmarks
|
| 58 |
+
|
| 59 |
+
| Benchmark | Scored unit | Primary metric |
|
| 60 |
+
|---|---|---|
|
| 61 |
+
| Megascale ΔΔG | mutation | Spearman's ρ |
|
| 62 |
+
| FireProt ΔΔG | mutation | Spearman's ρ |
|
| 63 |
+
| ProteinGym DMS | variant | Spearman's ρ, per assay |
|
| 64 |
+
| CAFA5 GO | protein | CAFA Fmax, macro over BP/MF/CC |
|
| 65 |
+
| AlloBench sites | residue | AUROC |
|
| 66 |
+
| PASSerRank sites | residue | AUROC |
|
| 67 |
+
| Human PPI | protein pair | AUROC |
|
| 68 |
+
| STRING SHS27k modes | protein pair | Macro AUROC over 7 modes |
|
| 69 |
+
| LP-PDBBind affinity | complex | Spearman's ρ |
|
| 70 |
+
| BindingDB affinity | measurement | Spearman's ρ |
|
| 71 |
+
| ATLAS RMSF | residue | Spearman's ρ |
|
| 72 |
+
|
| 73 |
+
Metric implementations are ported from
|
| 74 |
+
[`plug-baselines`](https://github.com/PrismScienceOrg/plug-baselines) so a leaderboard
|
| 75 |
+
number and a published baseline number are the same arithmetic. The headline **PLUG
|
| 76 |
+
Score** is the mean of the eleven primary metrics after normalising each onto `[0, 1]`
|
| 77 |
+
(a Spearman ρ of 0 and an AUROC of 0.5 both map to 0.5). See
|
| 78 |
+
[`docs/scoring.md`](docs/scoring.md).
|
| 79 |
+
|
| 80 |
+
## Where the data lives
|
| 81 |
+
|
| 82 |
+
| Repo | Visibility | Holds |
|
| 83 |
+
|---|---|---|
|
| 84 |
+
| `PrismScienceOrg/plug-challenge-data` | public | Per benchmark: `entities.parquet`, `sequences.fasta`, labelled `train`/`val`, and an unlabelled `test_manifest` |
|
| 85 |
+
| `PrismScienceOrg/plug-challenge-private` | private | `ground_truth/` (held-back test labels), `submissions/`, `scores/`, `leaderboard/entries.csv` |
|
| 86 |
+
|
| 87 |
+
The test *entities* are public — PLUG publishes its splits and you need them to know what
|
| 88 |
+
to predict — but the test *labels* are not, so a leaderboard number cannot be
|
| 89 |
+
self-reported. This is the one sense in which the challenge is "not blinded": the test
|
| 90 |
+
proteins are known up front.
|
| 91 |
+
|
| 92 |
+
## Running it locally
|
| 93 |
+
|
| 94 |
+
```bash
|
| 95 |
+
uv venv --python 3.12 && uv pip install -e ".[space,dev]"
|
| 96 |
+
pytest tests/ # 80 tests, synthetic data only
|
| 97 |
+
CURRENT_PHASE=1 python app.py # the Space, against whatever repos HF_TOKEN can reach
|
| 98 |
+
```
|
| 99 |
+
|
| 100 |
+
## Deploying
|
| 101 |
+
|
| 102 |
+
```bash
|
| 103 |
+
git push origin main # this repo is the Space; pushing deploys it
|
| 104 |
+
```
|
| 105 |
+
|
| 106 |
+
Space secrets and variables: `HF_TOKEN` (write access to both dataset repos),
|
| 107 |
+
`CURRENT_PHASE`, and optionally `PLUG_PRIVATE_REPO` / `PLUG_PUBLIC_REPO` to point a
|
| 108 |
+
staging Space at throwaway repos. Full walkthrough in [`docs/SETUP.md`](docs/SETUP.md).
|
| 109 |
+
|
| 110 |
+
## Challenge phases
|
| 111 |
+
|
| 112 |
+
`CURRENT_PHASE` gates the Space:
|
| 113 |
+
|
| 114 |
+
| Phase | Submit tab | Leaderboard |
|
| 115 |
+
|---|---|---|
|
| 116 |
+
| `0` pre-challenge | placeholder | placeholder |
|
| 117 |
+
| `1` open | accepting bundles | live, refreshing |
|
| 118 |
+
| `2` closed | closed notice | frozen as the final standings |
|
| 119 |
+
|
| 120 |
+
## License
|
| 121 |
+
|
| 122 |
+
Apache-2.0 for the code here. Every benchmark is redistributed from its original authors
|
| 123 |
+
under its own licence; PLUG contributes the leakage-free splits, not the measurements.
|
app.py
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Gradio app for the PLUG challenge.
|
| 2 |
+
|
| 3 |
+
Four tabs — About, Submit, Leaderboard, FAQ — whose content is gated on
|
| 4 |
+
``config.CURRENT_PHASE``. All challenge-specific copy comes from ``config`` and
|
| 5 |
+
all benchmark facts from ``plug_challenge.benchmarks``; this module only decides
|
| 6 |
+
the layout.
|
| 7 |
+
"""
|
| 8 |
+
|
| 9 |
+
import gradio as gr
|
| 10 |
+
from gradio.themes.utils import sizes
|
| 11 |
+
from loguru import logger
|
| 12 |
+
|
| 13 |
+
from config import (
|
| 14 |
+
ABOUT_MD,
|
| 15 |
+
CHALLENGE_ANNOUNCEMENT_LINK,
|
| 16 |
+
CURRENT_PHASE,
|
| 17 |
+
DATASET_DOWNLOAD_LINK,
|
| 18 |
+
FAQ_MD,
|
| 19 |
+
HEADER_MARKDOWN,
|
| 20 |
+
PAGE_TITLE,
|
| 21 |
+
)
|
| 22 |
+
from leaderboards import render_leaderboards
|
| 23 |
+
from submission import render_submission_tab
|
| 24 |
+
|
| 25 |
+
_TABLE_CSS = """
|
| 26 |
+
<style>
|
| 27 |
+
#welcome-md table, #faq-md table {
|
| 28 |
+
width: 100%;
|
| 29 |
+
border-collapse: collapse;
|
| 30 |
+
margin-top: 20px;
|
| 31 |
+
}
|
| 32 |
+
#welcome-md th, #welcome-md td, #faq-md th, #faq-md td {
|
| 33 |
+
padding: 10px;
|
| 34 |
+
border: 1px solid rgba(0,0,0,0.1);
|
| 35 |
+
}
|
| 36 |
+
#welcome-md thead th, #faq-md thead th {
|
| 37 |
+
background: var(--panel-background-fill, #f5f5f7);
|
| 38 |
+
}
|
| 39 |
+
</style>
|
| 40 |
+
"""
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def _link_button(url: str, label: str, colour: str) -> str:
|
| 44 |
+
"""Render one prominent call-to-action link."""
|
| 45 |
+
return f"""
|
| 46 |
+
<div style="margin: 12px 0 20px 0; text-align: center;">
|
| 47 |
+
<a href="{url}" target="_blank"
|
| 48 |
+
style="display: inline-block; padding: 12px 28px; background: {colour};
|
| 49 |
+
color: #fff; font-size: 1.05rem; font-weight: 600; border-radius: 8px;
|
| 50 |
+
text-decoration: none; box-shadow: 0 2px 8px rgba(0,0,0,0.18);">
|
| 51 |
+
{label}
|
| 52 |
+
</a>
|
| 53 |
+
</div>
|
| 54 |
+
"""
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
with gr.Blocks(
|
| 58 |
+
title=PAGE_TITLE,
|
| 59 |
+
fill_height=False,
|
| 60 |
+
theme=gr.themes.Ocean(text_size=sizes.text_lg),
|
| 61 |
+
) as demo:
|
| 62 |
+
gr.Markdown(HEADER_MARKDOWN)
|
| 63 |
+
gr.HTML(_TABLE_CSS)
|
| 64 |
+
|
| 65 |
+
with gr.Row():
|
| 66 |
+
with gr.Column(scale=1):
|
| 67 |
+
if CHALLENGE_ANNOUNCEMENT_LINK:
|
| 68 |
+
gr.HTML(_link_button(CHALLENGE_ANNOUNCEMENT_LINK, "📄 About PLUG →", "#2563eb"))
|
| 69 |
+
with gr.Column(scale=1):
|
| 70 |
+
# Hidden before the challenge opens: the data is released when submissions do.
|
| 71 |
+
if DATASET_DOWNLOAD_LINK and CURRENT_PHASE >= 1:
|
| 72 |
+
gr.HTML(_link_button(DATASET_DOWNLOAD_LINK, "🗄️ Challenge data →", "#059669"))
|
| 73 |
+
|
| 74 |
+
with gr.Tabs(elem_classes="tab-buttons"):
|
| 75 |
+
with gr.TabItem("📖 About"):
|
| 76 |
+
gr.Markdown(ABOUT_MD, elem_id="welcome-md")
|
| 77 |
+
|
| 78 |
+
with gr.TabItem("✉️ Submit"):
|
| 79 |
+
render_submission_tab(phase=CURRENT_PHASE)
|
| 80 |
+
|
| 81 |
+
with gr.TabItem("🏁 Leaderboard" if CURRENT_PHASE >= 2 else "🏎️ Leaderboard"):
|
| 82 |
+
render_leaderboards(phase=CURRENT_PHASE, demo=demo)
|
| 83 |
+
|
| 84 |
+
with gr.TabItem("🛠️ FAQ"):
|
| 85 |
+
gr.Markdown(FAQ_MD, elem_id="faq-md")
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
if __name__ == "__main__":
|
| 89 |
+
logger.info("Starting the PLUG challenge Gradio app (phase {})...", CURRENT_PHASE)
|
| 90 |
+
demo.launch()
|
config.py
ADDED
|
@@ -0,0 +1,300 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Configuration for the PLUG challenge Hugging Face Space.
|
| 2 |
+
|
| 3 |
+
Everything challenge-specific that is *presentation* lives here: the phase
|
| 4 |
+
switch, the rate limit, the external links, and the page-content markdown. The
|
| 5 |
+
benchmarks themselves — names, schemas, metrics, which file goes in the bundle —
|
| 6 |
+
come from ``plug_challenge.benchmarks``, which both this Space and the scorer
|
| 7 |
+
import, so the Space can never describe a benchmark differently from how it is
|
| 8 |
+
scored.
|
| 9 |
+
|
| 10 |
+
Work through every ``TODO`` before opening the challenge.
|
| 11 |
+
"""
|
| 12 |
+
|
| 13 |
+
import os
|
| 14 |
+
|
| 15 |
+
from plug_challenge.benchmarks import BENCHMARKS, GO_ASPECTS, ID_COLUMN, SHS27K_MODES
|
| 16 |
+
from plug_challenge.store import PRIVATE_REPO, PUBLIC_REPO
|
| 17 |
+
|
| 18 |
+
# ------------------------------- Challenge state --------------------------------------
|
| 19 |
+
|
| 20 |
+
# Updated manually to control what the Space shows.
|
| 21 |
+
# 0: Pre-challenge — leaderboard and submission portal show placeholders
|
| 22 |
+
# 1: Open — submissions accepted, live leaderboard
|
| 23 |
+
# 2: Closed — submissions rejected, leaderboard frozen as the final standings
|
| 24 |
+
CURRENT_PHASE = int(os.environ.get("CURRENT_PHASE", "0"))
|
| 25 |
+
|
| 26 |
+
# Minimum gap between two submissions from one Hugging Face account. PLUG scores
|
| 27 |
+
# synchronously against held-back labels, so without a cooldown a participant
|
| 28 |
+
# could tune against the test set by resubmitting in a loop.
|
| 29 |
+
HOURS_BETWEEN_SUBMISSIONS = 12
|
| 30 |
+
|
| 31 |
+
# Bootstrap resamples used for the per-metric standard deviation shown on the
|
| 32 |
+
# leaderboard. Scoring runs inside the submission request, so this is 0 (point
|
| 33 |
+
# estimates only) by default; the organisers' `plug-challenge score --bootstrap`
|
| 34 |
+
# computes intervals offline. cafa5's Fmax never bootstraps — see scoring.py.
|
| 35 |
+
BOOTSTRAP_SAMPLES = int(os.environ.get("BOOTSTRAP_SAMPLES", "0"))
|
| 36 |
+
|
| 37 |
+
# A bundle must carry all eleven benchmark files. Set False to accept partial
|
| 38 |
+
# bundles (they are then ranked on the PLUG Score of what they did cover, with
|
| 39 |
+
# `benchmarks_scored` showing the difference).
|
| 40 |
+
REQUIRE_COMPLETE_BUNDLE = True
|
| 41 |
+
|
| 42 |
+
# ------------------------------- Links ------------------------------------------------
|
| 43 |
+
|
| 44 |
+
# TODO: point these at the real pages before announcing the challenge.
|
| 45 |
+
CHALLENGE_ANNOUNCEMENT_LINK = "https://github.com/PrismScienceOrg/plug"
|
| 46 |
+
DATASET_DOWNLOAD_LINK = f"https://huggingface.co/datasets/{PUBLIC_REPO}"
|
| 47 |
+
TUTORIAL_LINK = "https://github.com/PrismScienceOrg/plug-baselines"
|
| 48 |
+
PLUG_REPO_LINK = "https://github.com/PrismScienceOrg/plug"
|
| 49 |
+
# TODO: set to your Discord/Slack invite, or set to "" to drop every mention of it.
|
| 50 |
+
COMMUNITY_LINK = ""
|
| 51 |
+
|
| 52 |
+
PAGE_TITLE = "PLUG Challenge"
|
| 53 |
+
|
| 54 |
+
# ------------------------------- Derived benchmark copy -------------------------------
|
| 55 |
+
|
| 56 |
+
BENCHMARK_COUNT = len(BENCHMARKS)
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
def _benchmark_table_md() -> str:
|
| 60 |
+
"""Build the benchmark overview table from the specs."""
|
| 61 |
+
rows = [
|
| 62 |
+
"| Benchmark | Scored unit | Primary metric | Submission file |",
|
| 63 |
+
"| :--- | :--- | :--- | :--- |",
|
| 64 |
+
]
|
| 65 |
+
for spec in BENCHMARKS:
|
| 66 |
+
rows.append(
|
| 67 |
+
f"| **{spec.label}** | one {spec.unit} | {spec.primary.label} | "
|
| 68 |
+
f"`{spec.filename}` |"
|
| 69 |
+
)
|
| 70 |
+
return "\n".join(rows)
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
def _schema_table_md(spec) -> str:
|
| 74 |
+
"""Build one benchmark's submission column table."""
|
| 75 |
+
rows = [
|
| 76 |
+
"| Column | Type | Description |",
|
| 77 |
+
"| :--- | :--- | :--- |",
|
| 78 |
+
f"| `{ID_COLUMN}` | string | The row's id, copied from the test manifest |",
|
| 79 |
+
]
|
| 80 |
+
if spec.long_form:
|
| 81 |
+
rows.append("| `aspect` | string | GO branch: `bp`, `mf` or `cc` |")
|
| 82 |
+
rows.append("| `term` | string | The GO term you are predicting, e.g. `GO:0005515` |")
|
| 83 |
+
for column in spec.pred_columns:
|
| 84 |
+
bound = (
|
| 85 |
+
f" in [{spec.score_range[0]}, {spec.score_range[1]}]"
|
| 86 |
+
if spec.score_range
|
| 87 |
+
else ""
|
| 88 |
+
)
|
| 89 |
+
rows.append(f"| `{column}` | float | Your prediction{bound} |")
|
| 90 |
+
return "\n".join(rows)
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
BENCHMARK_TABLE_MD = _benchmark_table_md()
|
| 94 |
+
|
| 95 |
+
SUBMISSION_SCHEMAS_MD = "\n\n".join(
|
| 96 |
+
f"##### `{spec.filename}` — {spec.label}\n\n{spec.description}\n\n{_schema_table_md(spec)}"
|
| 97 |
+
for spec in BENCHMARKS
|
| 98 |
+
)
|
| 99 |
+
|
| 100 |
+
BUNDLE_TREE_MD = "\n".join(
|
| 101 |
+
["```", "plug_submission.zip", *[f"├── {spec.filename}" for spec in BENCHMARKS[:-1]],
|
| 102 |
+
f"└── {BENCHMARKS[-1].filename}", "```"]
|
| 103 |
+
)
|
| 104 |
+
|
| 105 |
+
# ------------------------------- Page content -----------------------------------------
|
| 106 |
+
|
| 107 |
+
HEADER_MARKDOWN = f"""## PLUG Challenge 🧬
|
| 108 |
+
**Protein Leakage-free evaluation for Unbiased Generators of function.**
|
| 109 |
+
|
| 110 |
+
Conventional protein benchmarks let the same protein appear in train and in test,
|
| 111 |
+
which inflates apparent performance. PLUG rebuilds {BENCHMARK_COUNT} protein-function
|
| 112 |
+
benchmarks with splits where that is impossible by construction: similar entities are
|
| 113 |
+
fused into indivisible groups and whole groups are assigned to a split, so no test
|
| 114 |
+
protein has a homolog in training.
|
| 115 |
+
|
| 116 |
+
This challenge asks one question across all {BENCHMARK_COUNT} benchmarks at once: **how
|
| 117 |
+
well does your model predict protein function when it has never seen anything like the
|
| 118 |
+
test proteins?**
|
| 119 |
+
|
| 120 |
+
Go to the **Leaderboard** for the current standings, or the **Submit** tab to enter.
|
| 121 |
+
The test entities are public; their labels are held back, so every number on the
|
| 122 |
+
leaderboard was computed here rather than self-reported.
|
| 123 |
+
|
| 124 |
+
<!-- TODO: replace with the real dates. -->
|
| 125 |
+
**Timeline**: submissions open <DATE> · submissions close <DATE> · final standings <DATE>.
|
| 126 |
+
"""
|
| 127 |
+
|
| 128 |
+
HOW_TO_PARTICIPATE_MD = f"""## ✅ How to participate
|
| 129 |
+
|
| 130 |
+
1. **Get the data.** Download the [challenge dataset]({DATASET_DOWNLOAD_LINK}): per benchmark,
|
| 131 |
+
a labelled `train` and `val` split, an unlabelled `test_manifest`, and the sequences.
|
| 132 |
+
2. **Build your model.** Anything goes — pretrained weights, external data, ensembles.
|
| 133 |
+
The [PLUG baselines]({TUTORIAL_LINK}) give you zero-shot, linear-probe and fine-tuned
|
| 134 |
+
ESM-C reference numbers to beat.
|
| 135 |
+
3. **Make a bundle.** One file per benchmark, zipped. `plug-challenge template ./out`
|
| 136 |
+
writes the skeleton with the right ids already in place.
|
| 137 |
+
4. **Validate it locally.** `plug-challenge validate plug_submission.zip` runs exactly the
|
| 138 |
+
checks this Space runs, so you find problems before uploading.
|
| 139 |
+
5. **Submit.** Upload the zip on the **Submit** tab. Scoring is immediate — you get your
|
| 140 |
+
{BENCHMARK_COUNT} metrics and your PLUG Score back in the response.
|
| 141 |
+
6. **Disclose.** Flag proprietary training data, and link a method report. Both are shown
|
| 142 |
+
on the leaderboard.
|
| 143 |
+
|
| 144 |
+
---"""
|
| 145 |
+
|
| 146 |
+
ABOUT_MD = f"""
|
| 147 |
+
# The PLUG Challenge
|
| 148 |
+
|
| 149 |
+
## Why leakage-free splits
|
| 150 |
+
|
| 151 |
+
The claim PLUG tests is that conventional benchmark splits inflate apparent performance
|
| 152 |
+
because the same protein appears in train and in test. A random split of *measurements*
|
| 153 |
+
leaks by design; similarity-penalising splitters make leakage merely unlikely. PLUG makes
|
| 154 |
+
it impossible: entities that are too alike are fused into indivisible groups, and a solver
|
| 155 |
+
assigns whole groups to train/val/test while maximising how many datapoints survive. A
|
| 156 |
+
datapoint is kept only when everything it is about agrees on a split — both partners of an
|
| 157 |
+
interaction, or the protein *and* the ligand of an affinity measurement.
|
| 158 |
+
|
| 159 |
+
The default rule drops a candidate that looks like any test protein by sequence (MMseqs2,
|
| 160 |
+
>80% coverage at >30% identity, run bidirectionally so subdomains are caught), by structure
|
| 161 |
+
(Foldseek TM-score >0.5), or by either view for the benchmarks that have both. See the
|
| 162 |
+
[PLUG repository]({PLUG_REPO_LINK}) for the method and the thresholds.
|
| 163 |
+
|
| 164 |
+
---
|
| 165 |
+
|
| 166 |
+
## The {BENCHMARK_COUNT} benchmarks
|
| 167 |
+
|
| 168 |
+
Each contributes one file to your submission bundle and gets its own leaderboard tab.
|
| 169 |
+
|
| 170 |
+
{BENCHMARK_TABLE_MD}
|
| 171 |
+
|
| 172 |
+
Every residue number in every benchmark — mutation positions, allosteric sites — counts
|
| 173 |
+
along that benchmark's own `sequence`, starting at 1, and every per-residue vector is
|
| 174 |
+
exactly as long as the sequence beside it.
|
| 175 |
+
|
| 176 |
+
---
|
| 177 |
+
|
| 178 |
+
## Scoring
|
| 179 |
+
|
| 180 |
+
Each benchmark is scored with the metric its own literature uses, computed by the same
|
| 181 |
+
code as the [PLUG baselines]({TUTORIAL_LINK}) so a leaderboard number and a published
|
| 182 |
+
baseline number mean the same thing:
|
| 183 |
+
|
| 184 |
+
- **Rank correlation** (Spearman's ρ) for the ΔΔG, DMS fitness, affinity and RMSF
|
| 185 |
+
benchmarks. DMS is scored *per assay* and averaged, because assay scores share no
|
| 186 |
+
common scale.
|
| 187 |
+
- **AUROC** for the PPI and allosteric-site benchmarks, and **macro AUROC** over the
|
| 188 |
+
seven STRING modes for SHS27k.
|
| 189 |
+
- **CAFA target-centric Fmax**, per GO branch and macro-averaged, for CAFA5.
|
| 190 |
+
|
| 191 |
+
### The PLUG Score
|
| 192 |
+
|
| 193 |
+
The headline number. Each benchmark's primary metric is normalised onto `[0, 1]` — a
|
| 194 |
+
Spearman ρ of 0 and an AUROC of 0.5 both land at 0.5, so chance performance is worth the
|
| 195 |
+
same everywhere — and the PLUG Score is their mean. It depends only on your own
|
| 196 |
+
predictions, so it does not move as other entries arrive and is safe to quote. `Mean rank`
|
| 197 |
+
is shown beside it as the relative view.
|
| 198 |
+
|
| 199 |
+
---
|
| 200 |
+
|
| 201 |
+
{HOW_TO_PARTICIPATE_MD if CURRENT_PHASE == 1 else ""}
|
| 202 |
+
|
| 203 |
+
## 📅 Timeline
|
| 204 |
+
|
| 205 |
+
*All deadlines are 23:59 UTC.*
|
| 206 |
+
|
| 207 |
+
<!-- TODO: replace with the real dates. -->
|
| 208 |
+
| Date | Action |
|
| 209 |
+
|:--- |:--- |
|
| 210 |
+
| **<DATE>** | Challenge announced |
|
| 211 |
+
| **<DATE>** | Data released; submissions open 🚀 |
|
| 212 |
+
| **<DATE>** | Submissions close 🏁 |
|
| 213 |
+
| **<DATE>** | Final standings and write-up |
|
| 214 |
+
|
| 215 |
+
---
|
| 216 |
+
|
| 217 |
+
## Acknowledgements
|
| 218 |
+
<!-- TODO: name the benchmark authors, contributors and funders. -->
|
| 219 |
+
Every benchmark here is redistributed from its original authors under its own licence;
|
| 220 |
+
PLUG contributes the leakage-free splits, not the measurements.
|
| 221 |
+
"""
|
| 222 |
+
|
| 223 |
+
_COMPLETENESS_ANSWER = (
|
| 224 |
+
f"Yes — a bundle must carry all {BENCHMARK_COUNT} files. This keeps the PLUG Score "
|
| 225 |
+
"an apples-to-apples comparison between complete methods."
|
| 226 |
+
if REQUIRE_COMPLETE_BUNDLE
|
| 227 |
+
else "No — missing benchmarks are left unscored, and `benchmarks_scored` on the "
|
| 228 |
+
"leaderboard shows how many you covered."
|
| 229 |
+
)
|
| 230 |
+
|
| 231 |
+
FAQ_MD = f"""
|
| 232 |
+
### Frequently asked questions
|
| 233 |
+
|
| 234 |
+
**What am I predicting?**
|
| 235 |
+
All {BENCHMARK_COUNT} benchmarks at once. One submission is a single `.zip` with one file
|
| 236 |
+
per benchmark; each file predicts every row in that benchmark's test manifest.
|
| 237 |
+
|
| 238 |
+
**Do I have to enter every benchmark?**
|
| 239 |
+
{_COMPLETENESS_ANSWER}
|
| 240 |
+
|
| 241 |
+
**Is the test set blinded?**
|
| 242 |
+
No. The test *entities* are public — PLUG publishes its splits, and you need them to know
|
| 243 |
+
what to predict. The test *labels* are held back in a private repo that only this Space
|
| 244 |
+
reads, so a leaderboard number cannot be self-reported.
|
| 245 |
+
|
| 246 |
+
**Can I use external data, pretrained models, or structures?**
|
| 247 |
+
Yes, all of it. That is the point: the split, not the training data, is what PLUG
|
| 248 |
+
controls. Flag proprietary (non-publicly-available) training data at submission time — it
|
| 249 |
+
is shown on the leaderboard.
|
| 250 |
+
|
| 251 |
+
**Then what stops me fitting the test set by resubmitting?**
|
| 252 |
+
The cooldown: at most one submission every {HOURS_BETWEEN_SUBMISSIONS} hours per account,
|
| 253 |
+
and only your latest submission is ranked. Please validate locally
|
| 254 |
+
(`plug-challenge validate`) rather than using uploads as a syntax check.
|
| 255 |
+
|
| 256 |
+
**I want to enter with colleagues.**
|
| 257 |
+
Submit under one Hugging Face account representing the lab or team. Multiple accounts for
|
| 258 |
+
one team are not permitted.
|
| 259 |
+
|
| 260 |
+
**How is the overall ranking computed?**
|
| 261 |
+
Mean of the {BENCHMARK_COUNT} normalised primary metrics — the PLUG Score. See
|
| 262 |
+
**About → Scoring**.
|
| 263 |
+
|
| 264 |
+
**Why is my Spearman/AUROC blank for a benchmark?**
|
| 265 |
+
A rank metric is undefined when a prediction column is constant, or when a group has one
|
| 266 |
+
member. Constant columns are rejected at validation for those benchmarks, so a blank cell
|
| 267 |
+
means that benchmark had no scorable group.
|
| 268 |
+
|
| 269 |
+
**What exactly does a submission file look like?**
|
| 270 |
+
|
| 271 |
+
Your bundle:
|
| 272 |
+
|
| 273 |
+
{BUNDLE_TREE_MD}
|
| 274 |
+
|
| 275 |
+
Each file may be `.csv` or `.parquet`. Every file needs the `{ID_COLUMN}` column copied
|
| 276 |
+
from that benchmark's test manifest, plus its prediction columns:
|
| 277 |
+
|
| 278 |
+
{SUBMISSION_SCHEMAS_MD}
|
| 279 |
+
|
| 280 |
+
*Rules:*
|
| 281 |
+
1. One row per test {ID_COLUMN} — no duplicates, nothing outside the test split.
|
| 282 |
+
(`cafa5.csv` is the exception: one row per predicted GO term, so proteins you decline
|
| 283 |
+
to annotate are simply absent.)
|
| 284 |
+
2. Column names are case-sensitive.
|
| 285 |
+
3. Predictions must be finite numbers — no `NaN`, no `inf`, no blanks.
|
| 286 |
+
4. A constant prediction column is rejected for the ten rank-scored benchmarks — Spearman
|
| 287 |
+
and AUROC are undefined without variance. `cafa5` is exempt: Fmax sweeps a confidence
|
| 288 |
+
threshold, so predicting every term at `1.0` is a legitimate submission.
|
| 289 |
+
5. `shs27k.csv` needs all seven mode columns: {", ".join(f"`pred_{m}`" for m in SHS27K_MODES)}.
|
| 290 |
+
6. `cafa5.csv` needs an `aspect` of {", ".join(f"`{a}`" for a in GO_ASPECTS)} and a `score`
|
| 291 |
+
in `[0, 1]`.
|
| 292 |
+
|
| 293 |
+
**Where do the scores and submissions live?**
|
| 294 |
+
Bundles, scores and the leaderboard are in the private `{PRIVATE_REPO}` dataset; the
|
| 295 |
+
participant-facing data is the public `{PUBLIC_REPO}` dataset.
|
| 296 |
+
|
| 297 |
+
**My submission failed validation.**
|
| 298 |
+
The error message names the benchmark and the problem for every file at once. Run
|
| 299 |
+
`plug-challenge validate` locally on the same zip to iterate quickly.
|
| 300 |
+
"""
|
data/README.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Entity lists
|
| 2 |
+
|
| 3 |
+
One directory per benchmark, each holding `plug_entities.csv`:
|
| 4 |
+
|
| 5 |
+
```csv
|
| 6 |
+
entity,split
|
| 7 |
+
1A32,train
|
| 8 |
+
1AOY,val
|
| 9 |
+
```
|
| 10 |
+
|
| 11 |
+
An **entity** is what PLUG's leakage-free split is decided over — a protein, a PDB chain,
|
| 12 |
+
a DMS assay, a ligand. A **datapoint** is one scored row (a mutation, a residue, a pair, a
|
| 13 |
+
measurement); many datapoints belong to one entity. Entities are the unit here because
|
| 14 |
+
that is the unit the split is decided over: similar entities are fused into indivisible
|
| 15 |
+
groups and whole groups are assigned to a split, so a datapoint survives only when
|
| 16 |
+
everything it is about agrees on one.
|
| 17 |
+
|
| 18 |
+
These files are **verbatim copies** of `plug`'s split files
|
| 19 |
+
(`data/splits/<benchmark>__<thresholds>.csv` in the
|
| 20 |
+
[plug repository](https://github.com/PrismScienceOrg/plug)), committed here so this
|
| 21 |
+
repository records which entity was in which split independently of a `plug` checkout.
|
| 22 |
+
They carry no labels and no sequences.
|
| 23 |
+
|
| 24 |
+
Refresh them with `scripts/build_challenge_data.py`, which copies them as a side effect of
|
| 25 |
+
building the challenge data. The source filename encodes the thresholds the split was
|
| 26 |
+
built at (`id30_cov80`, plus `_tm60` where structure leakage applies and `_tan50` where
|
| 27 |
+
ligand similarity does), and the script resolves it through plug's own helper rather than
|
| 28 |
+
hardcoding it — so re-running after a threshold change picks up the right file.
|
| 29 |
+
|
| 30 |
+
## Why a copy and not a re-derivation
|
| 31 |
+
|
| 32 |
+
These list every entity **the solver placed**. The `entities.parquet` files in the public
|
| 33 |
+
data repo list only the entities that still have a surviving datapoint. The two differ
|
| 34 |
+
wherever a datapoint can straddle: a PPI pair whose two partners landed in different
|
| 35 |
+
splits is dropped, but both partners were still assigned a split. For `ppi` that is the
|
| 36 |
+
difference between 11,019 entities here and 9,646 with surviving pairs.
|
| 37 |
+
|
| 38 |
+
This file is the record of the split itself, so it has to be the solver's answer. The
|
| 39 |
+
downstream view belongs with the data participants actually download.
|
| 40 |
+
|
| 41 |
+
Note that for the two ligand benchmarks (`lp-pdbbind`, `bindingdb`) the entity column
|
| 42 |
+
mixes proteins and ligands, since both are split over — which is also why those two files
|
| 43 |
+
are the large ones, `bindingdb`'s entity key being the target's full sequence.
|
| 44 |
+
|
| 45 |
+
## What participants download
|
| 46 |
+
|
| 47 |
+
Not this. The predict-against artefacts live in the public dataset repo
|
| 48 |
+
[`PrismScienceOrg/plug-challenge-data`](https://huggingface.co/datasets/PrismScienceOrg/plug-challenge-data):
|
| 49 |
+
per benchmark, an `entities.parquet` (entity → sequence), a `sequences.fasta`, labelled
|
| 50 |
+
`train.parquet` / `val.parquet`, and the unlabelled `test_manifest.parquet` that a
|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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
entity,split
|
| 2 |
+
16pk_A,train
|
| 3 |
+
1a62_A,test
|
| 4 |
+
1ab1_A,train
|
| 5 |
+
1af7_A,train
|
| 6 |
+
1ah7_A,train
|
| 7 |
+
1ail_A,train
|
| 8 |
+
1aol_A,test
|
| 9 |
+
1b0n_A,train
|
| 10 |
+
1b25_D,train
|
| 11 |
+
1b2s_E,train
|
| 12 |
+
1b2s_F,train
|
| 13 |
+
1b8d_K,train
|
| 14 |
+
1bgf_A,train
|
| 15 |
+
1bkp_A,train
|
| 16 |
+
1bq8_A,test
|
| 17 |
+
1btk_A,train
|
| 18 |
+
1bx7_A,test
|
| 19 |
+
1bxy_A,train
|
| 20 |
+
1bxy_B,train
|
| 21 |
+
1by2_A,test
|
| 22 |
+
1c1k_A,train
|
| 23 |
+
1c52_A,test
|
| 24 |
+
1c96_A,train
|
| 25 |
+
1chd_A,train
|
| 26 |
+
1cm3_A,train
|
| 27 |
+
1coj_A,train
|
| 28 |
+
1cpq_A,train
|
| 29 |
+
1ctf_A,train
|
| 30 |
+
1cuo_A,test
|
| 31 |
+
1cvr_A,train
|
| 32 |
+
1d2t_A,train
|
| 33 |
+
1d3y_A,test
|
| 34 |
+
1d3y_B,test
|
| 35 |
+
1d4t_A,train
|
| 36 |
+
1dci_C,train
|
| 37 |
+
1dd3_A,train
|
| 38 |
+
1dd3_B,train
|
| 39 |
+
1dfu_P,test
|
| 40 |
+
1dj0_B,train
|
| 41 |
+
1dk8_A,train
|
| 42 |
+
1dlj_A,train
|
| 43 |
+
1doi_A,test
|
| 44 |
+
1dow_A,train
|
| 45 |
+
1dpt_A,test
|
| 46 |
+
1dtd_B,train
|
| 47 |
+
1dvo_A,train
|
| 48 |
+
1dwk_A,train
|
| 49 |
+
1dzf_A,train
|
| 50 |
+
1e6y_D,train
|
| 51 |
+
1e7l_B,train
|
| 52 |
+
1ear_A,train
|
| 53 |
+
1eb0_A,train
|
| 54 |
+
1ef1_C,train
|
| 55 |
+
1ef1_D,train
|
| 56 |
+
1egw_B,train
|
| 57 |
+
1egw_C,train
|
| 58 |
+
1enj_A,train
|
| 59 |
+
1esw_A,train
|
| 60 |
+
1ewf_A,train
|
| 61 |
+
1ez3_B,train
|
| 62 |
+
1f20_A,train
|
| 63 |
+
1f3u_E,train
|
| 64 |
+
1f3u_G,train
|
| 65 |
+
1f5n_A,train
|
| 66 |
+
1f9p_A,train
|
| 67 |
+
1fcz_A,train
|
| 68 |
+
1fd3_A,train
|
| 69 |
+
1feh_A,train
|
| 70 |
+
1fk5_A,train
|
| 71 |
+
1fm4_A,train
|
| 72 |
+
1fn9_A,train
|
| 73 |
+
1fn9_B,train
|
| 74 |
+
1fqi_A,train
|
| 75 |
+
1fs1_A,train
|
| 76 |
+
1fs1_C,train
|
| 77 |
+
1fx4_A,train
|
| 78 |
+
1fxo_G,val
|
| 79 |
+
1g2r_A,train
|
| 80 |
+
1g38_A,val
|
| 81 |
+
1g38_D,val
|
| 82 |
+
1g6g_A,train
|
| 83 |
+
1g7s_A,val
|
| 84 |
+
1g7t_A,val
|
| 85 |
+
1g81_A,val
|
| 86 |
+
1g9g_A,train
|
| 87 |
+
1gnt_A,train
|
| 88 |
+
1gpj_A,train
|
| 89 |
+
1gqe_A,train
|
| 90 |
+
1gqv_A,val
|
| 91 |
+
1gte_D,train
|
| 92 |
+
1gwe_A,train
|
| 93 |
+
1h02_B,train
|
| 94 |
+
1h16_A,train
|
| 95 |
+
1h17_A,train
|
| 96 |
+
1h2e_A,val
|
| 97 |
+
1h8e_G,train
|
| 98 |
+
1h99_A,train
|
| 99 |
+
1hbn_E,train
|
| 100 |
+
1hc9_B,train
|
| 101 |
+
1hoe_A,train
|
| 102 |
+
1hp1_A,train
|
| 103 |
+
1hq0_A,train
|
| 104 |
+
1huf_A,train
|
| 105 |
+
1hw1_B,train
|
| 106 |
+
1hye_A,train
|
| 107 |
+
1i0v_A,train
|
| 108 |
+
1i2t_A,train
|
| 109 |
+
1i4m_A,train
|
| 110 |
+
1ifg_A,val
|
| 111 |
+
1ig0_B,train
|
| 112 |
+
1ig3_A,train
|
| 113 |
+
1ijt_A,val
|
| 114 |
+
1ijx_C,test
|
| 115 |
+
1ikp_A,train
|
| 116 |
+
1ikt_A,train
|
| 117 |
+
1im5_A,train
|
| 118 |
+
1io1_A,train
|
| 119 |
+
1iom_A,train
|
| 120 |
+
1iqq_A,val
|
| 121 |
+
1iuq_A,train
|
| 122 |
+
1ix9_A,train
|
| 123 |
+
1j09_A,train
|
| 124 |
+
1j0p_A,train
|
| 125 |
+
1j2l_A,train
|
| 126 |
+
1j5u_A,val
|
| 127 |
+
1j77_A,train
|
| 128 |
+
1j8e_A,train
|
| 129 |
+
1j8r_A,test
|
| 130 |
+
1jhs_A,train
|
| 131 |
+
1jif_A,train
|
| 132 |
+
1jke_C,train
|
| 133 |
+
1jmx_G,val
|
| 134 |
+
1jnr_C,train
|
| 135 |
+
1jo0_A,train
|
| 136 |
+
1jq5_A,train
|
| 137 |
+
1juv_A,train
|
| 138 |
+
1jwq_A,train
|
| 139 |
+
1jyo_B,train
|
| 140 |
+
1jyo_E,train
|
| 141 |
+
1jyo_F,train
|
| 142 |
+
1k30_A,train
|
| 143 |
+
1k5n_A,train
|
| 144 |
+
1k7c_A,train
|
| 145 |
+
1k7j_A,train
|
| 146 |
+
1k8k_E,train
|
| 147 |
+
1ka1_A,train
|
| 148 |
+
1kew_A,train
|
| 149 |
+
1kgq_A,test
|
| 150 |
+
1knt_A,val
|
| 151 |
+
1koe_A,train
|
| 152 |
+
1kop_A,train
|
| 153 |
+
1kp3_A,train
|
| 154 |
+
1kpt_A,train
|
| 155 |
+
1krn_A,test
|
| 156 |
+
1l2p_A,train
|
| 157 |
+
1l2w_I,test
|
| 158 |
+
1l2w_J,test
|
| 159 |
+
1l5o_A,train
|
| 160 |
+
1l9l_A,train
|
| 161 |
+
1lc3_A,train
|
| 162 |
+
1lfp_A,train
|
| 163 |
+
1lj5_A,train
|
| 164 |
+
1llf_B,train
|
| 165 |
+
1lln_A,train
|
| 166 |
+
1lr0_A,train
|
| 167 |
+
1lri_A,train
|
| 168 |
+
1ls1_A,train
|
| 169 |
+
1lsl_A,train
|
| 170 |
+
1lwb_A,train
|
| 171 |
+
1lwd_B,train
|
| 172 |
+
1m15_A,train
|
| 173 |
+
1m5q_I,train
|
| 174 |
+
1m5q_Z,train
|
| 175 |
+
1m7v_A,train
|
| 176 |
+
1m8s_A,test
|
| 177 |
+
1m9z_A,train
|
| 178 |
+
1md6_A,val
|
| 179 |
+
1mix_A,train
|
| 180 |
+
1mjf_B,train
|
| 181 |
+
1mk0_A,val
|
| 182 |
+
1mlw_A,train
|
| 183 |
+
1msc_A,train
|
| 184 |
+
1msk_A,train
|
| 185 |
+
1mv8_C,train
|
| 186 |
+
1n2m_A,train
|
| 187 |
+
1n7z_A,test
|
| 188 |
+
1n7z_B,test
|
| 189 |
+
1n8o_E,val
|
| 190 |
+
1n8u_A,train
|
| 191 |
+
1n8v_B,train
|
| 192 |
+
1nf8_A,train
|
| 193 |
+
1ng6_A,train
|
| 194 |
+
1nh2_B,train
|
| 195 |
+
1nij_A,train
|
| 196 |
+
1njh_A,val
|
| 197 |
+
1nkp_D,train
|
| 198 |
+
1nl1_A,test
|
| 199 |
+
1nnh_A,train
|
| 200 |
+
1nns_A,train
|
| 201 |
+
1ntv_A,train
|
| 202 |
+
1nty_A,train
|
| 203 |
+
1o0s_A,train
|
| 204 |
+
1o1x_A,train
|
| 205 |
+
1o4k_A,train
|
| 206 |
+
1o75_A,test
|
| 207 |
+
1o98_A,train
|
| 208 |
+
1oao_C,train
|
| 209 |
+
1ocy_A,val
|
| 210 |
+
1oh9_A,train
|
| 211 |
+
1ois_A,train
|
| 212 |
+
1ojh_C,train
|
| 213 |
+
1ojh_D,train
|
| 214 |
+
1ojq_A,val
|
| 215 |
+
1ok0_A,train
|
| 216 |
+
1ouw_C,train
|
| 217 |
+
1p27_C,train
|
| 218 |
+
1p5g_X,train
|
| 219 |
+
1pby_C,val
|
| 220 |
+
1pcf_C,train
|
| 221 |
+
1pch_A,train
|
| 222 |
+
1pdo_A,train
|
| 223 |
+
1pp0_C,train
|
| 224 |
+
1ptq_A,train
|
| 225 |
+
1puc_A,train
|
| 226 |
+
1pv5_A,train
|
| 227 |
+
1q0q_A,train
|
| 228 |
+
1q2h_A,train
|
| 229 |
+
1q74_C,train
|
| 230 |
+
1q7e_A,train
|
| 231 |
+
1q8f_A,train
|
| 232 |
+
1qau_A,train
|
| 233 |
+
1qb7_A,train
|
| 234 |
+
1qcs_A,test
|
| 235 |
+
1qdd_A,val
|
| 236 |
+
1qgi_A,train
|
| 237 |
+
1qhv_A,test
|
| 238 |
+
1ql0_B,train
|
| 239 |
+
1qlm_A,train
|
| 240 |
+
1qnx_A,val
|
| 241 |
+
1qw2_A,test
|
| 242 |
+
1qwz_A,test
|
| 243 |
+
1qxo_A,train
|
| 244 |
+
1qxo_B,train
|
| 245 |
+
1qxy_A,train
|
| 246 |
+
1qz4_A,train
|
| 247 |
+
1r0k_A,train
|
| 248 |
+
1r5l_A,train
|
| 249 |
+
1r6l_A,train
|
| 250 |
+
1r6w_A,train
|
| 251 |
+
1r8m_E,train
|
| 252 |
+
1r9f_A,train
|
| 253 |
+
1rgz_A,train
|
| 254 |
+
1rk8_B,train
|
| 255 |
+
1rl6_A,train
|
| 256 |
+
1rlk_A,train
|
| 257 |
+
1rm6_B,train
|
| 258 |
+
1rpo_A,train
|
| 259 |
+
1rqj_A,train
|
| 260 |
+
1rrm_A,train
|
| 261 |
+
1rss_A,val
|
| 262 |
+
1ru4_A,train
|
| 263 |
+
1ryl_A,train
|
| 264 |
+
1s2o_A,train
|
| 265 |
+
1s9r_A,train
|
| 266 |
+
1s9u_A,train
|
| 267 |
+
1sdi_A,train
|
| 268 |
+
1sei_A,train
|
| 269 |
+
1sei_B,train
|
| 270 |
+
1sf9_A,train
|
| 271 |
+
1skz_A,test
|
| 272 |
+
1ssq_D,train
|
| 273 |
+
1svb_A,train
|
| 274 |
+
1sx3_A,train
|
| 275 |
+
1sx3_B,train
|
| 276 |
+
1t61_E,train
|
| 277 |
+
1t7v_A,train
|
| 278 |
+
1t8h_A,train
|
| 279 |
+
1t8k_A,train
|
| 280 |
+
1t95_A,train
|
| 281 |
+
1t9i_B,train
|
| 282 |
+
1tag_A,train
|
| 283 |
+
1tdz_A,test
|
| 284 |
+
1tez_B,train
|
| 285 |
+
1tg7_A,train
|
| 286 |
+
1tgr_A,train
|
| 287 |
+
1thm_A,train
|
| 288 |
+
1tov_A,test
|
| 289 |
+
1tt8_A,val
|
| 290 |
+
1tuk_A,train
|
| 291 |
+
1tzv_A,train
|
| 292 |
+
1tzw_A,train
|
| 293 |
+
1u07_A,train
|
| 294 |
+
1u09_A,train
|
| 295 |
+
1u55_A,train
|
| 296 |
+
1u6r_B,train
|
| 297 |
+
1u6t_A,test
|
| 298 |
+
1u7k_D,train
|
| 299 |
+
1u84_A,train
|
| 300 |
+
1u8v_C,train
|
| 301 |
+
1ugp_A,test
|
| 302 |
+
1ugp_B,test
|
| 303 |
+
1uha_A,val
|
| 304 |
+
1uoy_A,train
|
| 305 |
+
1upt_B,train
|
| 306 |
+
1upt_D,train
|
| 307 |
+
1usm_A,train
|
| 308 |
+
1utg_A,train
|
| 309 |
+
1uwk_B,train
|
| 310 |
+
1ux6_A,train
|
| 311 |
+
1uxy_A,train
|
| 312 |
+
1uz3_A,train
|
| 313 |
+
1uz3_B,train
|
| 314 |
+
1uzp_A,train
|
| 315 |
+
1v0w_A,test
|
| 316 |
+
1v1h_C,test
|
| 317 |
+
1v2z_A,train
|
| 318 |
+
1v30_A,val
|
| 319 |
+
1v4p_C,test
|
| 320 |
+
1v7r_A,test
|
| 321 |
+
1v7z_F,train
|
| 322 |
+
1v9m_A,train
|
| 323 |
+
1vaj_A,train
|
| 324 |
+
1vbi_A,train
|
| 325 |
+
1vbw_A,test
|
| 326 |
+
1vcc_A,train
|
| 327 |
+
1vcl_A,val
|
| 328 |
+
1vct_A,train
|
| 329 |
+
1vdk_B,train
|
| 330 |
+
1ve0_A,train
|
| 331 |
+
1vk1_A,test
|
| 332 |
+
1vkm_C,train
|
| 333 |
+
1vkm_D,train
|
| 334 |
+
1vlb_A,train
|
| 335 |
+
1vr8_A,test
|
| 336 |
+
1vra_B,train
|
| 337 |
+
1vyi_A,train
|
| 338 |
+
1vzm_B,val
|
| 339 |
+
1vzy_A,train
|
| 340 |
+
1vzy_B,train
|
| 341 |
+
1w2w_A,train
|
| 342 |
+
1w2w_E,train
|
| 343 |
+
1w53_A,train
|
| 344 |
+
1w6s_D,train
|
| 345 |
+
1w9g_A,train
|
| 346 |
+
1wbe_A,train
|
| 347 |
+
1wd5_A,train
|
| 348 |
+
1wf3_A,val
|
| 349 |
+
1whi_A,test
|
| 350 |
+
1whz_A,train
|
| 351 |
+
1wlg_A,train
|
| 352 |
+
1wlg_B,train
|
| 353 |
+
1wn9_A,train
|
| 354 |
+
1wna_A,train
|
| 355 |
+
1woj_A,test
|
| 356 |
+
1wpb_A,train
|
| 357 |
+
1wpb_L,train
|
| 358 |
+
1wpu_A,train
|
| 359 |
+
1wq6_A,train
|
| 360 |
+
1wq6_B,train
|
| 361 |
+
1wq8_A,test
|
| 362 |
+
1wqj_B,train
|
| 363 |
+
1wui_L,train
|
| 364 |
+
1wui_S,train
|
| 365 |
+
1wx1_B,train
|
| 366 |
+
1x0a_A,train
|
| 367 |
+
1x3o_A,train
|
| 368 |
+
1x6i_A,train
|
| 369 |
+
1x6j_A,train
|
| 370 |
+
1xeo_A,val
|
| 371 |
+
1xg0_A,test
|
| 372 |
+
1xg0_B,test
|
| 373 |
+
1xhk_B,val
|
| 374 |
+
1xkg_A,train
|
| 375 |
+
1xkn_A,train
|
| 376 |
+
1xkr_A,train
|
| 377 |
+
1xmk_A,train
|
| 378 |
+
1xo7_B,test
|
| 379 |
+
1xsz_A,train
|
| 380 |
+
1xta_A,val
|
| 381 |
+
1xta_B,val
|
| 382 |
+
1xty_B,train
|
| 383 |
+
1xvg_E,train
|
| 384 |
+
1xwl_A,train
|
| 385 |
+
1y0n_A,test
|
| 386 |
+
1y6i_A,train
|
| 387 |
+
1y7t_B,train
|
| 388 |
+
1yd3_A,val
|
| 389 |
+
1yib_A,train
|
| 390 |
+
1yoc_B,train
|
| 391 |
+
1yoe_A,train
|
| 392 |
+
1yoz_A,train
|
| 393 |
+
1yoz_B,train
|
| 394 |
+
1ypy_A,test
|
| 395 |
+
1yqe_A,train
|
| 396 |
+
1yqw_B,train
|
| 397 |
+
1yqw_Q,train
|
| 398 |
+
1ys1_X,train
|
| 399 |
+
1yu0_A,train
|
| 400 |
+
1yu2_A,train
|
| 401 |
+
1yu5_X,train
|
| 402 |
+
1z0b_A,val
|
| 403 |
+
1z1l_A,train
|
| 404 |
+
1z21_A,train
|
| 405 |
+
1z2u_A,train
|
| 406 |
+
1z7k_B,val
|
| 407 |
+
1zd7_B,train
|
| 408 |
+
1zdy_A,train
|
| 409 |
+
1ze3_D,train
|
| 410 |
+
1zht_A,train
|
| 411 |
+
1zjc_A,train
|
| 412 |
+
1zn6_A,test
|
| 413 |
+
1zos_C,train
|
| 414 |
+
1zpe_A,train
|
| 415 |
+
1zsw_A,train
|
| 416 |
+
1zt5_A,train
|
| 417 |
+
1zw0_G,train
|
| 418 |
+
1zxx_A,train
|
| 419 |
+
2a6s_B,train
|
| 420 |
+
2abk_A,train
|
| 421 |
+
2ad6_A,train
|
| 422 |
+
2ad6_D,train
|
| 423 |
+
2ahn_A,test
|
| 424 |
+
2aib_A,train
|
| 425 |
+
2aj7_A,train
|
| 426 |
+
2amh_A,test
|
| 427 |
+
2arz_A,val
|
| 428 |
+
2at8_X,train
|
| 429 |
+
2au3_A,train
|
| 430 |
+
2au7_A,train
|
| 431 |
+
2b0a_A,train
|
| 432 |
+
2b0t_A,train
|
| 433 |
+
2b1y_A,train
|
| 434 |
+
2b3y_A,train
|
| 435 |
+
2b7r_A,train
|
| 436 |
+
2b97_A,test
|
| 437 |
+
2b9d_A,train
|
| 438 |
+
2b9d_B,train
|
| 439 |
+
2bbr_A,train
|
| 440 |
+
2bf6_A,train
|
| 441 |
+
2bfw_A,train
|
| 442 |
+
2bjf_A,train
|
| 443 |
+
2bjq_A,train
|
| 444 |
+
2bk9_A,train
|
| 445 |
+
2bko_A,train
|
| 446 |
+
2bln_B,test
|
| 447 |
+
2bmo_B,train
|
| 448 |
+
2bo1_A,train
|
| 449 |
+
2bti_A,test
|
| 450 |
+
2bti_B,test
|
| 451 |
+
2bw3_B,train
|
| 452 |
+
2c9i_D,train
|
| 453 |
+
2cb5_A,train
|
| 454 |
+
2cc6_A,val
|
| 455 |
+
2ccq_A,train
|
| 456 |
+
2ccw_A,test
|
| 457 |
+
2cfe_A,test
|
| 458 |
+
2cfm_A,train
|
| 459 |
+
2cg7_A,train
|
| 460 |
+
2cwy_A,train
|
| 461 |
+
2cx7_A,train
|
| 462 |
+
2cxi_A,train
|
| 463 |
+
2cxi_B,train
|
| 464 |
+
2cyj_A,val
|
| 465 |
+
2d1l_A,train
|
| 466 |
+
2d28_C,val
|
| 467 |
+
2d5b_A,train
|
| 468 |
+
2db7_A,train
|
| 469 |
+
2db7_B,train
|
| 470 |
+
2dfx_I,train
|
| 471 |
+
2dka_A,train
|
| 472 |
+
2dlb_A,val
|
| 473 |
+
2dlb_B,val
|
| 474 |
+
2drv_B,train
|
| 475 |
+
2dt4_A,train
|
| 476 |
+
2dt8_A,train
|
| 477 |
+
2dtr_A,train
|
| 478 |
+
2dwk_A,train
|
| 479 |
+
2e5y_B,train
|
| 480 |
+
2e6x_A,train
|
| 481 |
+
2e6x_D,train
|
| 482 |
+
2e7u_A,train
|
| 483 |
+
2e7z_A,train
|
| 484 |
+
2e8e_A,train
|
| 485 |
+
2ebb_A,train
|
| 486 |
+
2ed6_A,train
|
| 487 |
+
2ed6_J,train
|
| 488 |
+
2ehq_A,train
|
| 489 |
+
2ejn_B,train
|
| 490 |
+
2end_A,train
|
| 491 |
+
2eo4_A,train
|
| 492 |
+
2eq8_C,val
|
| 493 |
+
2erl_A,train
|
| 494 |
+
2es9_A,train
|
| 495 |
+
2eu7_X,train
|
| 496 |
+
2ex2_A,train
|
| 497 |
+
2f5t_X,train
|
| 498 |
+
2f60_K,val
|
| 499 |
+
2f6e_A,train
|
| 500 |
+
2fb5_A,train
|
| 501 |
+
2fb5_B,train
|
| 502 |
+
2fb6_A,train
|
| 503 |
+
2fe5_A,train
|
| 504 |
+
2fef_A,train
|
| 505 |
+
2fef_B,train
|
| 506 |
+
2fhz_A,train
|
| 507 |
+
2fi9_A,val
|
| 508 |
+
2fip_A,train
|
| 509 |
+
2fip_B,train
|
| 510 |
+
2fj8_A,val
|
| 511 |
+
2fma_A,train
|
| 512 |
+
2fos_A,train
|
| 513 |
+
2foz_A,train
|
| 514 |
+
2fp1_A,train
|
| 515 |
+
2ftx_A,train
|
| 516 |
+
2ftx_B,val
|
| 517 |
+
2fyg_A,test
|
| 518 |
+
2fzp_A,train
|
| 519 |
+
2g64_A,val
|
| 520 |
+
2g7o_A,test
|
| 521 |
+
2g9e_A,test
|
| 522 |
+
2gc4_B,train
|
| 523 |
+
2gc4_L,val
|
| 524 |
+
2gec_A,train
|
| 525 |
+
2gfq_A,train
|
| 526 |
+
2gg2_A,train
|
| 527 |
+
2gg6_A,train
|
| 528 |
+
2gh0_D,train
|
| 529 |
+
2gib_A,val
|
| 530 |
+
2gib_B,val
|
| 531 |
+
2gke_A,train
|
| 532 |
+
2gkp_A,val
|
| 533 |
+
2gkr_I,val
|
| 534 |
+
2glz_B,train
|
| 535 |
+
2gno_A,train
|
| 536 |
+
2gpi_A,train
|
| 537 |
+
2gqt_A,train
|
| 538 |
+
2gs5_A,val
|
| 539 |
+
2gwm_A,val
|
| 540 |
+
2gwn_A,train
|
| 541 |
+
2h1t_B,train
|
| 542 |
+
2h2z_A,val
|
| 543 |
+
2h7g_X,train
|
| 544 |
+
2hba_A,train
|
| 545 |
+
2hgx_B,train
|
| 546 |
+
2hhv_A,train
|
| 547 |
+
2hl7_A,train
|
| 548 |
+
2hng_A,test
|
| 549 |
+
2hnu_A,train
|
| 550 |
+
2hnu_B,train
|
| 551 |
+
2hq4_A,train
|
| 552 |
+
2hq4_B,train
|
| 553 |
+
2hqk_A,train
|
| 554 |
+
2hu9_A,test
|
| 555 |
+
2hu9_B,test
|
| 556 |
+
2hwn_D,train
|
| 557 |
+
2hxm_A,train
|
| 558 |
+
2hy5_A,train
|
| 559 |
+
2hyv_A,train
|
| 560 |
+
2i2f_A,val
|
| 561 |
+
2i5u_A,train
|
| 562 |
+
2i5v_O,train
|
| 563 |
+
2i6d_A,train
|
| 564 |
+
2i7c_C,train
|
| 565 |
+
2i9w_A,val
|
| 566 |
+
2i9x_A,val
|
| 567 |
+
2i9x_B,val
|
| 568 |
+
2ia1_A,train
|
| 569 |
+
2ia1_B,train
|
| 570 |
+
2iay_A,train
|
| 571 |
+
2icu_A,test
|
| 572 |
+
2id6_A,train
|
| 573 |
+
2ie6_A,train
|
| 574 |
+
2igi_A,train
|
| 575 |
+
2igp_A,val
|
| 576 |
+
2ii1_D,val
|
| 577 |
+
2imf_A,train
|
| 578 |
+
2ims_A,train
|
| 579 |
+
2in8_A,train
|
| 580 |
+
2inc_A,train
|
| 581 |
+
2it2_B,train
|
| 582 |
+
2ixm_A,train
|
| 583 |
+
2j6a_A,test
|
| 584 |
+
2j6b_A,train
|
| 585 |
+
2j6c_A,train
|
| 586 |
+
2j7z_A,train
|
| 587 |
+
2jc5_A,train
|
| 588 |
+
2jdd_A,train
|
| 589 |
+
2jek_A,train
|
| 590 |
+
2jft_A,train
|
| 591 |
+
2jh3_A,val
|
| 592 |
+
2jh3_B,val
|
| 593 |
+
2jhf_B,train
|
| 594 |
+
2jhq_A,train
|
| 595 |
+
2jlq_A,train
|
| 596 |
+
2lis_A,train
|
| 597 |
+
2nlv_B,train
|
| 598 |
+
2nml_A,train
|
| 599 |
+
2nnu_A,train
|
| 600 |
+
2nqw_A,train
|
| 601 |
+
2nsa_A,train
|
| 602 |
+
2nug_B,train
|
| 603 |
+
2nuk_A,test
|
| 604 |
+
2nwv_A,train
|
| 605 |
+
2o4t_A,train
|
| 606 |
+
2o6x_A,train
|
| 607 |
+
2o70_F,train
|
| 608 |
+
2o74_F,train
|
| 609 |
+
2o7o_A,train
|
| 610 |
+
2obl_A,train
|
| 611 |
+
2oeb_A,train
|
| 612 |
+
2oez_A,train
|
| 613 |
+
2oez_B,train
|
| 614 |
+
2ofz_A,train
|
| 615 |
+
2ogb_B,train
|
| 616 |
+
2onf_B,train
|
| 617 |
+
2op6_A,train
|
| 618 |
+
2oqz_A,test
|
| 619 |
+
2osa_A,train
|
| 620 |
+
2ot9_A,val
|
| 621 |
+
2ou3_A,train
|
| 622 |
+
2ouw_A,train
|
| 623 |
+
2ov9_B,train
|
| 624 |
+
2ov9_C,train
|
| 625 |
+
2ovj_A,train
|
| 626 |
+
2ox7_B,train
|
| 627 |
+
2oxl_A,train
|
| 628 |
+
2oxl_B,train
|
| 629 |
+
2oxo_A,train
|
| 630 |
+
2oy9_A,train
|
| 631 |
+
2oy9_B,train
|
| 632 |
+
2oya_B,test
|
| 633 |
+
2ozl_A,train
|
| 634 |
+
2p12_A,train
|
| 635 |
+
2p12_B,train
|
| 636 |
+
2p2v_A,train
|
| 637 |
+
2p3p_A,train
|
| 638 |
+
2p3p_B,train
|
| 639 |
+
2p54_A,train
|
| 640 |
+
2p58_A,train
|
| 641 |
+
2p6h_B,train
|
| 642 |
+
2p6v_A,train
|
| 643 |
+
2p84_A,train
|
| 644 |
+
2p9x_A,train
|
| 645 |
+
2p9x_D,train
|
| 646 |
+
2pa6_B,train
|
| 647 |
+
2pag_A,val
|
| 648 |
+
2pbi_A,train
|
| 649 |
+
2pbi_C,train
|
| 650 |
+
2pbk_A,val
|
| 651 |
+
2pbk_B,val
|
| 652 |
+
2pcn_A,test
|
| 653 |
+
2pef_A,train
|
| 654 |
+
2pfx_A,train
|
| 655 |
+
2phn_A,val
|
| 656 |
+
2phn_B,val
|
| 657 |
+
2pmb_C,train
|
| 658 |
+
2pmk_A,train
|
| 659 |
+
2pnw_A,test
|
| 660 |
+
2po4_A,train
|
| 661 |
+
2ppp_A,train
|
| 662 |
+
2ppv_A,train
|
| 663 |
+
2pq8_A,train
|
| 664 |
+
2pqx_A,val
|
| 665 |
+
2prv_A,val
|
| 666 |
+
2psp_B,test
|
| 667 |
+
2pst_X,val
|
| 668 |
+
2pu3_A,test
|
| 669 |
+
2pu9_A,train
|
| 670 |
+
2puo_A,train
|
| 671 |
+
2pv4_A,train
|
| 672 |
+
2pw8_I,train
|
| 673 |
+
2py5_A,train
|
| 674 |
+
2py5_B,train
|
| 675 |
+
2pyq_B,train
|
| 676 |
+
2pyq_C,train
|
| 677 |
+
2q2g_A,train
|
| 678 |
+
2q7x_A,train
|
| 679 |
+
2q9r_A,train
|
| 680 |
+
2qcu_A,train
|
| 681 |
+
2qcu_B,train
|
| 682 |
+
2qdx_A,train
|
| 683 |
+
2qev_A,test
|
| 684 |
+
2qhq_A,train
|
| 685 |
+
2qhq_B,train
|
| 686 |
+
2qia_A,test
|
| 687 |
+
2qjz_A,val
|
| 688 |
+
2qmj_A,train
|
| 689 |
+
2qnl_A,train
|
| 690 |
+
2qp2_A,train
|
| 691 |
+
2qq4_B,val
|
| 692 |
+
2qqc_D,train
|
| 693 |
+
2qsa_A,train
|
| 694 |
+
2qsk_A,val
|
| 695 |
+
2qt4_A,val
|
| 696 |
+
2qtd_A,train
|
| 697 |
+
2qud_A,train
|
| 698 |
+
2qwo_B,train
|
| 699 |
+
2r2d_A,test
|
| 700 |
+
2r31_A,train
|
| 701 |
+
2ra8_A,test
|
| 702 |
+
2rbk_A,train
|
| 703 |
+
2rci_A,train
|
| 704 |
+
2rdi_A,train
|
| 705 |
+
2rff_A,train
|
| 706 |
+
2rij_A,test
|
| 707 |
+
2rji_A,test
|
| 708 |
+
2rjw_A,train
|
| 709 |
+
2rkq_A,val
|
| 710 |
+
2rku_A,train
|
| 711 |
+
2rkv_A,train
|
| 712 |
+
2uxy_A,train
|
| 713 |
+
2v05_A,train
|
| 714 |
+
2v0u_A,test
|
| 715 |
+
2v27_A,train
|
| 716 |
+
2v4b_A,train
|
| 717 |
+
2v4b_B,train
|
| 718 |
+
2v4n_A,train
|
| 719 |
+
2v6a_O,train
|
| 720 |
+
2v9m_A,train
|
| 721 |
+
2vac_A,train
|
| 722 |
+
2vcc_A,train
|
| 723 |
+
2vfk_A,train
|
| 724 |
+
2vfq_A,val
|
| 725 |
+
2vfx_C,train
|
| 726 |
+
2vg1_B,train
|
| 727 |
+
2vg3_C,train
|
| 728 |
+
2vh3_A,train
|
| 729 |
+
2vh3_B,train
|
| 730 |
+
2vi1_A,test
|
| 731 |
+
2vkp_B,test
|
| 732 |
+
2vlf_B,train
|
| 733 |
+
2vm5_A,train
|
| 734 |
+
2vmc_A,train
|
| 735 |
+
2vnl_A,val
|
| 736 |
+
2vri_A,val
|
| 737 |
+
2vrs_C,test
|
| 738 |
+
2vy8_A,test
|
| 739 |
+
2vzc_A,val
|
| 740 |
+
2w0g_A,train
|
| 741 |
+
2w0i_A,train
|
| 742 |
+
2w39_A,test
|
| 743 |
+
2w56_A,test
|
| 744 |
+
2w6k_A,train
|
| 745 |
+
2w6l_A,train
|
| 746 |
+
2w86_A,train
|
| 747 |
+
2w8x_A,val
|
| 748 |
+
2w9y_A,train
|
| 749 |
+
2waw_A,val
|
| 750 |
+
2wb6_A,train
|
| 751 |
+
2wbf_X,train
|
| 752 |
+
2wcu_A,test
|
| 753 |
+
2wfp_A,train
|
| 754 |
+
2wfr_A,test
|
| 755 |
+
2wkx_A,val
|
| 756 |
+
2wlt_A,train
|
| 757 |
+
2wn3_C,train
|
| 758 |
+
2wnp_F,train
|
| 759 |
+
2wny_B,val
|
| 760 |
+
2wpq_C,train
|
| 761 |
+
2wqi_D,train
|
| 762 |
+
2wr8_A,train
|
| 763 |
+
2wsi_A,test
|
| 764 |
+
2wya_A,train
|
| 765 |
+
2wzb_A,train
|
| 766 |
+
2wzg_A,train
|
| 767 |
+
2wzo_A,train
|
| 768 |
+
2x49_A,train
|
| 769 |
+
2x5g_A,train
|
| 770 |
+
2x5h_B,train
|
| 771 |
+
2x5r_A,test
|
| 772 |
+
2x63_A,train
|
| 773 |
+
2x8w_A,train
|
| 774 |
+
2x96_A,train
|
| 775 |
+
2x9o_A,train
|
| 776 |
+
2xc1_B,val
|
| 777 |
+
2xdg_A,train
|
| 778 |
+
2xeu_A,train
|
| 779 |
+
2xf2_A,train
|
| 780 |
+
2xf5_B,train
|
| 781 |
+
2xf7_A,train
|
| 782 |
+
2xjq_A,test
|
| 783 |
+
2xm5_A,train
|
| 784 |
+
2xmx_A,train
|
| 785 |
+
2xol_B,train
|
| 786 |
+
2xpp_A,train
|
| 787 |
+
2xqu_A,train
|
| 788 |
+
2xrh_A,train
|
| 789 |
+
2xse_A,train
|
| 790 |
+
2xu8_B,test
|
| 791 |
+
2xvs_A,test
|
| 792 |
+
2xz2_A,val
|
| 793 |
+
2xz3_A,train
|
| 794 |
+
2y1q_A,train
|
| 795 |
+
2y1y_A,train
|
| 796 |
+
2y20_A,train
|
| 797 |
+
2y39_A,train
|
| 798 |
+
2y3w_A,train
|
| 799 |
+
2y3w_B,train
|
| 800 |
+
2y44_A,train
|
| 801 |
+
2y4x_A,train
|
| 802 |
+
2y4x_B,train
|
| 803 |
+
2y7b_A,train
|
| 804 |
+
2ycl_A,train
|
| 805 |
+
2ygs_A,train
|
| 806 |
+
2yjg_A,train
|
| 807 |
+
2yp8_A,train
|
| 808 |
+
2ysk_A,train
|
| 809 |
+
2yvo_A,train
|
| 810 |
+
2yvq_A,train
|
| 811 |
+
2yxn_A,test
|
| 812 |
+
2yyv_B,train
|
| 813 |
+
2yzs_B,train
|
| 814 |
+
2yzt_A,train
|
| 815 |
+
2z0a_B,train
|
| 816 |
+
2z0j_E,train
|
| 817 |
+
2z0x_A,train
|
| 818 |
+
2z4u_A,train
|
| 819 |
+
2z5e_B,val
|
| 820 |
+
2z6o_A,train
|
| 821 |
+
2z6r_A,train
|
| 822 |
+
2z7f_I,train
|
| 823 |
+
2zca_B,train
|
| 824 |
+
2zd2_B,train
|
| 825 |
+
2zfz_D,train
|
| 826 |
+
2znr_A,val
|
| 827 |
+
2zwd_A,train
|
| 828 |
+
2zzd_E,test
|
| 829 |
+
3a0y_B,val
|
| 830 |
+
3a1g_A,train
|
| 831 |
+
3a1g_B,val
|
| 832 |
+
3a1g_C,train
|
| 833 |
+
3a1g_D,val
|
| 834 |
+
3a1u_A,train
|
| 835 |
+
3a2q_A,train
|
| 836 |
+
3a39_A,val
|
| 837 |
+
3a3d_B,train
|
| 838 |
+
3a6d_F,train
|
| 839 |
+
3a7l_A,train
|
| 840 |
+
3aa0_A,train
|
| 841 |
+
3aa6_B,train
|
| 842 |
+
3agn_A,train
|
| 843 |
+
3ajf_A,train
|
| 844 |
+
3ajf_B,train
|
| 845 |
+
3apa_A,train
|
| 846 |
+
3apr_E,test
|
| 847 |
+
3b49_A,train
|
| 848 |
+
3b4q_A,train
|
| 849 |
+
3b4q_B,train
|
| 850 |
+
3b4w_A,train
|
| 851 |
+
3b9q_A,train
|
| 852 |
+
3bec_A,train
|
| 853 |
+
3bhg_A,train
|
| 854 |
+
3bjd_B,train
|
| 855 |
+
3bjd_C,train
|
| 856 |
+
3bk5_A,train
|
| 857 |
+
3bl9_A,train
|
| 858 |
+
3bl9_B,train
|
| 859 |
+
3bn0_A,train
|
| 860 |
+
3boe_A,test
|
| 861 |
+
3bpj_B,train
|
| 862 |
+
3bpj_C,train
|
| 863 |
+
3bpt_A,train
|
| 864 |
+
3bq9_B,train
|
| 865 |
+
3bqk_A,train
|
| 866 |
+
3bqp_B,train
|
| 867 |
+
3bri_A,train
|
| 868 |
+
3bwu_D,train
|
| 869 |
+
3bzl_D,test
|
| 870 |
+
3bzm_A,train
|
| 871 |
+
3bzn_A,train
|
| 872 |
+
3c05_A,train
|
| 873 |
+
3c0f_B,test
|
| 874 |
+
3c1q_B,train
|
| 875 |
+
3c2q_B,train
|
| 876 |
+
3c8w_C,val
|
| 877 |
+
3c8y_A,train
|
| 878 |
+
3c9p_A,test
|
| 879 |
+
3cjs_B,train
|
| 880 |
+
3cjs_C,train
|
| 881 |
+
3ckf_A,train
|
| 882 |
+
3cla_A,train
|
| 883 |
+
3cml_A,train
|
| 884 |
+
3crv_A,test
|
| 885 |
+
3cw3_A,train
|
| 886 |
+
3cy4_A,val
|
| 887 |
+
3cyi_A,test
|
| 888 |
+
3czz_B,val
|
| 889 |
+
3d1g_A,train
|
| 890 |
+
3d2q_A,test
|
| 891 |
+
3d3y_A,train
|
| 892 |
+
3d4i_A,val
|
| 893 |
+
3d7a_B,val
|
| 894 |
+
3da8_A,test
|
| 895 |
+
3dai_A,train
|
| 896 |
+
3dan_A,train
|
| 897 |
+
3dau_A,train
|
| 898 |
+
3dd6_A,train
|
| 899 |
+
3dff_A,train
|
| 900 |
+
3dgp_B,train
|
| 901 |
+
3dha_A,test
|
| 902 |
+
3djl_A,train
|
| 903 |
+
3dnh_B,val
|
| 904 |
+
3do6_A,train
|
| 905 |
+
3dpg_B,test
|
| 906 |
+
3dqy_A,test
|
| 907 |
+
3dso_A,test
|
| 908 |
+
3dza_A,train
|
| 909 |
+
3e0z_A,train
|
| 910 |
+
3e0z_B,train
|
| 911 |
+
3e2d_A,test
|
| 912 |
+
3e4w_B,train
|
| 913 |
+
3e7h_A,train
|
| 914 |
+
3e8t_A,test
|
| 915 |
+
3e9v_A,train
|
| 916 |
+
3ebh_A,train
|
| 917 |
+
3eh1_A,train
|
| 918 |
+
3ehg_A,val
|
| 919 |
+
3emf_A,test
|
| 920 |
+
3emi_A,test
|
| 921 |
+
3enu_A,train
|
| 922 |
+
3eoj_A,train
|
| 923 |
+
3eqx_A,train
|
| 924 |
+
3eto_A,train
|
| 925 |
+
3eye_A,train
|
| 926 |
+
3ezu_A,train
|
| 927 |
+
3f0o_B,train
|
| 928 |
+
3f0p_A,train
|
| 929 |
+
3f2e_A,train
|
| 930 |
+
3f43_A,train
|
| 931 |
+
3f4m_A,train
|
| 932 |
+
3f7c_A,train
|
| 933 |
+
3f7w_A,train
|
| 934 |
+
3fbl_A,train
|
| 935 |
+
3fcn_A,train
|
| 936 |
+
3fgh_A,train
|
| 937 |
+
3fh2_A,train
|
| 938 |
+
3fhf_A,train
|
| 939 |
+
3fkc_A,test
|
| 940 |
+
3fke_A,val
|
| 941 |
+
3fm2_A,train
|
| 942 |
+
3fn2_B,test
|
| 943 |
+
3fo8_D,train
|
| 944 |
+
3fp5_A,train
|
| 945 |
+
3fpn_A,test
|
| 946 |
+
3fpu_A,train
|
| 947 |
+
3frr_A,train
|
| 948 |
+
3fyb_A,test
|
| 949 |
+
3g06_A,train
|
| 950 |
+
3g0m_A,val
|
| 951 |
+
3g28_A,train
|
| 952 |
+
3g3s_B,train
|
| 953 |
+
3g5k_D,val
|
| 954 |
+
3g5t_A,test
|
| 955 |
+
3g6i_A,train
|
| 956 |
+
3g98_B,train
|
| 957 |
+
3ga3_A,train
|
| 958 |
+
3ghd_A,val
|
| 959 |
+
3gkj_A,test
|
| 960 |
+
3glx_A,train
|
| 961 |
+
3gmv_X,val
|
| 962 |
+
3gnu_P,val
|
| 963 |
+
3gqh_A,test
|
| 964 |
+
3gqv_A,train
|
| 965 |
+
3gs9_A,train
|
| 966 |
+
3gwi_A,train
|
| 967 |
+
3h0n_A,val
|
| 968 |
+
3h1d_A,train
|
| 969 |
+
3h1w_A,train
|
| 970 |
+
3h2d_B,train
|
| 971 |
+
3h5q_A,train
|
| 972 |
+
3h8t_A,val
|
| 973 |
+
3h93_A,train
|
| 974 |
+
3hdj_B,train
|
| 975 |
+
3hfw_A,train
|
| 976 |
+
3hgl_A,train
|
| 977 |
+
3hht_A,test
|
| 978 |
+
3hlz_A,train
|
| 979 |
+
3hlz_B,train
|
| 980 |
+
3hmr_A,val
|
| 981 |
+
3hms_A,val
|
| 982 |
+
3ho6_A,val
|
| 983 |
+
3hol_A,train
|
| 984 |
+
3hvv_A,val
|
| 985 |
+
3hwu_A,train
|
| 986 |
+
3hxv_A,train
|
| 987 |
+
3hxw_A,train
|
| 988 |
+
3i57_B,train
|
| 989 |
+
3i94_A,train
|
| 990 |
+
3ib5_A,train
|
| 991 |
+
3ic3_B,train
|
| 992 |
+
3ic3_C,train
|
| 993 |
+
3ig9_B,train
|
| 994 |
+
3ig9_C,train
|
| 995 |
+
3igz_B,train
|
| 996 |
+
3ii2_A,test
|
| 997 |
+
3iis_M,train
|
| 998 |
+
3iiu_M,train
|
| 999 |
+
3ijw_A,val
|
| 1000 |
+
3ikw_A,train
|
| 1001 |
+
3ilw_A,train
|
| 1002 |
+
3im1_A,train
|
| 1003 |
+
3im3_A,train
|
| 1004 |
+
3imk_A,train
|
| 1005 |
+
3in9_A,train
|
| 1006 |
+
3ino_A,test
|
| 1007 |
+
3ip4_A,train
|
| 1008 |
+
3ipf_A,train
|
| 1009 |
+
3ipf_B,train
|
| 1010 |
+
3ipj_A,train
|
| 1011 |
+
3it4_B,train
|
| 1012 |
+
3it4_C,val
|
| 1013 |
+
3jsy_A,train
|
| 1014 |
+
3jsy_B,train
|
| 1015 |
+
3jsz_A,train
|
| 1016 |
+
3jtz_A,test
|
| 1017 |
+
3ju3_A,val
|
| 1018 |
+
3ju4_A,train
|
| 1019 |
+
3jub_A,val
|
| 1020 |
+
3jv1_A,test
|
| 1021 |
+
3jz9_A,train
|
| 1022 |
+
3jza_B,train
|
| 1023 |
+
3k29_A,train
|
| 1024 |
+
3k59_A,train
|
| 1025 |
+
3k5j_A,test
|
| 1026 |
+
3k6q_B,train
|
| 1027 |
+
3ka5_A,train
|
| 1028 |
+
3ka5_B,train
|
| 1029 |
+
3kbb_A,train
|
| 1030 |
+
3kby_A,train
|
| 1031 |
+
3kby_B,train
|
| 1032 |
+
3kd4_A,train
|
| 1033 |
+
3kd4_B,train
|
| 1034 |
+
3kde_C,test
|
| 1035 |
+
3kef_B,test
|
| 1036 |
+
3klr_A,train
|
| 1037 |
+
3ktp_A,train
|
| 1038 |
+
3kvd_D,train
|
| 1039 |
+
3kwr_A,train
|
| 1040 |
+
3kz5_B,train
|
| 1041 |
+
3kz5_E,train
|
| 1042 |
+
3kz7_A,train
|
| 1043 |
+
3l1e_A,train
|
| 1044 |
+
3l2a_A,val
|
| 1045 |
+
3l32_A,train
|
| 1046 |
+
3l32_B,train
|
| 1047 |
+
3l4h_A,train
|
| 1048 |
+
3l4p_A,train
|
| 1049 |
+
3l51_A,val
|
| 1050 |
+
3l51_B,val
|
| 1051 |
+
3l84_A,train
|
| 1052 |
+
3l9a_X,train
|
| 1053 |
+
3lae_A,train
|
| 1054 |
+
3las_B,train
|
| 1055 |
+
3lbl_A,train
|
| 1056 |
+
3ld7_B,test
|
| 1057 |
+
3ldu_A,train
|
| 1058 |
+
3let_B,train
|
| 1059 |
+
3lgb_B,train
|
| 1060 |
+
3lk7_A,test
|
| 1061 |
+
3lkt_Q,val
|
| 1062 |
+
3ll7_A,test
|
| 1063 |
+
3lpc_A,train
|
| 1064 |
+
3lpe_B,test
|
| 1065 |
+
3lq9_A,train
|
| 1066 |
+
3lq9_B,train
|
| 1067 |
+
3lti_A,train
|
| 1068 |
+
3lui_B,train
|
| 1069 |
+
3lur_B,train
|
| 1070 |
+
3luu_A,test
|
| 1071 |
+
3lvu_D,train
|
| 1072 |
+
3lwx_A,test
|
| 1073 |
+
3lx5_A,train
|
| 1074 |
+
3lyf_D,train
|
| 1075 |
+
3lyw_A,train
|
| 1076 |
+
3lyy_A,train
|
| 1077 |
+
3m4r_A,train
|
| 1078 |
+
3m5q_A,val
|
| 1079 |
+
3m66_A,test
|
| 1080 |
+
3m6z_A,train
|
| 1081 |
+
3m7a_A,train
|
| 1082 |
+
3m7d_A,train
|
| 1083 |
+
3mcb_A,val
|
| 1084 |
+
3mcb_B,val
|
| 1085 |
+
3mfd_A,train
|
| 1086 |
+
3mhs_B,train
|
| 1087 |
+
3mil_A,train
|
| 1088 |
+
3mm6_A,train
|
| 1089 |
+
3mmh_B,train
|
| 1090 |
+
3mmy_D,train
|
| 1091 |
+
3mmy_F,train
|
| 1092 |
+
3mol_B,train
|
| 1093 |
+
3mqz_A,train
|
| 1094 |
+
3msu_B,train
|
| 1095 |
+
3msw_A,train
|
| 1096 |
+
3mwz_A,val
|
| 1097 |
+
3mx7_A,train
|
| 1098 |
+
3mxz_A,train
|
| 1099 |
+
3n4i_B,val
|
| 1100 |
+
3n4j_A,train
|
| 1101 |
+
3n8u_A,train
|
| 1102 |
+
3nci_A,train
|
| 1103 |
+
3ncl_A,train
|
| 1104 |
+
3ngg_B,train
|
| 1105 |
+
3ni2_A,train
|
| 1106 |
+
3nis_B,train
|
| 1107 |
+
3nke_B,train
|
| 1108 |
+
3nl9_A,test
|
| 1109 |
+
3npd_A,train
|
| 1110 |
+
3nqi_A,val
|
| 1111 |
+
3nr1_A,train
|
| 1112 |
+
3nrl_A,train
|
| 1113 |
+
3nrl_B,train
|
| 1114 |
+
3nrw_A,train
|
| 1115 |
+
3nuf_A,train
|
| 1116 |
+
3nyy_A,train
|
| 1117 |
+
3o04_A,val
|
| 1118 |
+
3o0g_D,train
|
| 1119 |
+
3o3x_A,train
|
| 1120 |
+
3o6p_A,train
|
| 1121 |
+
3o79_A,train
|
| 1122 |
+
3obl_B,train
|
| 1123 |
+
3ofg_A,train
|
| 1124 |
+
3ofg_B,train
|
| 1125 |
+
3ohg_A,train
|
| 1126 |
+
3oi8_A,val
|
| 1127 |
+
3oi8_B,val
|
| 1128 |
+
3ol3_A,train
|
| 1129 |
+
3ol4_A,train
|
| 1130 |
+
3omd_A,train
|
| 1131 |
+
3omd_B,train
|
| 1132 |
+
3on9_A,train
|
| 1133 |
+
3on9_B,train
|
| 1134 |
+
3onj_A,train
|
| 1135 |
+
3ono_A,train
|
| 1136 |
+
3ooi_A,train
|
| 1137 |
+
3ot9_B,train
|
| 1138 |
+
3ouf_A,train
|
| 1139 |
+
3ouf_B,train
|
| 1140 |
+
3ov5_A,train
|
| 1141 |
+
3owt_A,train
|
| 1142 |
+
3owt_B,train
|
| 1143 |
+
3oxp_A,train
|
| 1144 |
+
3oyv_A,train
|
| 1145 |
+
3p3g_A,test
|
| 1146 |
+
3p3o_A,train
|
| 1147 |
+
3p3v_B,train
|
| 1148 |
+
3p4h_A,val
|
| 1149 |
+
3p5p_A,train
|
| 1150 |
+
3pes_A,train
|
| 1151 |
+
3pes_B,train
|
| 1152 |
+
3pf6_A,train
|
| 1153 |
+
3pf6_C,train
|
| 1154 |
+
3pjy_B,train
|
| 1155 |
+
3pkz_A,train
|
| 1156 |
+
3pkz_B,train
|
| 1157 |
+
3po8_A,train
|
| 1158 |
+
3pt1_A,train
|
| 1159 |
+
3pvh_A,train
|
| 1160 |
+
3pzw_A,train
|
| 1161 |
+
3q0i_A,test
|
| 1162 |
+
3q1c_A,test
|
| 1163 |
+
3q1n_A,train
|
| 1164 |
+
3q1p_A,train
|
| 1165 |
+
3q3u_A,val
|
| 1166 |
+
3qc5_X,train
|
| 1167 |
+
3qc7_A,test
|
| 1168 |
+
3qfl_A,test
|
| 1169 |
+
3qra_A,train
|
| 1170 |
+
3quo_A,train
|
| 1171 |
+
3rjs_A,train
|
| 1172 |
+
3rkg_A,train
|
| 1173 |
+
3rlk_A,test
|
| 1174 |
+
3rmq_A,train
|
| 1175 |
+
3rt4_A,val
|
| 1176 |
+
3rv1_B,train
|
| 1177 |
+
3rxy_A,train
|
| 1178 |
+
3rzn_A,train
|
| 1179 |
+
3se9_G,val
|
| 1180 |
+
3sfv_B,train
|
| 1181 |
+
3shg_B,train
|
| 1182 |
+
3sol_A,train
|
| 1183 |
+
3st1_A,val
|
| 1184 |
+
3svi_A,train
|
| 1185 |
+
3sws_E,train
|
| 1186 |
+
3sxk_B,train
|
| 1187 |
+
3t4r_A,train
|
| 1188 |
+
3t7h_B,train
|
| 1189 |
+
3t7z_A,val
|
| 1190 |
+
3t92_A,train
|
| 1191 |
+
3tbn_A,val
|
| 1192 |
+
3tdt_A,test
|
| 1193 |
+
3tee_A,test
|
| 1194 |
+
3tgt_A,val
|
| 1195 |
+
3ti2_A,train
|
| 1196 |
+
3tkk_A,val
|
| 1197 |
+
3tvj_I,train
|
| 1198 |
+
3twz_A,train
|
| 1199 |
+
3txs_B,train
|
| 1200 |
+
3txs_C,train
|
| 1201 |
+
3u5v_A,train
|
| 1202 |
+
3u7t_A,train
|
| 1203 |
+
3u9g_A,train
|
| 1204 |
+
3ueb_C,train
|
| 1205 |
+
3ueb_E,train
|
| 1206 |
+
3ush_A,val
|
| 1207 |
+
3ush_B,val
|
| 1208 |
+
3v0r_A,val
|
| 1209 |
+
3v3l_A,train
|
| 1210 |
+
3v68_A,train
|
| 1211 |
+
3vc8_A,train
|
| 1212 |
+
3vc8_B,train
|
| 1213 |
+
3vej_B,train
|
| 1214 |
+
3vgp_A,train
|
| 1215 |
+
3vhj_A,train
|
| 1216 |
+
3vjz_A,train
|
| 1217 |
+
3vkw_A,train
|
| 1218 |
+
3vnb_A,train
|
| 1219 |
+
3vor_A,test
|
| 1220 |
+
3vth_A,train
|
| 1221 |
+
3vu0_B,train
|
| 1222 |
+
3w1o_A,train
|
| 1223 |
+
3wa1_A,val
|
| 1224 |
+
3whj_A,train
|
| 1225 |
+
3wkx_A,train
|
| 1226 |
+
3wok_A,train
|
| 1227 |
+
3wol_A,train
|
| 1228 |
+
3wp8_A,test
|
| 1229 |
+
3wur_B,train
|
| 1230 |
+
3wvz_A,train
|
| 1231 |
+
3wvz_B,train
|
| 1232 |
+
3wwh_A,train
|
| 1233 |
+
3wx4_A,train
|
| 1234 |
+
3x0g_A,train
|
| 1235 |
+
3x38_B,train
|
| 1236 |
+
3zcb_B,train
|
| 1237 |
+
3zdm_A,train
|
| 1238 |
+
3zfn_A,train
|
| 1239 |
+
3zfp_A,train
|
| 1240 |
+
3zl8_A,train
|
| 1241 |
+
3zoq_B,train
|
| 1242 |
+
3zoq_C,train
|
| 1243 |
+
3zr8_X,train
|
| 1244 |
+
3zrg_B,test
|
| 1245 |
+
3zzo_A,train
|
| 1246 |
+
3zzr_A,train
|
| 1247 |
+
4a1k_A,val
|
| 1248 |
+
4a3p_A,train
|
| 1249 |
+
4a56_A,train
|
| 1250 |
+
4adn_A,train
|
| 1251 |
+
4adn_B,train
|
| 1252 |
+
4af1_A,train
|
| 1253 |
+
4alz_A,test
|
| 1254 |
+
4aqr_D,test
|
| 1255 |
+
4arl_B,train
|
| 1256 |
+
4ayg_A,train
|
| 1257 |
+
4ayg_B,train
|
| 1258 |
+
4b2f_A,train
|
| 1259 |
+
4b6i_D,train
|
| 1260 |
+
4bcl_A,train
|
| 1261 |
+
4bgp_A,test
|
| 1262 |
+
4bt9_A,train
|
| 1263 |
+
4bt9_B,train
|
| 1264 |
+
4byz_A,train
|
| 1265 |
+
4cbe_A,train
|
| 1266 |
+
4cdp_A,train
|
| 1267 |
+
4cfi_A,train
|
| 1268 |
+
4cjn_A,train
|
| 1269 |
+
4ckk_A,train
|
| 1270 |
+
4csb_A,val
|
| 1271 |
+
4ct7_A,train
|
| 1272 |
+
4cv4_A,train
|
| 1273 |
+
4cv7_A,val
|
| 1274 |
+
4d71_A,train
|
| 1275 |
+
4ddp_A,train
|
| 1276 |
+
4dja_A,train
|
| 1277 |
+
4dlh_B,test
|
| 1278 |
+
4dok_A,train
|
| 1279 |
+
4dol_A,train
|
| 1280 |
+
4e1p_A,train
|
| 1281 |
+
4e1p_B,train
|
| 1282 |
+
4e40_A,train
|
| 1283 |
+
4e5r_A,train
|
| 1284 |
+
4ea9_A,test
|
| 1285 |
+
4ead_A,train
|
| 1286 |
+
4ebg_A,train
|
| 1287 |
+
4ebg_B,train
|
| 1288 |
+
4edk_A,train
|
| 1289 |
+
4ehx_A,test
|
| 1290 |
+
4eo1_A,test
|
| 1291 |
+
4epi_A,train
|
| 1292 |
+
4erv_A,train
|
| 1293 |
+
4ew5_A,train
|
| 1294 |
+
4ew5_B,train
|
| 1295 |
+
4exo_A,test
|
| 1296 |
+
4ezi_A,val
|
| 1297 |
+
4f55_A,test
|
| 1298 |
+
4f87_A,train
|
| 1299 |
+
4f98_A,test
|
| 1300 |
+
4fbs_A,train
|
| 1301 |
+
4fc2_B,val
|
| 1302 |
+
4fch_B,test
|
| 1303 |
+
4fhr_B,test
|
| 1304 |
+
4fqn_B,train
|
| 1305 |
+
4ftf_A,train
|
| 1306 |
+
4g6d_B,train
|
| 1307 |
+
4g75_A,train
|
| 1308 |
+
4g94_B,train
|
| 1309 |
+
4geh_A,train
|
| 1310 |
+
4geh_C,train
|
| 1311 |
+
4ghn_A,train
|
| 1312 |
+
4gip_A,test
|
| 1313 |
+
4gip_B,test
|
| 1314 |
+
4gjp_A,train
|
| 1315 |
+
4gk9_A,train
|
| 1316 |
+
4gn0_A,train
|
| 1317 |
+
4goe_A,train
|
| 1318 |
+
4goq_A,train
|
| 1319 |
+
4goq_B,train
|
| 1320 |
+
4gsj_A,train
|
| 1321 |
+
4gv2_A,train
|
| 1322 |
+
4gvq_C,train
|
| 1323 |
+
4h4n_A,train
|
| 1324 |
+
4h9m_A,train
|
| 1325 |
+
4h9n_C,train
|
| 1326 |
+
4h9q_C,train
|
| 1327 |
+
4hfq_B,train
|
| 1328 |
+
4hfv_A,train
|
| 1329 |
+
4hkd_B,train
|
| 1330 |
+
4hwx_A,train
|
| 1331 |
+
4iaj_A,train
|
| 1332 |
+
4iaj_B,train
|
| 1333 |
+
4ics_A,train
|
| 1334 |
+
4iu3_B,train
|
| 1335 |
+
4j32_B,train
|
| 1336 |
+
4j4r_A,train
|
| 1337 |
+
4j8c_A,val
|
| 1338 |
+
4j8c_B,val
|
| 1339 |
+
4jgi_A,train
|
| 1340 |
+
4jgi_B,train
|
| 1341 |
+
4jgn_A,train
|
| 1342 |
+
4jja_A,train
|
| 1343 |
+
4jmu_A,test
|
| 1344 |
+
4jnu_A,train
|
| 1345 |
+
4jnu_B,train
|
| 1346 |
+
4jo7_A,train
|
| 1347 |
+
4jo7_C,train
|
| 1348 |
+
4jqu_B,train
|
| 1349 |
+
4k05_B,train
|
| 1350 |
+
4k2m_A,train
|
| 1351 |
+
4k2m_B,train
|
| 1352 |
+
4kct_B,train
|
| 1353 |
+
4ke2_B,train
|
| 1354 |
+
4ke2_C,train
|
| 1355 |
+
4kk7_A,test
|
| 1356 |
+
4kmn_A,train
|
| 1357 |
+
4koq_A,train
|
| 1358 |
+
4ksn_A,train
|
| 1359 |
+
4ksn_C,train
|
| 1360 |
+
4lim_A,train
|
| 1361 |
+
4ljo_A,train
|
| 1362 |
+
4lpq_A,val
|
| 1363 |
+
4lq4_A,train
|
| 1364 |
+
4lty_A,train
|
| 1365 |
+
4lty_D,train
|
| 1366 |
+
4lur_A,train
|
| 1367 |
+
4lzh_A,val
|
| 1368 |
+
4m0q_A,train
|
| 1369 |
+
4m0q_B,train
|
| 1370 |
+
4m37_A,train
|
| 1371 |
+
4m62_S,train
|
| 1372 |
+
4mb5_A,train
|
| 1373 |
+
4mmj_A,train
|
| 1374 |
+
4mp8_A,train
|
| 1375 |
+
4myy_A,train
|
| 1376 |
+
4mzv_A,train
|
| 1377 |
+
4n67_A,train
|
| 1378 |
+
4n7w_A,train
|
| 1379 |
+
4n7w_B,train
|
| 1380 |
+
4na5_A,val
|
| 1381 |
+
4ndt_A,train
|
| 1382 |
+
4ngd_A,test
|
| 1383 |
+
4npd_A,train
|
| 1384 |
+
4ny3_A,train
|
| 1385 |
+
4o66_C,train
|
| 1386 |
+
4o66_D,train
|
| 1387 |
+
4o6g_A,train
|
| 1388 |
+
4o6q_A,train
|
| 1389 |
+
4o7j_B,test
|
| 1390 |
+
4o87_A,train
|
| 1391 |
+
4o87_B,train
|
| 1392 |
+
4oa3_A,train
|
| 1393 |
+
4obi_A,test
|
| 1394 |
+
4oe9_A,train
|
| 1395 |
+
4oe9_B,train
|
| 1396 |
+
4oie_A,test
|
| 1397 |
+
4oj6_C,train
|
| 1398 |
+
4ojl_C,train
|
| 1399 |
+
4ok9_A,train
|
| 1400 |
+
4omf_B,train
|
| 1401 |
+
4oxw_A,train
|
| 1402 |
+
4p3a_B,train
|
| 1403 |
+
4p3x_A,test
|
| 1404 |
+
4p5a_A,train
|
| 1405 |
+
4p5a_B,train
|
| 1406 |
+
4p7x_A,test
|
| 1407 |
+
4peg_C,train
|
| 1408 |
+
4pfx_A,train
|
| 1409 |
+
4phr_A,train
|
| 1410 |
+
4psf_B,train
|
| 1411 |
+
4pz1_A,test
|
| 1412 |
+
4q0y_A,train
|
| 1413 |
+
4q0y_B,train
|
| 1414 |
+
4q6v_A,train
|
| 1415 |
+
4q7o_B,train
|
| 1416 |
+
4qaz_A,train
|
| 1417 |
+
4qb0_A,train
|
| 1418 |
+
4qbu_A,train
|
| 1419 |
+
4qlp_A,train
|
| 1420 |
+
4qmd_A,train
|
| 1421 |
+
4qmd_B,train
|
| 1422 |
+
4qn8_A,train
|
| 1423 |
+
4qn8_B,train
|
| 1424 |
+
4qtq_A,test
|
| 1425 |
+
4qx8_B,train
|
| 1426 |
+
4qx8_C,test
|
| 1427 |
+
4qxo_A,train
|
| 1428 |
+
4r03_A,train
|
| 1429 |
+
4r7q_A,train
|
| 1430 |
+
4reo_A,train
|
| 1431 |
+
4rgi_A,train
|
| 1432 |
+
4rhf_A,train
|
| 1433 |
+
4rnz_A,train
|
| 1434 |
+
4rp4_A,train
|
| 1435 |
+
4rp5_A,train
|
| 1436 |
+
4rr9_A,train
|
| 1437 |
+
4rsw_B,train
|
| 1438 |
+
4s39_A,train
|
| 1439 |
+
4tkx_L,train
|
| 1440 |
+
4tsh_A,train
|
| 1441 |
+
4u5h_B,train
|
| 1442 |
+
4u5h_G,train
|
| 1443 |
+
4u9b_A,train
|
| 1444 |
+
4ubp_C,train
|
| 1445 |
+
4uc8_A,train
|
| 1446 |
+
4ue8_B,train
|
| 1447 |
+
4ued_B,train
|
| 1448 |
+
4uhv_B,train
|
| 1449 |
+
4v1g_B,train
|
| 1450 |
+
4v23_A,train
|
| 1451 |
+
4v4e_M,train
|
| 1452 |
+
4whe_A,train
|
| 1453 |
+
4wkz_A,train
|
| 1454 |
+
4wlr_B,test
|
| 1455 |
+
4wrp_A,train
|
| 1456 |
+
4wrp_B,train
|
| 1457 |
+
4wt3_A,train
|
| 1458 |
+
4wwr_F,train
|
| 1459 |
+
4wyw_A,train
|
| 1460 |
+
4wzg_A,train
|
| 1461 |
+
4xb4_A,train
|
| 1462 |
+
4xb5_A,train
|
| 1463 |
+
4xb6_C,train
|
| 1464 |
+
4xb6_D,val
|
| 1465 |
+
4xb6_E,train
|
| 1466 |
+
4xb6_F,val
|
| 1467 |
+
4xb6_H,val
|
| 1468 |
+
4xdu_A,train
|
| 1469 |
+
4xgl_A,train
|
| 1470 |
+
4xo1_A,train
|
| 1471 |
+
4xo2_A,train
|
| 1472 |
+
4xpz_A,train
|
| 1473 |
+
4xqm_A,val
|
| 1474 |
+
4y7s_A,train
|
| 1475 |
+
4y7s_B,train
|
| 1476 |
+
4y93_A,train
|
| 1477 |
+
4yal_A,train
|
| 1478 |
+
4ykd_A,train
|
| 1479 |
+
4ys0_A,train
|
| 1480 |
+
4ytw_C,train
|
| 1481 |
+
4ywk_A,train
|
| 1482 |
+
4ywk_B,train
|
| 1483 |
+
4yxp_A,train
|
| 1484 |
+
4z3x_A,train
|
| 1485 |
+
4z8q_B,train
|
| 1486 |
+
4z8t_B,train
|
| 1487 |
+
4z9p_A,train
|
| 1488 |
+
4za9_A,train
|
| 1489 |
+
4zac_D,train
|
| 1490 |
+
4zav_A,train
|
| 1491 |
+
4zbo_D,val
|
| 1492 |
+
4zce_B,train
|
| 1493 |
+
4zds_A,train
|
| 1494 |
+
4zds_B,train
|
| 1495 |
+
4zi3_C,train
|
| 1496 |
+
4zi3_D,train
|
| 1497 |
+
4zmk_A,train
|
| 1498 |
+
4zqv_A,val
|
| 1499 |
+
4zya_A,train
|
| 1500 |
+
4zya_B,train
|
| 1501 |
+
5a0d_B,train
|
| 1502 |
+
5a0n_A,train
|
| 1503 |
+
5a5y_A,val
|
| 1504 |
+
5a67_A,val
|
| 1505 |
+
5b1n_A,train
|
| 1506 |
+
5b1q_A,train
|
| 1507 |
+
5b1q_B,train
|
| 1508 |
+
5b3p_A,test
|
| 1509 |
+
5b42_A,train
|
| 1510 |
+
5b5i_A,train
|
| 1511 |
+
5b5i_B,train
|
| 1512 |
+
5b6c_A,test
|
| 1513 |
+
5bmt_B,val
|
| 1514 |
+
5bnh_A,train
|
| 1515 |
+
5bnh_D,train
|
| 1516 |
+
5bs1_B,train
|
| 1517 |
+
5bty_A,train
|
| 1518 |
+
5btz_A,train
|
| 1519 |
+
5by8_B,test
|
| 1520 |
+
5c8q_B,val
|
| 1521 |
+
5ce9_A,train
|
| 1522 |
+
5cfl_A,train
|
| 1523 |
+
5cof_A,train
|
| 1524 |
+
5cyz_C,test
|
| 1525 |
+
5dbl_A,train
|
| 1526 |
+
5dje_A,train
|
| 1527 |
+
5dje_B,train
|
| 1528 |
+
5dmp_A,val
|
| 1529 |
+
5dmu_A,train
|
| 1530 |
+
5dpo_A,train
|
| 1531 |
+
5e3e_A,train
|
| 1532 |
+
5e3e_E,train
|
| 1533 |
+
5e5q_A,train
|
| 1534 |
+
5e5y_C,train
|
| 1535 |
+
5e7x_A,train
|
| 1536 |
+
5ef9_A,train
|
| 1537 |
+
5eg7_A,train
|
| 1538 |
+
5el3_B,train
|
| 1539 |
+
5en2_C,test
|
| 1540 |
+
5eqz_A,train
|
| 1541 |
+
5erq_A,train
|
| 1542 |
+
5ert_A,train
|
| 1543 |
+
5exe_C,train
|
| 1544 |
+
5exh_C,train
|
| 1545 |
+
5ezu_A,train
|
| 1546 |
+
5fbf_A,train
|
| 1547 |
+
5fia_B,train
|
| 1548 |
+
5ftw_A,train
|
| 1549 |
+
5fub_A,train
|
| 1550 |
+
5g38_A,train
|
| 1551 |
+
5g5g_B,train
|
| 1552 |
+
5g68_A,train
|
| 1553 |
+
5ggl_A,train
|
| 1554 |
+
5gof_A,train
|
| 1555 |
+
5gv0_A,train
|
| 1556 |
+
5gw6_A,train
|
| 1557 |
+
5h1n_A,train
|
| 1558 |
+
5h1n_B,train
|
| 1559 |
+
5h2d_A,train
|
| 1560 |
+
5h6x_A,train
|
| 1561 |
+
5h7w_B,train
|
| 1562 |
+
5hee_B,train
|
| 1563 |
+
5hkq_I,train
|
| 1564 |
+
5hkx_A,train
|
| 1565 |
+
5hob_F,train
|
| 1566 |
+
5hqh_A,train
|
| 1567 |
+
5htl_A,val
|
| 1568 |
+
5hub_A,train
|
| 1569 |
+
5hz7_A,train
|
| 1570 |
+
5i8j_A,train
|
| 1571 |
+
5i8j_B,train
|
| 1572 |
+
5iff_A,train
|
| 1573 |
+
5iff_B,train
|
| 1574 |
+
5ii7_A,train
|
| 1575 |
+
5ij2_B,train
|
| 1576 |
+
5imu_A,train
|
| 1577 |
+
5iqj_A,train
|
| 1578 |
+
5iqj_C,train
|
| 1579 |
+
5iz3_B,train
|
| 1580 |
+
5j2l_B,train
|
| 1581 |
+
5j3t_B,train
|
| 1582 |
+
5j47_A,train
|
| 1583 |
+
5j72_A,train
|
| 1584 |
+
5ja5_A,val
|
| 1585 |
+
5jak_A,train
|
| 1586 |
+
5jbg_A,train
|
| 1587 |
+
5jca_S,train
|
| 1588 |
+
5jfc_L,train
|
| 1589 |
+
5jfc_S,train
|
| 1590 |
+
5jou_A,train
|
| 1591 |
+
5jr5_A,train
|
| 1592 |
+
5jx1_A,train
|
| 1593 |
+
5k6d_B,test
|
| 1594 |
+
5kdv_A,train
|
| 1595 |
+
5kdw_B,train
|
| 1596 |
+
5kko_C,train
|
| 1597 |
+
5kko_D,train
|
| 1598 |
+
5klh_A,train
|
| 1599 |
+
5klh_B,train
|
| 1600 |
+
5kts_A,test
|
| 1601 |
+
5kvk_A,train
|
| 1602 |
+
5kwb_A,val
|
| 1603 |
+
5kza_A,train
|
| 1604 |
+
5l0r_A,train
|
| 1605 |
+
5l0s_A,train
|
| 1606 |
+
5l87_A,train
|
| 1607 |
+
5lbd_A,train
|
| 1608 |
+
5lc8_A,train
|
| 1609 |
+
5lpa_A,train
|
| 1610 |
+
5lpa_B,train
|
| 1611 |
+
5ltj_A,train
|
| 1612 |
+
5m1m_A,train
|
| 1613 |
+
5m33_A,train
|
| 1614 |
+
5m45_B,train
|
| 1615 |
+
5m45_K,train
|
| 1616 |
+
5mdu_A,train
|
| 1617 |
+
5mu4_A,train
|
| 1618 |
+
5mux_B,train
|
| 1619 |
+
5mux_C,train
|
| 1620 |
+
5muy_A,train
|
| 1621 |
+
5muy_B,train
|
| 1622 |
+
5n0n_A,train
|
| 1623 |
+
5n0s_A,train
|
| 1624 |
+
5n6y_C,train
|
| 1625 |
+
5n76_F,train
|
| 1626 |
+
5naz_A,train
|
| 1627 |
+
5ngd_B,train
|
| 1628 |
+
5ngd_D,train
|
| 1629 |
+
5nir_A,test
|
| 1630 |
+
5njb_B,train
|
| 1631 |
+
5njc_D,train
|
| 1632 |
+
5njl_A,test
|
| 1633 |
+
5nod_A,train
|
| 1634 |
+
5noh_A,train
|
| 1635 |
+
5noh_B,train
|
| 1636 |
+
5o5s_A,train
|
| 1637 |
+
5o9e_A,train
|
| 1638 |
+
5oh5_A,train
|
| 1639 |
+
5ok6_A,train
|
| 1640 |
+
5ol4_A,train
|
| 1641 |
+
5op0_B,train
|
| 1642 |
+
5opm_A,train
|
| 1643 |
+
5opz_A,test
|
| 1644 |
+
5ori_A,train
|
| 1645 |
+
5osw_A,train
|
| 1646 |
+
5pal_A,test
|
| 1647 |
+
5rlk_B,train
|
| 1648 |
+
5syr_B,train
|
| 1649 |
+
5t2p_B,train
|
| 1650 |
+
5t2p_D,train
|
| 1651 |
+
5t76_A,train
|
| 1652 |
+
5txr_B,train
|
| 1653 |
+
5uc0_A,val
|
| 1654 |
+
5udz_A,test
|
| 1655 |
+
5uki_A,train
|
| 1656 |
+
5ul3_A,train
|
| 1657 |
+
5ul4_A,train
|
| 1658 |
+
5um3_A,train
|
| 1659 |
+
5uvr_A,train
|
| 1660 |
+
5v03_B,train
|
| 1661 |
+
5v0m_A,train
|
| 1662 |
+
5v6g_A,train
|
| 1663 |
+
5v7m_A,train
|
| 1664 |
+
5vap_A,train
|
| 1665 |
+
5vu3_B,train
|
| 1666 |
+
5vz0_A,train
|
| 1667 |
+
5vz0_B,train
|
| 1668 |
+
5w2f_A,train
|
| 1669 |
+
5w4a_B,train
|
| 1670 |
+
5w4d_B,train
|
| 1671 |
+
5w53_A,train
|
| 1672 |
+
5w53_B,train
|
| 1673 |
+
5w5c_A,train
|
| 1674 |
+
5w82_B,train
|
| 1675 |
+
5w82_E,train
|
| 1676 |
+
5wbx_B,train
|
| 1677 |
+
5wfy_A,train
|
| 1678 |
+
5wqq_A,val
|
| 1679 |
+
5ws1_A,train
|
| 1680 |
+
5wvo_C,train
|
| 1681 |
+
5wx9_A,train
|
| 1682 |
+
5x0b_A,test
|
| 1683 |
+
5x1e_A,train
|
| 1684 |
+
5x1e_B,train
|
| 1685 |
+
5x1e_D,train
|
| 1686 |
+
5x1e_E,train
|
| 1687 |
+
5x1u_B,val
|
| 1688 |
+
5xbc_B,train
|
| 1689 |
+
5xct_B,train
|
| 1690 |
+
5y4z_A,train
|
| 1691 |
+
5ydn_A,train
|
| 1692 |
+
5ygh_A,train
|
| 1693 |
+
5yrt_C,train
|
| 1694 |
+
5yrv_I,train
|
| 1695 |
+
5z1n_A,train
|
| 1696 |
+
5z42_A,train
|
| 1697 |
+
5z51_A,train
|
| 1698 |
+
5zlq_A,train
|
| 1699 |
+
5zmo_A,train
|
| 1700 |
+
5znj_A,train
|
| 1701 |
+
6a02_A,train
|
| 1702 |
+
6a0p_A,train
|
| 1703 |
+
6a9a_A,train
|
| 1704 |
+
6anz_A,train
|
| 1705 |
+
6ao8_A,train
|
| 1706 |
+
6as3_A,train
|
| 1707 |
+
6as3_B,train
|
| 1708 |
+
6asd_C,train
|
| 1709 |
+
6atg_C,train
|
| 1710 |
+
6avj_B,val
|
| 1711 |
+
6b1z_A,train
|
| 1712 |
+
6b6m_A,train
|
| 1713 |
+
6bk4_A,train
|
| 1714 |
+
6bm5_A,train
|
| 1715 |
+
6bn0_A,train
|
| 1716 |
+
6bwq_A,train
|
| 1717 |
+
6bwr_A,train
|
| 1718 |
+
6c0h_A,test
|
| 1719 |
+
6c62_C,train
|
| 1720 |
+
6c62_D,train
|
| 1721 |
+
6cb6_A,train
|
| 1722 |
+
6cb7_A,train
|
| 1723 |
+
6ch1_A,train
|
| 1724 |
+
6cka_B,train
|
| 1725 |
+
6crk_G,train
|
| 1726 |
+
6d7y_A,test
|
| 1727 |
+
6d7y_B,train
|
| 1728 |
+
6dfp_A,train
|
| 1729 |
+
6dgk_A,train
|
| 1730 |
+
6dgk_B,train
|
| 1731 |
+
6dlm_A,train
|
| 1732 |
+
6dnm_A,train
|
| 1733 |
+
6e0x_B,train
|
| 1734 |
+
6e33_A,train
|
| 1735 |
+
6e5y_A,train
|
| 1736 |
+
6e6o_A,train
|
| 1737 |
+
6e7e_A,train
|
| 1738 |
+
6eof_A,train
|
| 1739 |
+
6eu8_A,val
|
| 1740 |
+
6exa_B,val
|
| 1741 |
+
6f45_D,train
|
| 1742 |
+
6fbz_B,train
|
| 1743 |
+
6fc0_B,train
|
| 1744 |
+
6fsw_A,train
|
| 1745 |
+
6fub_B,train
|
| 1746 |
+
6fy5_A,val
|
| 1747 |
+
6gfx_C,train
|
| 1748 |
+
6gu2_C,train
|
| 1749 |
+
6gus_A,train
|
| 1750 |
+
6h49_A,train
|
| 1751 |
+
6h86_A,train
|
| 1752 |
+
6h86_B,train
|
| 1753 |
+
6h95_A,train
|
| 1754 |
+
6hat_B,train
|
| 1755 |
+
6hem_A,train
|
| 1756 |
+
6hj6_A,train
|
| 1757 |
+
6hr2_B,train
|
| 1758 |
+
6i0i_A,train
|
| 1759 |
+
6i3v_A,train
|
| 1760 |
+
6iah_A,train
|
| 1761 |
+
6idx_A,train
|
| 1762 |
+
6in7_A,train
|
| 1763 |
+
6irx_A,train
|
| 1764 |
+
6j33_B,train
|
| 1765 |
+
6j56_A,train
|
| 1766 |
+
6j56_B,train
|
| 1767 |
+
6jfk_A,train
|
| 1768 |
+
6jim_B,train
|
| 1769 |
+
6jpt_A,val
|
| 1770 |
+
6jv8_A,train
|
| 1771 |
+
6jwh_A,val
|
| 1772 |
+
6jwj_A,val
|
| 1773 |
+
6kty_A,train
|
| 1774 |
+
6l34_A,train
|
| 1775 |
+
6l3m_B,train
|
| 1776 |
+
6l3r_A,train
|
| 1777 |
+
6l3r_E,train
|
| 1778 |
+
6l4l_A,train
|
| 1779 |
+
6l4p_B,train
|
| 1780 |
+
6l8s_A,train
|
| 1781 |
+
6l8s_C,train
|
| 1782 |
+
6lrd_A,train
|
| 1783 |
+
6lus_A,train
|
| 1784 |
+
6mbg_A,train
|
| 1785 |
+
6mdw_A,train
|
| 1786 |
+
6mdx_A,train
|
| 1787 |
+
6mi3_B,train
|
| 1788 |
+
6mm7_C,train
|
| 1789 |
+
6ndw_B,train
|
| 1790 |
+
6ne6_A,train
|
| 1791 |
+
6nl2_A,train
|
| 1792 |
+
6nl2_B,train
|
| 1793 |
+
6o19_A,train
|
| 1794 |
+
6o2v_A,val
|
| 1795 |
+
6o2v_B,val
|
| 1796 |
+
6o6y_A,train
|
| 1797 |
+
6odd_B,train
|
| 1798 |
+
6okd_C,train
|
| 1799 |
+
6okd_D,train
|
| 1800 |
+
6ono_C,val
|
| 1801 |
+
6onu_C,val
|
| 1802 |
+
6ovk_R,train
|
| 1803 |
+
6ovm_R,train
|
| 1804 |
+
6oz1_A,train
|
| 1805 |
+
6p5h_A,train
|
| 1806 |
+
6p5h_B,train
|
| 1807 |
+
6p5x_B,train
|
| 1808 |
+
6pce_A,train
|
| 1809 |
+
6pce_B,train
|
| 1810 |
+
6pnv_A,train
|
| 1811 |
+
6pr1_B,train
|
| 1812 |
+
6pxz_B,train
|
| 1813 |
+
6pxz_C,train
|
| 1814 |
+
6q10_A,test
|
| 1815 |
+
6q9c_A,val
|
| 1816 |
+
6q9c_B,train
|
| 1817 |
+
6q9c_C,val
|
| 1818 |
+
6q9c_D,train
|
| 1819 |
+
6qfk_A,train
|
| 1820 |
+
6qgr_B,train
|
| 1821 |
+
6qj0_A,train
|
| 1822 |
+
6ro6_A,train
|
| 1823 |
+
6ro6_B,train
|
| 1824 |
+
6rrv_A,train
|
| 1825 |
+
6rwt_A,train
|
| 1826 |
+
6sdk_A,test
|
| 1827 |
+
6sms_A,test
|
| 1828 |
+
6spt_A,train
|
| 1829 |
+
6sup_A,train
|
| 1830 |
+
6tgk_C,train
|
| 1831 |
+
6tj6_C,train
|
| 1832 |
+
6tly_A,test
|
| 1833 |
+
6uof_A,val
|
| 1834 |
+
6uxe_B,train
|
| 1835 |
+
6vg5_A,train
|
| 1836 |
+
6vjg_A,train
|
| 1837 |
+
6vr8_I,train
|
| 1838 |
+
6w6x_A,train
|
| 1839 |
+
6wqd_B,train
|
| 1840 |
+
6wzw_A,train
|
| 1841 |
+
6xb3_A,train
|
| 1842 |
+
6xb3_H,train
|
| 1843 |
+
6xds_A,train
|
| 1844 |
+
6xrx_A,train
|
| 1845 |
+
6y2x_A,train
|
| 1846 |
+
6y43_A,train
|
| 1847 |
+
6y5p_B,train
|
| 1848 |
+
6yhu_B,train
|
| 1849 |
+
6ypi_A,train
|
| 1850 |
+
6yud_B,train
|
| 1851 |
+
6z2t_A,train
|
| 1852 |
+
6zdt_B,val
|
| 1853 |
+
6zpe_A,test
|
| 1854 |
+
6zsl_B,train
|
| 1855 |
+
7a66_B,train
|
| 1856 |
+
7a66_C,train
|
| 1857 |
+
7adr_C,train
|
| 1858 |
+
7aex_A,train
|
| 1859 |
+
7aqx_A,train
|
| 1860 |
+
7asg_A,train
|
| 1861 |
+
7bhc_A,train
|
| 1862 |
+
7bqi_A,train
|
| 1863 |
+
7buy_A,val
|
| 1864 |
+
7bwf_B,train
|
| 1865 |
+
7c21_A,train
|
| 1866 |
+
7c45_A,train
|
| 1867 |
+
7ccg_A,train
|
| 1868 |
+
7dif_A,train
|
| 1869 |
+
7dmn_A,train
|
| 1870 |
+
7e2s_A,train
|
| 1871 |
+
7ead_A,train
|
| 1872 |
+
7ec1_A,train
|
| 1873 |
+
7ecq_A,train
|
| 1874 |
+
7egs_A,train
|
| 1875 |
+
7fd1_A,test
|
| 1876 |
+
7jfl_C,train
|
| 1877 |
+
7jfl_D,train
|
| 1878 |
+
7jrq_A,train
|
| 1879 |
+
7k7p_B,train
|
| 1880 |
+
7kwt_A,train
|
| 1881 |
+
7la6_A,train
|
| 1882 |
+
7lao_A,val
|
| 1883 |
+
7lp1_A,train
|
| 1884 |
+
7m8h_A,train
|
| 1885 |
+
7mf4_A,train
|
| 1886 |
+
7mfu_A,val
|
| 1887 |
+
7mi2_A,train
|
| 1888 |
+
7mq3_A,train
|
| 1889 |
+
7n0j_A,train
|
| 1890 |
+
7n0j_E,train
|
| 1891 |
+
7n1n_A,train
|
| 1892 |
+
7n51_A,test
|
| 1893 |
+
7ned_A,train
|
| 1894 |
+
7nmq_A,train
|
| 1895 |
+
7nru_A,train
|
| 1896 |
+
7onn_A,train
|
| 1897 |
+
7p41_D,train
|
| 1898 |
+
7p46_A,train
|
| 1899 |
+
7p46_B,train
|
| 1900 |
+
7qgs_A,train
|
| 1901 |
+
7qsu_A,train
|
| 1902 |
+
7r79_B,train
|
| 1903 |
+
7r79_C,train
|
| 1904 |
+
7rm7_A,train
|
| 1905 |
+
7rsa_A,val
|
| 1906 |
+
7s58_D,train
|
| 1907 |
+
7s6q_C,train
|
| 1908 |
+
7s86_A,test
|
| 1909 |
+
7s94_C,train
|
| 1910 |
+
7sao_A,train
|
| 1911 |
+
7snb_A,train
|
| 1912 |
+
7t9q_A,train
|
| 1913 |
+
7u1y_A,train
|
| 1914 |
+
7ubj_A,train
|
| 1915 |
+
7ubk_B,train
|
| 1916 |
+
7uhe_A,train
|
| 1917 |
+
7uhe_C,train
|
| 1918 |
+
7uw7_A,train
|
| 1919 |
+
7vfk_A,train
|
| 1920 |
+
7w81_A,train
|
| 1921 |
+
7w81_B,train
|
| 1922 |
+
7wab_A,val
|
| 1923 |
+
7z1k_A,val
|
| 1924 |
+
7z27_A,val
|
| 1925 |
+
7z4m_A,train
|
| 1926 |
+
7zh9_A,train
|
| 1927 |
+
7zkk_B,train
|
| 1928 |
+
7zou_A,train
|
| 1929 |
+
7zoy_A,train
|
| 1930 |
+
7zz7_A,val
|
| 1931 |
+
8b2r_B,train
|
| 1932 |
+
8b3w_A,train
|
| 1933 |
+
8bbm_A,train
|
| 1934 |
+
8bnt_B,train
|
| 1935 |
+
8cxl_A,train
|
| 1936 |
+
8dkp_A,train
|
| 1937 |
+
8dkp_B,train
|
| 1938 |
+
8ezh_B,train
|
| 1939 |
+
8htw_B,train
|
data/bindingdb/plug_entities.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/lp-pdbbind/plug_entities.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
docs/SETUP.md
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
+
Runbook for taking this repository from a fresh checkout to a live, scoring Space. It
|
| 4 |
+
follows the shape of OpenADMET's `docs/SETUP.md` but has no AWS, no OpenTofu and no
|
| 5 |
+
container registry — the whole backend is two Hugging Face dataset repos.
|
| 6 |
+
|
| 7 |
+
Everything you need: a Hugging Face account with rights to create datasets in the
|
| 8 |
+
`PrismScienceOrg` namespace, a write token, and a local checkout of
|
| 9 |
+
[`plug`](https://github.com/PrismScienceOrg/plug) with its benchmark data downloaded.
|
| 10 |
+
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
## 1. Create the two dataset repos
|
| 14 |
+
|
| 15 |
+
```bash
|
| 16 |
+
huggingface-cli login # a write token
|
| 17 |
+
|
| 18 |
+
huggingface-cli repo create plug-challenge-data --type dataset --organization PrismScienceOrg
|
| 19 |
+
huggingface-cli repo create plug-challenge-private --type dataset --organization PrismScienceOrg --private
|
| 20 |
+
```
|
| 21 |
+
|
| 22 |
+
The private one must be **private**: it holds the held-back test labels and participants'
|
| 23 |
+
contact details. Double-check that before the first submission arrives.
|
| 24 |
+
|
| 25 |
+
If you name them differently, set `PLUG_PRIVATE_REPO` / `PLUG_PUBLIC_REPO` as Space
|
| 26 |
+
variables to match (defaults are in `plug_challenge/store.py`).
|
| 27 |
+
|
| 28 |
+
## 2. Build the data
|
| 29 |
+
|
| 30 |
+
From this repo, with `plug`'s environment active (it needs `torch`):
|
| 31 |
+
|
| 32 |
+
```bash
|
| 33 |
+
PLUG_REPO=~/plug ~/plug/.venv/bin/python scripts/build_challenge_data.py
|
| 34 |
+
```
|
| 35 |
+
|
| 36 |
+
That writes, per benchmark, into `.challenge-data/` (gitignored):
|
| 37 |
+
|
| 38 |
+
```
|
| 39 |
+
public/<benchmark>/entities.parquet entity -> sequence + split
|
| 40 |
+
public/<benchmark>/sequences.fasta
|
| 41 |
+
public/<benchmark>/train.parquet labelled
|
| 42 |
+
public/<benchmark>/val.parquet labelled
|
| 43 |
+
public/<benchmark>/test_manifest.parquet labels removed
|
| 44 |
+
private/ground_truth/<benchmark>.parquet the held-back labels
|
| 45 |
+
```
|
| 46 |
+
|
| 47 |
+
and refreshes the committed `data/<benchmark>/plug_entities.csv` entity lists.
|
| 48 |
+
|
| 49 |
+
Run it for a subset while iterating: `... build_challenge_data.py megascale fireprot`.
|
| 50 |
+
|
| 51 |
+
The ids are deterministic (a content hash — see the script's docstring), so re-running it
|
| 52 |
+
reproduces the same `datapoint_id` values and an old submission still joins against a
|
| 53 |
+
rebuilt ground truth. **Re-running after changing PLUG's split thresholds does not**: the
|
| 54 |
+
test split itself moves, which invalidates every stored score. Rebuild the leaderboard
|
| 55 |
+
(step 6) if that happens mid-challenge, or better, don't.
|
| 56 |
+
|
| 57 |
+
## 3. Upload it
|
| 58 |
+
|
| 59 |
+
```bash
|
| 60 |
+
huggingface-cli upload PrismScienceOrg/plug-challenge-data \
|
| 61 |
+
.challenge-data/public . --repo-type dataset
|
| 62 |
+
|
| 63 |
+
huggingface-cli upload PrismScienceOrg/plug-challenge-private \
|
| 64 |
+
.challenge-data/private . --repo-type dataset
|
| 65 |
+
```
|
| 66 |
+
|
| 67 |
+
Check the private repo is private *before* this second command, not after.
|
| 68 |
+
|
| 69 |
+
## 4. Configure the Space
|
| 70 |
+
|
| 71 |
+
This repository **is** the Space, so there is no deploy pipeline to set up — but the
|
| 72 |
+
Space needs its secrets. On
|
| 73 |
+
[huggingface.co/spaces/PrismScienceOrg/PLUG-challenge/settings](https://huggingface.co/spaces/PrismScienceOrg/PLUG-challenge/settings):
|
| 74 |
+
|
| 75 |
+
| Kind | Name | Value |
|
| 76 |
+
|---|---|---|
|
| 77 |
+
| **Secret** | `HF_TOKEN` | A write token that can read both dataset repos and write the private one |
|
| 78 |
+
| Variable | `CURRENT_PHASE` | `0` until you are ready to open; `1` to open submissions; `2` to close |
|
| 79 |
+
| Variable | `PLUG_PRIVATE_REPO` | Only if you renamed the private repo |
|
| 80 |
+
| Variable | `PLUG_PUBLIC_REPO` | Only if you renamed the public repo |
|
| 81 |
+
| Variable | `BOOTSTRAP_SAMPLES` | Leave unset (`0`). See [`scoring.md`](scoring.md) |
|
| 82 |
+
|
| 83 |
+
The Space's hardware only needs CPU basic — scoring is a handful of NumPy passes, not a
|
| 84 |
+
model forward. Keep the Space **private** while you test, then make it public.
|
| 85 |
+
|
| 86 |
+
## 5. Work through the TODOs, then deploy
|
| 87 |
+
|
| 88 |
+
```bash
|
| 89 |
+
grep -rn "TODO" config.py docs/
|
| 90 |
+
```
|
| 91 |
+
|
| 92 |
+
`config.py` is where every challenge-specific string lives: the dates in
|
| 93 |
+
`HEADER_MARKDOWN` and `ABOUT_MD`, the announcement/tutorial links, `COMMUNITY_LINK`, and
|
| 94 |
+
the acknowledgements. Then:
|
| 95 |
+
|
| 96 |
+
```bash
|
| 97 |
+
pytest tests/ # 80 tests, synthetic data
|
| 98 |
+
CURRENT_PHASE=1 python app.py # check it locally first
|
| 99 |
+
git push origin main # deploys
|
| 100 |
+
```
|
| 101 |
+
|
| 102 |
+
Watch the Space's build log for the first deploy — the `sdk` changed from `static` to
|
| 103 |
+
`docker`, so the first build is a full image build.
|
| 104 |
+
|
| 105 |
+
### Smoke-test the full path before announcing
|
| 106 |
+
|
| 107 |
+
With the Space open (`CURRENT_PHASE=1`) and the data uploaded, submit a junk-but-valid
|
| 108 |
+
bundle under your own account and confirm it appears on the board:
|
| 109 |
+
|
| 110 |
+
```bash
|
| 111 |
+
plug-challenge template ./smoke --data-dir .challenge-data/public # zeros everywhere
|
| 112 |
+
python - <<'PY'
|
| 113 |
+
# Replace the zeros with noise: a constant column is rejected on the ten
|
| 114 |
+
# rank-scored benchmarks, and cafa5's template is header-only by design (you
|
| 115 |
+
# choose which GO terms to predict), so it needs a row or two to be scorable.
|
| 116 |
+
import glob, numpy as np, pandas as pd
|
| 117 |
+
rng = np.random.default_rng(0)
|
| 118 |
+
for path in glob.glob("smoke/*.csv"):
|
| 119 |
+
frame = pd.read_csv(path)
|
| 120 |
+
if "cafa5" in path:
|
| 121 |
+
manifest = pd.read_parquet(".challenge-data/public/cafa5/test_manifest.parquet")
|
| 122 |
+
pd.DataFrame({
|
| 123 |
+
"datapoint_id": manifest["datapoint_id"],
|
| 124 |
+
"aspect": "bp",
|
| 125 |
+
"term": "GO:0008150", # "biological_process", the BP root
|
| 126 |
+
"score": rng.uniform(size=len(manifest)).round(3),
|
| 127 |
+
}).to_csv(path, index=False)
|
| 128 |
+
continue
|
| 129 |
+
for column in frame.columns:
|
| 130 |
+
if column.startswith("pred"):
|
| 131 |
+
frame[column] = rng.normal(size=len(frame))
|
| 132 |
+
frame.to_csv(path, index=False)
|
| 133 |
+
PY
|
| 134 |
+
cd smoke && zip ../smoke.zip *.csv && cd ..
|
| 135 |
+
plug-challenge validate smoke.zip
|
| 136 |
+
plug-challenge score smoke.zip --ground-truth .challenge-data/private/ground_truth
|
| 137 |
+
```
|
| 138 |
+
|
| 139 |
+
That should report a PLUG Score near 0.5 — the ten rank-scored benchmarks land at chance
|
| 140 |
+
by construction, which is exactly the check: a pipeline that is wired up wrong tends to
|
| 141 |
+
score 0 or 1, not 0.5. (`cafa5` is the exception; a single-term submission's Fmax reflects
|
| 142 |
+
that term's prevalence rather than chance ranking.) `pytest tests/test_real_data.py` makes
|
| 143 |
+
the same check automatically, plus the stricter one that echoing the labels back scores
|
| 144 |
+
exactly 1.0.
|
| 145 |
+
|
| 146 |
+
Then submit `smoke.zip` through the Space itself to exercise the storage path, and delete
|
| 147 |
+
the row afterwards: remove `submissions/<you>/<id>/` and `scores/<you>/<id>/` from the
|
| 148 |
+
private repo and run step 6.
|
| 149 |
+
|
| 150 |
+
## 6. Maintenance
|
| 151 |
+
|
| 152 |
+
**Rebuild the leaderboard** — the leaderboard CSV is derived; the per-submission
|
| 153 |
+
`scores/**/scores.json` files are the source of truth. If two submissions race and one
|
| 154 |
+
row is lost, or you remove a submission:
|
| 155 |
+
|
| 156 |
+
```bash
|
| 157 |
+
HF_TOKEN=... plug-challenge rebuild
|
| 158 |
+
```
|
| 159 |
+
|
| 160 |
+
**Rescore everything** after a metric change: download the bundles from the private
|
| 161 |
+
repo and re-run `plug-challenge score` over each, then rebuild. There is no automated
|
| 162 |
+
path for this on purpose — a metric change mid-challenge is a decision, not a routine.
|
| 163 |
+
|
| 164 |
+
**Block an account**: add it to `BANNED_USERNAMES` in `utils.py` and push.
|
| 165 |
+
|
| 166 |
+
**Close the challenge**: set `CURRENT_PHASE=2`. Submissions are refused and the
|
| 167 |
+
leaderboard is relabelled as the final standings. Nothing is deleted.
|
| 168 |
+
|
| 169 |
+
## 7. Teardown
|
| 170 |
+
|
| 171 |
+
Far less than the template's, since there is no cloud account involved:
|
| 172 |
+
|
| 173 |
+
1. Archive what matters: `huggingface-cli download PrismScienceOrg/plug-challenge-private --repo-type dataset --local-dir ./archive`.
|
| 174 |
+
2. Decide what to publish. Releasing the test labels after the challenge closes is the
|
| 175 |
+
natural end state — it turns the private repo's `ground_truth/` into an ordinary
|
| 176 |
+
public benchmark release.
|
| 177 |
+
3. Leave the Space up with `CURRENT_PHASE=2`; a frozen leaderboard is the record. Only
|
| 178 |
+
delete it if you mean to erase the results.
|
docs/architecture.md
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Architecture, and what changed from the template
|
| 2 |
+
|
| 3 |
+
This challenge is modelled on
|
| 4 |
+
[OpenADMET's blind-challenge-template](https://github.com/OpenADMET/blind-challenge-template).
|
| 5 |
+
The participant-facing shape is deliberately the same — a Gradio Space with About /
|
| 6 |
+
Submit / Leaderboard / FAQ tabs, a `config.py` holding every challenge-specific string, a
|
| 7 |
+
separate scoring library with its own tests, anonymity and disclosure flags on the
|
| 8 |
+
leaderboard, and a submission cooldown. The backend is not.
|
| 9 |
+
|
| 10 |
+
## The template's architecture
|
| 11 |
+
|
| 12 |
+
```
|
| 13 |
+
Space (Gradio) ──upload──► S3 submissions/
|
| 14 |
+
│
|
| 15 |
+
EventBridge (scheduled)
|
| 16 |
+
▼
|
| 17 |
+
Lambda (scoring image from ECR)
|
| 18 |
+
├──► S3 scores/
|
| 19 |
+
└──► Discord webhook
|
| 20 |
+
Lambda (leaderboard) ──► S3 leaderboard/*.csv
|
| 21 |
+
▲
|
| 22 |
+
Space ────────────read───────┘
|
| 23 |
+
```
|
| 24 |
+
|
| 25 |
+
Submissions are asynchronous because the challenge is **blind**: a participant must not
|
| 26 |
+
learn their score immediately, or the held-out labels leak one submission at a time.
|
| 27 |
+
That requirement is what buys the queue, the container image, the OpenTofu stack, the
|
| 28 |
+
OIDC deploy role and the Discord receipts.
|
| 29 |
+
|
| 30 |
+
## This challenge's architecture
|
| 31 |
+
|
| 32 |
+
```
|
| 33 |
+
Space (Gradio)
|
| 34 |
+
├── validate bundle plug_challenge.validation
|
| 35 |
+
├── score vs held-back labels plug_challenge.scoring ◄── private repo: ground_truth/
|
| 36 |
+
├── store bundle + metadata ──► private repo: submissions/
|
| 37 |
+
├── store scores ──► private repo: scores/
|
| 38 |
+
└── append leaderboard row ──► private repo: leaderboard/entries.csv
|
| 39 |
+
│
|
| 40 |
+
Space leaderboard tabs ──────────────read──────────────────────────┘
|
| 41 |
+
|
| 42 |
+
public repo: entities / sequences / train / val / test_manifest ──► participants
|
| 43 |
+
```
|
| 44 |
+
|
| 45 |
+
PLUG is not blinded, so scoring can happen inside the request. Removing the asynchrony
|
| 46 |
+
removes everything the asynchrony was for:
|
| 47 |
+
|
| 48 |
+
| Template | Here | Why |
|
| 49 |
+
|---|---|---|
|
| 50 |
+
| S3 bucket | private Hub dataset repo | One storage system, and it is the one the Space already authenticates to |
|
| 51 |
+
| Scoring Lambdas + ECR image + EventBridge | a function call in the Submit handler | Nothing to queue when the answer is allowed to be immediate |
|
| 52 |
+
| Leaderboard Lambda | `aggregate.build_leaderboard`, called on read | The board is small; ranking it per page load is cheaper than storing a ranked copy |
|
| 53 |
+
| OpenTofu stack, OIDC deploy role, `AWS_DEPLOY_ROLE_ARN` | — | No cloud account |
|
| 54 |
+
| GitHub repo deploying an `hf_space/` subtree | this repo *is* the Space | No second repo, no deploy workflow, no `HF_TOKEN` in GitHub |
|
| 55 |
+
| Discord webhook receipts | the response in the Submit tab | The participant already sees their per-benchmark scores and PLUG Score |
|
| 56 |
+
| `interim` / `final` / `live` leaderboards | one board, frozen at phase 2 | The interim/final split exists to stage the reveal of blinded results |
|
| 57 |
+
| `ACTIVITY_DATASET_SIZE` constants | the ids in the ground truth | Row counts are read from the data rather than restated in config, so they cannot drift |
|
| 58 |
+
|
| 59 |
+
What that costs: there is no queue to absorb a burst, and a long scoring run would block
|
| 60 |
+
a request. The numbers make that a non-issue — every metric is one or two NumPy passes
|
| 61 |
+
over at most a few hundred thousand rows — with one exception, noted in
|
| 62 |
+
[`scoring.md`](scoring.md): bootstrap resampling is off by default because 1000 resamples
|
| 63 |
+
of eleven benchmarks is not a request-time workload.
|
| 64 |
+
|
| 65 |
+
## Ordering guarantees in the Submit handler
|
| 66 |
+
|
| 67 |
+
The order in `submission.submit_bundle` is the part worth not breaking:
|
| 68 |
+
|
| 69 |
+
1. **Identity and form checks** — cheapest, and they need no data.
|
| 70 |
+
2. **Cooldown check** — before any work, so a rate-limited user pays nothing.
|
| 71 |
+
3. **Validation** — before anything is stored. A malformed bundle costs the participant
|
| 72 |
+
nothing and does not start their cooldown, which is what makes "validate locally, then
|
| 73 |
+
upload" a reasonable instruction rather than a trap.
|
| 74 |
+
4. **Scoring** — after validation, so the scorer can assume a clean join.
|
| 75 |
+
5. **Store the bundle and metadata** — the durable record.
|
| 76 |
+
6. **Store the scores, then append the leaderboard row** — in that order, so a failure
|
| 77 |
+
between them leaves a scored submission that `plug-challenge rebuild` can recover,
|
| 78 |
+
rather than a leaderboard row with nothing behind it.
|
| 79 |
+
|
| 80 |
+
## Consistency: one source of truth
|
| 81 |
+
|
| 82 |
+
`plug_challenge/benchmarks.py` declares each benchmark's submission schema, ground-truth
|
| 83 |
+
schema and metrics. Generated from it: the validator's column and range checks, the
|
| 84 |
+
scorer's metric dispatch, the leaderboard's columns and sort order, the Submit tab's
|
| 85 |
+
per-file schema tables, and the FAQ's format rules. The template keeps its endpoint lists
|
| 86 |
+
in two files (`backend/config.py` and `hf_space/config.py`) and asks you to keep them in
|
| 87 |
+
sync by hand; collapsing that into one import is the one place this repo departs from the
|
| 88 |
+
template's structure on purpose.
|
| 89 |
+
|
| 90 |
+
## Threat model
|
| 91 |
+
|
| 92 |
+
It is worth being precise about what the held-back labels do and do not buy.
|
| 93 |
+
|
| 94 |
+
**Prevented.** Self-reported numbers. Every leaderboard value was computed here from an
|
| 95 |
+
uploaded bundle that is still on file.
|
| 96 |
+
|
| 97 |
+
**Bounded.** Fitting the test set by repeated submission. The cooldown
|
| 98 |
+
(`HOURS_BETWEEN_SUBMISSIONS`, 12) and latest-submission-only ranking make this slow and
|
| 99 |
+
visible, but eleven scalars per attempt is still information. A determined participant
|
| 100 |
+
with months can extract some of it.
|
| 101 |
+
|
| 102 |
+
**Not prevented.** Sybil accounts. Hugging Face username validation is a typo check, not
|
| 103 |
+
an identity proof, and nothing here ties an account to a person. `BANNED_USERNAMES` in
|
| 104 |
+
`utils.py` is the manual remedy.
|
| 105 |
+
|
| 106 |
+
**Out of scope.** Training on the test proteins. The test entities are public by design —
|
| 107 |
+
you cannot predict for them otherwise — and PLUG's whole subject is what it costs when
|
| 108 |
+
training data resembles test data. The method report link and the proprietary-data flag
|
| 109 |
+
are how that gets disclosed, not prevented.
|
docs/scoring.md
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Scoring reference
|
| 2 |
+
|
| 3 |
+
How a submission bundle becomes eleven numbers and one PLUG Score. The code is
|
| 4 |
+
`plug_challenge/metrics.py` (the arithmetic), `scoring.py` (the dispatch) and
|
| 5 |
+
`aggregate.py` (the aggregation); the per-benchmark choices are declared in
|
| 6 |
+
`benchmarks.py`.
|
| 7 |
+
|
| 8 |
+
Every metric here is **higher is better** and every one is a rank statistic or a
|
| 9 |
+
threshold sweep — none of them depend on the absolute scale of your predictions.
|
| 10 |
+
|
| 11 |
+
## Per-benchmark metrics
|
| 12 |
+
|
| 13 |
+
| Benchmark | Primary | Secondary | Grouped over |
|
| 14 |
+
|---|---|---|---|
|
| 15 |
+
| `megascale` | Spearman's ρ | ρ per protein | `pdb` |
|
| 16 |
+
| `fireprot` | Spearman's ρ | ρ per protein | `pdb` |
|
| 17 |
+
| `dms` | **ρ per assay** | pooled ρ | `dms_id` |
|
| 18 |
+
| `cafa5` | Fmax, macro over branches | Fmax BP / MF / CC | — |
|
| 19 |
+
| `allobench` | AUROC | AUROC per protein | `target_id` |
|
| 20 |
+
| `passerrank` | AUROC | AUROC per protein | `uniprot` |
|
| 21 |
+
| `ppi` | AUROC | — | — |
|
| 22 |
+
| `shs27k` | Macro AUROC over 7 modes | — | — |
|
| 23 |
+
| `lp-pdbbind` | Spearman's ρ | — | — |
|
| 24 |
+
| `bindingdb` | Spearman's ρ | ρ per target | `target_key` |
|
| 25 |
+
| `atlas` | Spearman's ρ | ρ per chain | `pdb_chain` |
|
| 26 |
+
|
| 27 |
+
Two choices in that table are worth stating plainly, because they are judgement calls
|
| 28 |
+
rather than definitions:
|
| 29 |
+
|
| 30 |
+
- **`dms` is grouped by default and the others are not.** DMS assay scores share no
|
| 31 |
+
common scale, so a pooled correlation would largely measure between-assay spread;
|
| 32 |
+
`plug-baselines` scores DMS per assay and averages, and this follows it.
|
| 33 |
+
- **`atlas`, `allobench` and `passerrank` pool residues by default.** Their per-protein
|
| 34 |
+
means are arguably the better measurement — pooling lets a model win by getting
|
| 35 |
+
between-protein scale right — but `plug-baselines` reports the pooled value, so that is
|
| 36 |
+
the primary here and comparability with the published baselines is preserved. The
|
| 37 |
+
per-protein number is reported beside it. To swap them, reorder `metrics=(...)` for
|
| 38 |
+
those benchmarks in `benchmarks.py`; the first entry is the primary, and everything
|
| 39 |
+
downstream follows.
|
| 40 |
+
|
| 41 |
+
### Undefined values
|
| 42 |
+
|
| 43 |
+
A rank metric is undefined rather than zero when there is nothing to rank: a constant
|
| 44 |
+
prediction column, a single-class label column, a group with one member. These return
|
| 45 |
+
NaN (`metrics.UNDEFINED`), and:
|
| 46 |
+
|
| 47 |
+
- Constant prediction columns are **rejected at validation** for the rank-scored
|
| 48 |
+
benchmarks, so this cannot happen by accident. `cafa5` is exempt, because Fmax sweeps a
|
| 49 |
+
threshold rather than ranking and a constant confidence is well-defined there — see
|
| 50 |
+
`BenchmarkSpec.needs_varying_predictions`.
|
| 51 |
+
- A grouped metric **skips** undefined groups and averages the rest; every scorable group
|
| 52 |
+
counts once regardless of size.
|
| 53 |
+
- `macro_auroc` skips single-class modes — a STRING mode that no test pair carries says
|
| 54 |
+
nothing about the submission either way.
|
| 55 |
+
- A benchmark whose primary metric is NaN shows blank on the board and is excluded from
|
| 56 |
+
the PLUG Score's mean, with `Benchmarks` showing the reduced count.
|
| 57 |
+
|
| 58 |
+
### CAFA Fmax
|
| 59 |
+
|
| 60 |
+
`cafa5` is the one benchmark with a variable-length submission: one row per
|
| 61 |
+
`(protein, branch, term)` you predict, with a confidence in `[0, 1]`.
|
| 62 |
+
|
| 63 |
+
Fmax sweeps a threshold over `[0, 1]` in steps of 0.01. At each threshold, **precision is
|
| 64 |
+
averaged over the targets that predict at least one term** while **recall is averaged over
|
| 65 |
+
every annotated target**. That asymmetry is CAFA's, and it is the reason declining to
|
| 66 |
+
annotate a protein costs you recall but not precision — so a selective, confident
|
| 67 |
+
submission is a legitimate strategy rather than an exploit. Unannotated targets are
|
| 68 |
+
dropped from both averages.
|
| 69 |
+
|
| 70 |
+
Two implementations exist and are cross-checked against each other in the tests:
|
| 71 |
+
`metrics.fmax` is a faithful port of `plug-baselines`' dense version, and
|
| 72 |
+
`metrics.fmax_long` computes the same thing from the long-form triples a submission
|
| 73 |
+
actually carries. Only `fmax_long` runs in production — a dense `targets × terms` score
|
| 74 |
+
matrix for CAFA5 runs to hundreds of megabytes.
|
| 75 |
+
|
| 76 |
+
## The PLUG Score
|
| 77 |
+
|
| 78 |
+
```
|
| 79 |
+
PLUG Score = mean over benchmarks of normalise(primary metric)
|
| 80 |
+
|
| 81 |
+
normalise(v, (low, high)) = clip((v - low) / (high - low), 0, 1)
|
| 82 |
+
```
|
| 83 |
+
|
| 84 |
+
with `(low, high)` taken from each metric's natural range: `(-1, 1)` for Spearman,
|
| 85 |
+
`(0, 1)` for AUROC and Fmax. So:
|
| 86 |
+
|
| 87 |
+
| Raw | Normalised |
|
| 88 |
+
|---|---|
|
| 89 |
+
| ρ = 1.0 | 1.0 |
|
| 90 |
+
| ρ = 0.0 (chance) | 0.5 |
|
| 91 |
+
| ρ = −1.0 | 0.0 |
|
| 92 |
+
| AUROC = 1.0 | 1.0 |
|
| 93 |
+
| AUROC = 0.5 (chance) | 0.5 |
|
| 94 |
+
| Fmax = 0.4 | 0.4 |
|
| 95 |
+
|
| 96 |
+
Normalising first is the point: an unweighted mean of the raw values would give the
|
| 97 |
+
rank correlations twice the range of everything else, quietly weighting them double. A
|
| 98 |
+
random submission scores about 0.5 overall. A perfect one scores 1.0.
|
| 99 |
+
|
| 100 |
+
The PLUG Score depends **only on your own predictions**, so it does not move as other
|
| 101 |
+
entries arrive and it is safe to quote. `Mean rank` — the mean of your per-benchmark
|
| 102 |
+
ranks — is shown beside it as the relative view; that one does move.
|
| 103 |
+
|
| 104 |
+
## Bootstrap intervals
|
| 105 |
+
|
| 106 |
+
`metrics.bootstrap` resamples and reports a standard deviation per metric, with whole
|
| 107 |
+
**groups** as the resampling unit for the grouped metrics (a per-assay mean has as many
|
| 108 |
+
independent observations as there are assays, not as there are variants).
|
| 109 |
+
|
| 110 |
+
It is **off by default** (`BOOTSTRAP_SAMPLES=0`), because scoring runs inside the
|
| 111 |
+
submission request and 1000 resamples of eleven benchmarks is not a request-time
|
| 112 |
+
workload. Point estimates are exact either way; with it off, the `_std` columns are 0.
|
| 113 |
+
|
| 114 |
+
To compute intervals offline:
|
| 115 |
+
|
| 116 |
+
```bash
|
| 117 |
+
plug-challenge score my_submission.zip --ground-truth ./gt --bootstrap 1000
|
| 118 |
+
```
|
| 119 |
+
|
| 120 |
+
`cafa5` never bootstraps: a resample has to redraw whole targets and recount each one's
|
| 121 |
+
annotations, and a 101-point threshold sweep per resample is far too slow. Its `_std` is
|
| 122 |
+
always 0 and its point estimate is exact.
|
| 123 |
+
|
| 124 |
+
## What is stored
|
| 125 |
+
|
| 126 |
+
Per submission, `scores/<user>/<id>/scores.json` holds the identity fields, the
|
| 127 |
+
`plug_score`, and every metric flattened as `<benchmark>__<metric>_mean` /
|
| 128 |
+
`_std` plus `<benchmark>__n`. `leaderboard/entries.csv` is the same rows concatenated —
|
| 129 |
+
derived, and rebuildable from the score files with `plug-challenge rebuild`.
|
| 130 |
+
|
| 131 |
+
Ranking happens on read (`aggregate.build_leaderboard`): latest submission per entrant,
|
| 132 |
+
sorted by `plug_score`, with a per-benchmark rank and `mean_rank` added.
|
docs/submission-format.md
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Submission format
|
| 2 |
+
|
| 3 |
+
*Written for participants.*
|
| 4 |
+
|
| 5 |
+
A submission is **one `.zip`** containing **eleven files**, one per benchmark. Each file
|
| 6 |
+
may be `.csv` or `.parquet`.
|
| 7 |
+
|
| 8 |
+
```
|
| 9 |
+
plug_submission.zip
|
| 10 |
+
├── megascale.csv
|
| 11 |
+
├── fireprot.csv
|
| 12 |
+
├── dms.csv
|
| 13 |
+
├── cafa5.csv
|
| 14 |
+
├── allobench.csv
|
| 15 |
+
├── passerrank.csv
|
| 16 |
+
├── ppi.csv
|
| 17 |
+
├── shs27k.csv
|
| 18 |
+
├── lp-pdbbind.csv
|
| 19 |
+
├── bindingdb.csv
|
| 20 |
+
└── atlas.csv
|
| 21 |
+
```
|
| 22 |
+
|
| 23 |
+
A bundle zipped from a directory (`plug_submission/megascale.csv`) works too, and macOS's
|
| 24 |
+
`__MACOSX` entries are ignored.
|
| 25 |
+
|
| 26 |
+
## Don't hand-build it
|
| 27 |
+
|
| 28 |
+
```bash
|
| 29 |
+
pip install "plug-challenge @ git+https://huggingface.co/spaces/PrismScienceOrg/PLUG-challenge"
|
| 30 |
+
|
| 31 |
+
plug-challenge template ./my_submission # every file, with the right ids already in place
|
| 32 |
+
# ...overwrite the prediction columns...
|
| 33 |
+
cd my_submission && zip ../plug_submission.zip *.csv && cd ..
|
| 34 |
+
plug-challenge validate plug_submission.zip # the exact checks the Space runs
|
| 35 |
+
```
|
| 36 |
+
|
| 37 |
+
`validate` needs only the public test manifests. Pass `--data-dir` to point it at a local
|
| 38 |
+
copy of the [challenge data](https://huggingface.co/datasets/PrismScienceOrg/plug-challenge-data)
|
| 39 |
+
and it runs fully offline.
|
| 40 |
+
|
| 41 |
+
## The `datapoint_id`
|
| 42 |
+
|
| 43 |
+
Every file joins to the ground truth on `datapoint_id`, copied verbatim from that
|
| 44 |
+
benchmark's `test_manifest.parquet`. You never construct it; the manifest is the list of
|
| 45 |
+
exactly what to predict. Row order does not matter.
|
| 46 |
+
|
| 47 |
+
## Per-file columns
|
| 48 |
+
|
| 49 |
+
Ten of the eleven are **one row per test `datapoint_id`** — no duplicates, nothing
|
| 50 |
+
outside the test split, every row present:
|
| 51 |
+
|
| 52 |
+
| File | Columns | Prediction means |
|
| 53 |
+
|---|---|---|
|
| 54 |
+
| `megascale.csv` | `datapoint_id`, `pred` | ΔΔG in kcal/mol; destabilising is negative |
|
| 55 |
+
| `fireprot.csv` | `datapoint_id`, `pred` | ΔΔG in kcal/mol |
|
| 56 |
+
| `dms.csv` | `datapoint_id`, `pred` | Variant fitness; scored per assay, so only within-assay ranking matters |
|
| 57 |
+
| `allobench.csv` | `datapoint_id`, `pred` | Score that this residue is in an allosteric site; any monotone score |
|
| 58 |
+
| `passerrank.csv` | `datapoint_id`, `pred` | As above |
|
| 59 |
+
| `ppi.csv` | `datapoint_id`, `pred` | Score that the pair interacts. Pairs are undirected — your score should not depend on partner order |
|
| 60 |
+
| `lp-pdbbind.csv` | `datapoint_id`, `pred` | Binding affinity on LP-PDBBind's scale (−log Kd/Ki) |
|
| 61 |
+
| `bindingdb.csv` | `datapoint_id`, `pred` | Binding affinity on the benchmark's scale |
|
| 62 |
+
| `atlas.csv` | `datapoint_id`, `pred` | Per-residue RMSF in Å |
|
| 63 |
+
| `shs27k.csv` | `datapoint_id`, `pred_reaction`, `pred_binding`, `pred_catalysis`, `pred_activation`, `pred_inhibition`, `pred_ptmod`, `pred_expression` | One score per STRING mode; all seven required |
|
| 64 |
+
|
| 65 |
+
`cafa5.csv` is **long form**: one row per `(protein, branch, term)` you predict.
|
| 66 |
+
|
| 67 |
+
| Column | Type | Meaning |
|
| 68 |
+
|---|---|---|
|
| 69 |
+
| `datapoint_id` | string | The protein, from the manifest |
|
| 70 |
+
| `aspect` | string | `bp`, `mf` or `cc` |
|
| 71 |
+
| `term` | string | The GO term, e.g. `GO:0005515` |
|
| 72 |
+
| `score` | float | Confidence in `[0, 1]` |
|
| 73 |
+
|
| 74 |
+
```csv
|
| 75 |
+
datapoint_id,aspect,term,score
|
| 76 |
+
a1b2c3d4e5f60718,mf,GO:0005515,0.92
|
| 77 |
+
a1b2c3d4e5f60718,bp,GO:0006355,0.61
|
| 78 |
+
```
|
| 79 |
+
|
| 80 |
+
Terms you don't predict are simply absent, and a protein you decline to annotate
|
| 81 |
+
entirely is allowed — under Fmax that costs recall but not precision, so being selective
|
| 82 |
+
is a real strategy. Predict each `(protein, aspect, term)` at most once.
|
| 83 |
+
|
| 84 |
+
## Rules
|
| 85 |
+
|
| 86 |
+
1. **All eleven files.** A bundle missing one is rejected.
|
| 87 |
+
2. **Exactly the manifest's ids** for the ten row-per-datapoint files — nothing missing,
|
| 88 |
+
nothing extra, no duplicates. (`cafa5.csv` may cover fewer proteins, never more.)
|
| 89 |
+
3. **Column names are case-sensitive.**
|
| 90 |
+
4. **Finite numbers only** — no `NaN`, no `inf`, no blanks.
|
| 91 |
+
5. **No constant prediction columns** — for the ten benchmarks scored by a rank
|
| 92 |
+
statistic. Spearman and AUROC are undefined without variance, so this is rejected
|
| 93 |
+
rather than scored as zero. `cafa5` is exempt: Fmax sweeps a confidence threshold, so
|
| 94 |
+
giving every term you predict a score of `1.0` is fine.
|
| 95 |
+
6. `cafa5`'s `score` must be in `[0, 1]`. The other predictions are unbounded.
|
| 96 |
+
|
| 97 |
+
## Limits
|
| 98 |
+
|
| 99 |
+
One submission per Hugging Face account every **12 hours**, and only your **latest**
|
| 100 |
+
submission is ranked. Validate locally rather than using uploads as a syntax check — a
|
| 101 |
+
bundle that fails validation is not stored and does not start your cooldown, but a
|
| 102 |
+
successful one does.
|
| 103 |
+
|
| 104 |
+
## What you get back
|
| 105 |
+
|
| 106 |
+
Immediately, in the Submit tab: your per-benchmark primary metric, your PLUG Score, and a
|
| 107 |
+
submission id. See [`scoring.md`](scoring.md) for how each number is computed.
|
index.html
DELETED
|
@@ -1,19 +0,0 @@
|
|
| 1 |
-
<!doctype html>
|
| 2 |
-
<html>
|
| 3 |
-
<head>
|
| 4 |
-
<meta charset="utf-8" />
|
| 5 |
-
<meta name="viewport" content="width=device-width" />
|
| 6 |
-
<title>My static Space</title>
|
| 7 |
-
<link rel="stylesheet" href="style.css" />
|
| 8 |
-
</head>
|
| 9 |
-
<body>
|
| 10 |
-
<div class="card">
|
| 11 |
-
<h1>Welcome to your static Space!</h1>
|
| 12 |
-
<p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
|
| 13 |
-
<p>
|
| 14 |
-
Also don't forget to check the
|
| 15 |
-
<a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
|
| 16 |
-
</p>
|
| 17 |
-
</div>
|
| 18 |
-
</body>
|
| 19 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
leaderboards.py
ADDED
|
@@ -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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""The leaderboard tabs: one overall board plus one per benchmark.
|
| 2 |
+
|
| 3 |
+
All of them are views of a single stored table (``leaderboard/entries.csv`` in
|
| 4 |
+
the private repo): ``load_overall`` ranks by the PLUG Score across every
|
| 5 |
+
benchmark, and ``load_benchmark`` narrows the same rows to one benchmark's
|
| 6 |
+
metric columns and re-ranks by that benchmark's primary metric. Nothing here
|
| 7 |
+
recomputes a score — the numbers were computed once, when the submission was
|
| 8 |
+
accepted.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import tempfile
|
| 12 |
+
from collections.abc import Callable
|
| 13 |
+
from functools import partial
|
| 14 |
+
|
| 15 |
+
import gradio as gr
|
| 16 |
+
import pandas as pd
|
| 17 |
+
from gradio_leaderboard import ColumnFilter, Leaderboard
|
| 18 |
+
from loguru import logger
|
| 19 |
+
|
| 20 |
+
from plug_challenge import BENCHMARKS, BenchmarkSpec, aggregate, store
|
| 21 |
+
from utils import make_tag_clickable, make_user_clickable
|
| 22 |
+
|
| 23 |
+
# A board's data source: called with no arguments for the rendered view, or with
|
| 24 |
+
# for_download=True for the CSV export.
|
| 25 |
+
BoardLoader = Callable[..., pd.DataFrame]
|
| 26 |
+
|
| 27 |
+
# How often the tables re-read the stored leaderboard, in seconds. Reads are
|
| 28 |
+
# served from store.read_leaderboard's short-lived cache, so several open tabs
|
| 29 |
+
# do not multiply into several Hub requests.
|
| 30 |
+
REFRESH_SECONDS = 30
|
| 31 |
+
|
| 32 |
+
_IDENTITY_DISPLAY = {
|
| 33 |
+
"rank": "Rank",
|
| 34 |
+
"username": "Entrant",
|
| 35 |
+
"submitted_at": "Submitted",
|
| 36 |
+
"plug_score": "PLUG Score",
|
| 37 |
+
"mean_rank": "Mean Rank",
|
| 38 |
+
"benchmarks_scored": "Benchmarks",
|
| 39 |
+
"model_report_link": "Method Report",
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
_OVERALL_BASE_COLUMNS = [
|
| 43 |
+
"Rank",
|
| 44 |
+
"Entrant",
|
| 45 |
+
"PLUG Score",
|
| 46 |
+
"Mean Rank",
|
| 47 |
+
"Benchmarks",
|
| 48 |
+
"Submitted",
|
| 49 |
+
"Method Report",
|
| 50 |
+
"Proprietary Data",
|
| 51 |
+
"Open Code",
|
| 52 |
+
]
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
def _empty(columns: list[str]) -> pd.DataFrame:
|
| 56 |
+
"""Build a placeholder table, shown before the first submission or on a read failure."""
|
| 57 |
+
return pd.DataFrame(columns=columns)
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
def _ranked() -> pd.DataFrame:
|
| 61 |
+
"""Read the stored entries and rank them.
|
| 62 |
+
|
| 63 |
+
Returns
|
| 64 |
+
-------
|
| 65 |
+
pd.DataFrame
|
| 66 |
+
The output of ``aggregate.build_leaderboard`` — one row per entrant,
|
| 67 |
+
ranked — or an empty frame when nothing has been submitted yet.
|
| 68 |
+
|
| 69 |
+
"""
|
| 70 |
+
raw = store.read_leaderboard()
|
| 71 |
+
if raw.empty:
|
| 72 |
+
return pd.DataFrame()
|
| 73 |
+
return aggregate.build_leaderboard(raw.to_dict(orient="records"), BENCHMARKS)
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
def _format_shared(df: pd.DataFrame, for_download: bool) -> pd.DataFrame:
|
| 77 |
+
"""Apply the formatting every board shares: timestamps, flags, links."""
|
| 78 |
+
df = df.copy()
|
| 79 |
+
df["submitted_at"] = pd.to_datetime(df["submitted_at"], utc=True, errors="coerce").dt.strftime(
|
| 80 |
+
"%Y-%m-%d %H:%M UTC"
|
| 81 |
+
)
|
| 82 |
+
for source, label in (
|
| 83 |
+
("used_proprietary_data", "Proprietary Data"),
|
| 84 |
+
("open_source_code", "Open Code"),
|
| 85 |
+
):
|
| 86 |
+
df[label] = (
|
| 87 |
+
df[source].fillna(False).astype(bool).map({True: "Yes", False: "No"})
|
| 88 |
+
if source in df.columns
|
| 89 |
+
else "No"
|
| 90 |
+
)
|
| 91 |
+
df = df.drop(
|
| 92 |
+
columns=[
|
| 93 |
+
"used_proprietary_data",
|
| 94 |
+
"open_source_code",
|
| 95 |
+
"safe_username",
|
| 96 |
+
"anonymous",
|
| 97 |
+
"submission_id",
|
| 98 |
+
],
|
| 99 |
+
errors="ignore",
|
| 100 |
+
)
|
| 101 |
+
if not for_download:
|
| 102 |
+
df["username"] = df["username"].astype(str).map(make_user_clickable)
|
| 103 |
+
df["model_report_link"] = df["model_report_link"].astype(str).map(make_tag_clickable)
|
| 104 |
+
return df.rename(columns=_IDENTITY_DISPLAY)
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
def load_overall(for_download: bool = False) -> pd.DataFrame:
|
| 108 |
+
"""Build the overall leaderboard: PLUG Score plus every benchmark's primary metric.
|
| 109 |
+
|
| 110 |
+
Parameters
|
| 111 |
+
----------
|
| 112 |
+
for_download : bool
|
| 113 |
+
Keep plain text (no HTML links) and full precision for the CSV export.
|
| 114 |
+
|
| 115 |
+
Returns
|
| 116 |
+
-------
|
| 117 |
+
pd.DataFrame
|
| 118 |
+
The overall board, best PLUG Score first.
|
| 119 |
+
|
| 120 |
+
"""
|
| 121 |
+
metric_labels = [spec.label for spec in BENCHMARKS]
|
| 122 |
+
ranked = _ranked()
|
| 123 |
+
if ranked.empty:
|
| 124 |
+
return _empty(_OVERALL_BASE_COLUMNS + metric_labels)
|
| 125 |
+
|
| 126 |
+
df = _format_shared(ranked, for_download)
|
| 127 |
+
for spec in BENCHMARKS:
|
| 128 |
+
source = aggregate.column(spec.name, spec.primary)
|
| 129 |
+
df[spec.label] = (
|
| 130 |
+
pd.to_numeric(df[source], errors="coerce") if source in df.columns else pd.NA
|
| 131 |
+
)
|
| 132 |
+
for column in ["PLUG Score", "Mean Rank", *metric_labels]:
|
| 133 |
+
if column in df.columns and not for_download:
|
| 134 |
+
df[column] = pd.to_numeric(df[column], errors="coerce").round(4)
|
| 135 |
+
columns = [c for c in _OVERALL_BASE_COLUMNS if c in df.columns] + metric_labels
|
| 136 |
+
logger.info("Overall leaderboard: {} entrant(s).", len(df))
|
| 137 |
+
return df[columns]
|
| 138 |
+
|
| 139 |
+
|
| 140 |
+
def load_benchmark(spec: BenchmarkSpec, for_download: bool = False) -> pd.DataFrame:
|
| 141 |
+
"""Build one benchmark's leaderboard, ranked by that benchmark's primary metric.
|
| 142 |
+
|
| 143 |
+
Parameters
|
| 144 |
+
----------
|
| 145 |
+
spec : BenchmarkSpec
|
| 146 |
+
The benchmark to narrow to.
|
| 147 |
+
for_download : bool
|
| 148 |
+
Keep plain text and full precision for the CSV export.
|
| 149 |
+
|
| 150 |
+
Returns
|
| 151 |
+
-------
|
| 152 |
+
pd.DataFrame
|
| 153 |
+
Entrants with a score for this benchmark, best first. Entrants with no
|
| 154 |
+
score here are dropped rather than ranked last, so the row count is the
|
| 155 |
+
number of methods that actually entered this benchmark.
|
| 156 |
+
|
| 157 |
+
"""
|
| 158 |
+
metric_labels = [metric.label for metric in spec.metrics]
|
| 159 |
+
base = [
|
| 160 |
+
"Rank",
|
| 161 |
+
"Entrant",
|
| 162 |
+
*metric_labels,
|
| 163 |
+
"Submitted",
|
| 164 |
+
"Method Report",
|
| 165 |
+
"Proprietary Data",
|
| 166 |
+
"Open Code",
|
| 167 |
+
]
|
| 168 |
+
ranked = _ranked()
|
| 169 |
+
primary_column = aggregate.column(spec.name, spec.primary)
|
| 170 |
+
if ranked.empty or primary_column not in ranked.columns:
|
| 171 |
+
return _empty(base)
|
| 172 |
+
|
| 173 |
+
df = ranked[pd.to_numeric(ranked[primary_column], errors="coerce").notna()].copy()
|
| 174 |
+
if df.empty:
|
| 175 |
+
return _empty(base)
|
| 176 |
+
df = df.sort_values(
|
| 177 |
+
primary_column, ascending=not spec.primary.higher_is_better
|
| 178 |
+
).reset_index(drop=True)
|
| 179 |
+
df["rank"] = range(1, len(df) + 1)
|
| 180 |
+
|
| 181 |
+
df = _format_shared(df, for_download)
|
| 182 |
+
for metric in spec.metrics:
|
| 183 |
+
source = aggregate.column(spec.name, metric)
|
| 184 |
+
values = (
|
| 185 |
+
pd.to_numeric(df[source], errors="coerce") if source in df.columns else pd.NA
|
| 186 |
+
)
|
| 187 |
+
df[metric.label] = (
|
| 188 |
+
values if for_download else pd.to_numeric(values, errors="coerce").round(4)
|
| 189 |
+
)
|
| 190 |
+
std_source = aggregate.column(spec.name, metric, "std")
|
| 191 |
+
if for_download and std_source in df.columns:
|
| 192 |
+
df[f"{metric.label} std"] = pd.to_numeric(df[std_source], errors="coerce")
|
| 193 |
+
columns = [c for c in base if c in df.columns]
|
| 194 |
+
if for_download:
|
| 195 |
+
columns += [f"{m.label} std" for m in spec.metrics if f"{m.label} std" in df.columns]
|
| 196 |
+
logger.info("{} leaderboard: {} entrant(s).", spec.name, len(df))
|
| 197 |
+
return df[columns]
|
| 198 |
+
|
| 199 |
+
|
| 200 |
+
def _download(loader: BoardLoader) -> str:
|
| 201 |
+
"""Write a board to a temp CSV and return its path."""
|
| 202 |
+
frame = loader(for_download=True)
|
| 203 |
+
with tempfile.NamedTemporaryFile(
|
| 204 |
+
"w", suffix=".csv", prefix="plug_leaderboard_", delete=False
|
| 205 |
+
) as handle:
|
| 206 |
+
frame.to_csv(handle, index=False)
|
| 207 |
+
return handle.name
|
| 208 |
+
|
| 209 |
+
|
| 210 |
+
def _table(
|
| 211 |
+
loader: BoardLoader, numeric_columns: list[str], search_column: str = "Entrant"
|
| 212 |
+
) -> Leaderboard:
|
| 213 |
+
"""Render one board: download button, table, and the disclosure filters."""
|
| 214 |
+
download_btn = gr.DownloadButton(label="Download CSV", size="sm")
|
| 215 |
+
download_btn.click(fn=partial(_download, loader), outputs=download_btn)
|
| 216 |
+
value = loader()
|
| 217 |
+
return Leaderboard(
|
| 218 |
+
value=value,
|
| 219 |
+
select_columns=list(value.columns),
|
| 220 |
+
search_columns=[search_column],
|
| 221 |
+
filter_columns=[
|
| 222 |
+
ColumnFilter(
|
| 223 |
+
"Proprietary Data",
|
| 224 |
+
type="checkboxgroup",
|
| 225 |
+
label="Proprietary Data",
|
| 226 |
+
choices=[("Yes", "Yes"), ("No", "No")],
|
| 227 |
+
default=[("Yes", "Yes"), ("No", "No")],
|
| 228 |
+
),
|
| 229 |
+
ColumnFilter(
|
| 230 |
+
"Open Code",
|
| 231 |
+
type="checkboxgroup",
|
| 232 |
+
label="Open Code",
|
| 233 |
+
choices=[("Yes", "Yes"), ("No", "No")],
|
| 234 |
+
default=[("Yes", "Yes"), ("No", "No")],
|
| 235 |
+
),
|
| 236 |
+
],
|
| 237 |
+
datatype=[
|
| 238 |
+
"number"
|
| 239 |
+
if column in numeric_columns
|
| 240 |
+
else ("html" if column in ("Entrant", "Method Report") else "str")
|
| 241 |
+
for column in value.columns
|
| 242 |
+
],
|
| 243 |
+
)
|
| 244 |
+
|
| 245 |
+
|
| 246 |
+
def render_leaderboards(phase: int, demo: gr.Blocks) -> None:
|
| 247 |
+
"""Render every leaderboard tab.
|
| 248 |
+
|
| 249 |
+
Parameters
|
| 250 |
+
----------
|
| 251 |
+
phase : int
|
| 252 |
+
``config.CURRENT_PHASE``. Phase 0 shows a placeholder; phase 2 labels the
|
| 253 |
+
board as the final standings.
|
| 254 |
+
demo : gr.Blocks
|
| 255 |
+
The app's Blocks instance, used to refresh each table on page load so a
|
| 256 |
+
visitor sees current data rather than the snapshot baked in at build
|
| 257 |
+
time.
|
| 258 |
+
|
| 259 |
+
"""
|
| 260 |
+
if phase == 0:
|
| 261 |
+
gr.Markdown(
|
| 262 |
+
"# Leaderboard (coming soon)\n\n"
|
| 263 |
+
"The challenge has not started yet. Standings appear here once submissions open."
|
| 264 |
+
)
|
| 265 |
+
return
|
| 266 |
+
|
| 267 |
+
gr.Markdown(
|
| 268 |
+
"# Final standings" if phase >= 2 else "# Leaderboard",
|
| 269 |
+
elem_id="leaderboard-heading",
|
| 270 |
+
)
|
| 271 |
+
gr.Markdown(
|
| 272 |
+
"Ranked by **PLUG Score** — the mean of the eleven normalised primary metrics "
|
| 273 |
+
"(see **About → Scoring**). Each benchmark's own tab re-ranks by that benchmark's "
|
| 274 |
+
"metric and adds its secondary metrics. Only each entrant's latest submission is "
|
| 275 |
+
"shown."
|
| 276 |
+
+ ("" if phase >= 2 else f" Refreshes every {REFRESH_SECONDS} seconds.")
|
| 277 |
+
)
|
| 278 |
+
|
| 279 |
+
timer = gr.Timer(value=REFRESH_SECONDS) if phase < 2 else None
|
| 280 |
+
tables: list[tuple[Leaderboard, BoardLoader]] = []
|
| 281 |
+
|
| 282 |
+
with gr.Tabs():
|
| 283 |
+
with gr.TabItem("🏆 Overall"):
|
| 284 |
+
overall_numeric = ["Rank", "PLUG Score", "Mean Rank", "Benchmarks"] + [
|
| 285 |
+
spec.label for spec in BENCHMARKS
|
| 286 |
+
]
|
| 287 |
+
tables.append((_table(load_overall, overall_numeric), load_overall))
|
| 288 |
+
for spec in BENCHMARKS:
|
| 289 |
+
with gr.TabItem(spec.label):
|
| 290 |
+
gr.Markdown(f"*{spec.description}*")
|
| 291 |
+
loader = partial(load_benchmark, spec)
|
| 292 |
+
numeric = ["Rank", *[metric.label for metric in spec.metrics]]
|
| 293 |
+
tables.append((_table(loader, numeric), loader))
|
| 294 |
+
|
| 295 |
+
triggers = [demo.load] + ([timer.tick] if timer is not None else [])
|
| 296 |
+
for table, board_loader in tables:
|
| 297 |
+
gr.on(triggers=triggers, fn=board_loader, outputs=[table])
|
models.py
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Pydantic model for a PLUG challenge submission."""
|
| 2 |
+
|
| 3 |
+
import uuid
|
| 4 |
+
from datetime import UTC, datetime
|
| 5 |
+
|
| 6 |
+
from pydantic import BaseModel, ConfigDict, Field, model_validator
|
| 7 |
+
|
| 8 |
+
from utils import safeify_username
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
class Submission(BaseModel):
|
| 12 |
+
"""One competition submission: a bundle plus who sent it.
|
| 13 |
+
|
| 14 |
+
Serialised to JSON and stored beside the uploaded bundle in the private
|
| 15 |
+
dataset repo. Only the non-private fields ever reach the leaderboard.
|
| 16 |
+
|
| 17 |
+
Unlike the template this is modelled on, there is no ``track`` field — a PLUG
|
| 18 |
+
submission always covers every benchmark in one bundle, so the benchmark
|
| 19 |
+
breakdown lives in the scores rather than in the submission's identity.
|
| 20 |
+
|
| 21 |
+
Attributes
|
| 22 |
+
----------
|
| 23 |
+
model_config
|
| 24 |
+
``protected_namespaces=()`` disables Pydantic's "model_" warning, which
|
| 25 |
+
would otherwise fire on ``model_report_link``.
|
| 26 |
+
submission_id : str
|
| 27 |
+
Auto-generated UUID; the storage path component.
|
| 28 |
+
submitted_at : datetime
|
| 29 |
+
UTC timestamp of submission.
|
| 30 |
+
username : str
|
| 31 |
+
Hugging Face username. Required, and the deduplication key: only a
|
| 32 |
+
user's latest submission is ranked.
|
| 33 |
+
safe_username : str
|
| 34 |
+
Path-safe form of ``username``, derived automatically.
|
| 35 |
+
user_alias : str
|
| 36 |
+
Display name shown instead of the username for anonymous entries.
|
| 37 |
+
anonymous : bool
|
| 38 |
+
If True, show ``user_alias`` on the leaderboard.
|
| 39 |
+
participant_name : str
|
| 40 |
+
Real name — stored privately, never displayed.
|
| 41 |
+
discord_username : str
|
| 42 |
+
Contact handle — stored privately.
|
| 43 |
+
email : str
|
| 44 |
+
Contact email — stored privately.
|
| 45 |
+
affiliation : str
|
| 46 |
+
Institutional affiliation — stored privately.
|
| 47 |
+
model_report_link : str
|
| 48 |
+
URL to a method report or code repository; displayed on the leaderboard.
|
| 49 |
+
used_proprietary_data : bool
|
| 50 |
+
Whether non-public training data was used. Displayed publicly.
|
| 51 |
+
open_source_code : bool
|
| 52 |
+
Whether the method's code is public. Displayed publicly.
|
| 53 |
+
filename : str
|
| 54 |
+
Original uploaded filename.
|
| 55 |
+
bundle_path : str
|
| 56 |
+
Path the bundle was stored at in the private repo.
|
| 57 |
+
|
| 58 |
+
"""
|
| 59 |
+
|
| 60 |
+
model_config = ConfigDict(protected_namespaces=())
|
| 61 |
+
|
| 62 |
+
# --- generated ---
|
| 63 |
+
submission_id: str = Field(default_factory=lambda: str(uuid.uuid4()))
|
| 64 |
+
submitted_at: datetime = Field(default_factory=lambda: datetime.now(UTC))
|
| 65 |
+
|
| 66 |
+
# --- public identity ---
|
| 67 |
+
username: str
|
| 68 |
+
safe_username: str = ""
|
| 69 |
+
user_alias: str = ""
|
| 70 |
+
anonymous: bool = True
|
| 71 |
+
|
| 72 |
+
# --- private contact ---
|
| 73 |
+
participant_name: str = ""
|
| 74 |
+
discord_username: str = ""
|
| 75 |
+
email: str = ""
|
| 76 |
+
affiliation: str = ""
|
| 77 |
+
|
| 78 |
+
# --- public disclosures ---
|
| 79 |
+
model_report_link: str = ""
|
| 80 |
+
used_proprietary_data: bool = False
|
| 81 |
+
open_source_code: bool = False
|
| 82 |
+
|
| 83 |
+
# --- submission ---
|
| 84 |
+
filename: str = ""
|
| 85 |
+
bundle_path: str = ""
|
| 86 |
+
|
| 87 |
+
@model_validator(mode="after")
|
| 88 |
+
def _populate_safe_username(self) -> "Submission":
|
| 89 |
+
"""Derive ``safe_username`` from ``username`` after construction."""
|
| 90 |
+
self.safe_username = safeify_username(self.username)
|
| 91 |
+
return self
|
| 92 |
+
|
| 93 |
+
@property
|
| 94 |
+
def display_name(self) -> str:
|
| 95 |
+
"""Name to show on the leaderboard."""
|
| 96 |
+
if self.anonymous and self.user_alias:
|
| 97 |
+
return self.user_alias
|
| 98 |
+
return self.username
|
| 99 |
+
|
| 100 |
+
def public_fields(self) -> dict:
|
| 101 |
+
"""Return the identity columns that go into a leaderboard row.
|
| 102 |
+
|
| 103 |
+
``username`` is the display name, so an anonymous entry never writes the
|
| 104 |
+
real account name into the leaderboard file; ``safe_username`` is kept as
|
| 105 |
+
the (non-displayed) deduplication and cooldown key.
|
| 106 |
+
|
| 107 |
+
Returns
|
| 108 |
+
-------
|
| 109 |
+
dict
|
| 110 |
+
Leaderboard identity columns for this submission.
|
| 111 |
+
|
| 112 |
+
"""
|
| 113 |
+
return {
|
| 114 |
+
"submission_id": self.submission_id,
|
| 115 |
+
"submitted_at": self.submitted_at.isoformat(),
|
| 116 |
+
"username": self.display_name,
|
| 117 |
+
"safe_username": self.safe_username,
|
| 118 |
+
"anonymous": self.anonymous,
|
| 119 |
+
"model_report_link": self.model_report_link,
|
| 120 |
+
"used_proprietary_data": self.used_proprietary_data,
|
| 121 |
+
"open_source_code": self.open_source_code,
|
| 122 |
+
}
|
plug_challenge/__init__.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Scoring library for the PLUG challenge.
|
| 2 |
+
|
| 3 |
+
The eleven benchmarks and their metrics are declared in ``benchmarks``; the rest
|
| 4 |
+
of the package is the pipeline over them:
|
| 5 |
+
|
| 6 |
+
``metrics``
|
| 7 |
+
Bare metric functions, ported from ``plug-baselines`` so a leaderboard
|
| 8 |
+
number and a published baseline number are the same arithmetic.
|
| 9 |
+
``validation``
|
| 10 |
+
Whether a submission bundle is scorable, and why not.
|
| 11 |
+
``scoring``
|
| 12 |
+
Validated predictions plus ground truth -> per-benchmark metric values.
|
| 13 |
+
``aggregate``
|
| 14 |
+
Eleven benchmarks -> the PLUG Score and a ranked leaderboard.
|
| 15 |
+
``store``
|
| 16 |
+
Reading and writing all of it on the Hugging Face Hub.
|
| 17 |
+
``cli``
|
| 18 |
+
``plug-challenge validate`` for participants; ``score`` / ``rebuild`` /
|
| 19 |
+
``template`` for organisers.
|
| 20 |
+
"""
|
| 21 |
+
|
| 22 |
+
from .benchmarks import BENCHMARK_NAMES, BENCHMARKS, BENCHMARKS_BY_NAME, BenchmarkSpec
|
| 23 |
+
|
| 24 |
+
__all__ = ["BENCHMARKS", "BENCHMARKS_BY_NAME", "BENCHMARK_NAMES", "BenchmarkSpec"]
|
| 25 |
+
|
| 26 |
+
__version__ = "0.1.0"
|
plug_challenge/aggregate.py
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Aggregating eleven benchmarks into one leaderboard.
|
| 2 |
+
|
| 3 |
+
The per-benchmark numbers are not on one scale — Spearman's rho runs over
|
| 4 |
+
``[-1, 1]``, AUROC and Fmax over ``[0, 1]`` — so an unweighted mean of the raw
|
| 5 |
+
values would quietly weight the rank correlations twice as heavily as the rest.
|
| 6 |
+
``normalise`` puts every metric on ``[0, 1]`` first, and their mean is the **PLUG
|
| 7 |
+
Score**.
|
| 8 |
+
|
| 9 |
+
The PLUG Score is deterministic: it depends only on a submission's own
|
| 10 |
+
predictions, so a number stays the same as other entries arrive and is safe to
|
| 11 |
+
quote in a paper. ``mean_rank`` is reported next to it as the relative view, and
|
| 12 |
+
that one does move as the field fills in.
|
| 13 |
+
"""
|
| 14 |
+
|
| 15 |
+
import numpy as np
|
| 16 |
+
import pandas as pd
|
| 17 |
+
|
| 18 |
+
from .benchmarks import BENCHMARKS, BenchmarkSpec, MetricSpec
|
| 19 |
+
|
| 20 |
+
# Column prefix separator for the flattened per-benchmark metric columns in a
|
| 21 |
+
# leaderboard row: "megascale__spearman_mean". Double underscore because several
|
| 22 |
+
# benchmark names and metric keys contain single underscores.
|
| 23 |
+
SEP = "__"
|
| 24 |
+
|
| 25 |
+
# Public leaderboard columns that are not per-benchmark metrics, in display order.
|
| 26 |
+
IDENTITY_COLUMNS = (
|
| 27 |
+
"rank",
|
| 28 |
+
"username",
|
| 29 |
+
"submitted_at",
|
| 30 |
+
"plug_score",
|
| 31 |
+
"mean_rank",
|
| 32 |
+
"benchmarks_scored",
|
| 33 |
+
"model_report_link",
|
| 34 |
+
"used_proprietary_data",
|
| 35 |
+
"open_source_code",
|
| 36 |
+
)
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
def normalise(value: float, scale: tuple[float, float]) -> float:
|
| 40 |
+
"""Map a metric value onto ``[0, 1]`` given its natural range.
|
| 41 |
+
|
| 42 |
+
A Spearman correlation of 0 (no better than chance) normalises to 0.5, the
|
| 43 |
+
same place an AUROC of 0.5 lands, so the two contribute comparably to the
|
| 44 |
+
mean. Values outside the declared range are clipped rather than rejected —
|
| 45 |
+
only ``scale`` bounds can be exceeded, and only by floating-point slack.
|
| 46 |
+
|
| 47 |
+
Parameters
|
| 48 |
+
----------
|
| 49 |
+
value : float
|
| 50 |
+
The raw metric value.
|
| 51 |
+
scale : tuple[float, float]
|
| 52 |
+
The metric's ``(low, high)`` natural range, from its ``MetricSpec``.
|
| 53 |
+
|
| 54 |
+
Returns
|
| 55 |
+
-------
|
| 56 |
+
float
|
| 57 |
+
The normalised value, or NaN if ``value`` is not finite.
|
| 58 |
+
|
| 59 |
+
"""
|
| 60 |
+
if not np.isfinite(value):
|
| 61 |
+
return float("nan")
|
| 62 |
+
low, high = scale
|
| 63 |
+
return float(np.clip((value - low) / (high - low), 0.0, 1.0))
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
def plug_score(
|
| 67 |
+
scores: dict[str, dict[str, float]], specs: tuple[BenchmarkSpec, ...] = BENCHMARKS
|
| 68 |
+
) -> float:
|
| 69 |
+
"""Compute the headline number: mean normalised primary metric across benchmarks.
|
| 70 |
+
|
| 71 |
+
Parameters
|
| 72 |
+
----------
|
| 73 |
+
scores : dict[str, dict[str, float]]
|
| 74 |
+
Per-benchmark metric values, as returned by ``scoring.score_bundle``.
|
| 75 |
+
specs : tuple[BenchmarkSpec, ...]
|
| 76 |
+
The benchmarks the challenge runs.
|
| 77 |
+
|
| 78 |
+
Returns
|
| 79 |
+
-------
|
| 80 |
+
float
|
| 81 |
+
Mean over the benchmarks with a finite primary metric, on ``[0, 1]``, or
|
| 82 |
+
NaN when none are scorable. Benchmarks that are absent do not count
|
| 83 |
+
toward the denominator, so ``benchmarks_scored`` is reported alongside it
|
| 84 |
+
— a partial bundle is not silently rewarded for what it skipped.
|
| 85 |
+
|
| 86 |
+
"""
|
| 87 |
+
values = [
|
| 88 |
+
normalise(scores[spec.name][f"{spec.primary.key}_mean"], spec.primary.scale)
|
| 89 |
+
for spec in specs
|
| 90 |
+
if spec.name in scores and f"{spec.primary.key}_mean" in scores[spec.name]
|
| 91 |
+
]
|
| 92 |
+
finite = [v for v in values if np.isfinite(v)]
|
| 93 |
+
return float(np.mean(finite)) if finite else float("nan")
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
def flatten(scores: dict[str, dict[str, float]]) -> dict[str, float]:
|
| 97 |
+
"""Flatten nested per-benchmark scores into leaderboard columns.
|
| 98 |
+
|
| 99 |
+
Parameters
|
| 100 |
+
----------
|
| 101 |
+
scores : dict[str, dict[str, float]]
|
| 102 |
+
Per-benchmark metric values.
|
| 103 |
+
|
| 104 |
+
Returns
|
| 105 |
+
-------
|
| 106 |
+
dict[str, float]
|
| 107 |
+
``{"megascale__spearman_mean": ..., "megascale__n": ..., ...}``.
|
| 108 |
+
|
| 109 |
+
"""
|
| 110 |
+
return {
|
| 111 |
+
f"{benchmark}{SEP}{key}": value
|
| 112 |
+
for benchmark, benchmark_scores in scores.items()
|
| 113 |
+
for key, value in benchmark_scores.items()
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
def column(benchmark: str, metric: MetricSpec, statistic: str = "mean") -> str:
|
| 118 |
+
"""Name of the flattened leaderboard column for one benchmark's metric.
|
| 119 |
+
|
| 120 |
+
Parameters
|
| 121 |
+
----------
|
| 122 |
+
benchmark : str
|
| 123 |
+
Benchmark name.
|
| 124 |
+
metric : MetricSpec
|
| 125 |
+
The metric.
|
| 126 |
+
statistic : str
|
| 127 |
+
``"mean"`` or ``"std"``.
|
| 128 |
+
|
| 129 |
+
Returns
|
| 130 |
+
-------
|
| 131 |
+
str
|
| 132 |
+
e.g. ``"megascale__spearman_mean"``.
|
| 133 |
+
|
| 134 |
+
"""
|
| 135 |
+
return f"{benchmark}{SEP}{metric.key}_{statistic}"
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
def build_leaderboard(
|
| 139 |
+
entries: list[dict], specs: tuple[BenchmarkSpec, ...] = BENCHMARKS
|
| 140 |
+
) -> pd.DataFrame:
|
| 141 |
+
"""Rank leaderboard entries and add the per-benchmark and overall rank columns.
|
| 142 |
+
|
| 143 |
+
Only a participant's **latest** submission is ranked: earlier ones are
|
| 144 |
+
dropped so the board shows one row per entrant, which is what makes
|
| 145 |
+
``mean_rank`` meaningful.
|
| 146 |
+
|
| 147 |
+
Parameters
|
| 148 |
+
----------
|
| 149 |
+
entries : list[dict]
|
| 150 |
+
One dict per submission — identity fields plus the flattened metric
|
| 151 |
+
columns from ``flatten``.
|
| 152 |
+
specs : tuple[BenchmarkSpec, ...]
|
| 153 |
+
The benchmarks the challenge runs, in display order.
|
| 154 |
+
|
| 155 |
+
Returns
|
| 156 |
+
-------
|
| 157 |
+
pd.DataFrame
|
| 158 |
+
One row per entrant, sorted best-first by ``plug_score``, with a 1-based
|
| 159 |
+
``rank``, a ``<benchmark>__rank`` per benchmark, and ``mean_rank``.
|
| 160 |
+
Returns an empty frame with the expected columns when ``entries`` is
|
| 161 |
+
empty.
|
| 162 |
+
|
| 163 |
+
"""
|
| 164 |
+
if not entries:
|
| 165 |
+
return pd.DataFrame(columns=list(IDENTITY_COLUMNS))
|
| 166 |
+
|
| 167 |
+
df = pd.DataFrame(entries)
|
| 168 |
+
df["submitted_at"] = pd.to_datetime(df["submitted_at"], utc=True, errors="coerce")
|
| 169 |
+
df = (
|
| 170 |
+
df.sort_values("submitted_at")
|
| 171 |
+
.drop_duplicates(subset=["username"], keep="last")
|
| 172 |
+
.reset_index(drop=True)
|
| 173 |
+
)
|
| 174 |
+
|
| 175 |
+
rank_columns = []
|
| 176 |
+
for spec in specs:
|
| 177 |
+
metric_column = column(spec.name, spec.primary)
|
| 178 |
+
if metric_column not in df.columns:
|
| 179 |
+
continue
|
| 180 |
+
rank_column = f"{spec.name}{SEP}rank"
|
| 181 |
+
df[rank_column] = df[metric_column].rank(
|
| 182 |
+
ascending=not spec.primary.higher_is_better, method="min"
|
| 183 |
+
)
|
| 184 |
+
rank_columns.append(rank_column)
|
| 185 |
+
|
| 186 |
+
df["mean_rank"] = df[rank_columns].mean(axis=1) if rank_columns else np.nan
|
| 187 |
+
primary_columns = [
|
| 188 |
+
column(spec.name, spec.primary)
|
| 189 |
+
for spec in specs
|
| 190 |
+
if column(spec.name, spec.primary) in df.columns
|
| 191 |
+
]
|
| 192 |
+
df["benchmarks_scored"] = df[primary_columns].notna().sum(axis=1)
|
| 193 |
+
df = df.sort_values(
|
| 194 |
+
["plug_score", "mean_rank"], ascending=[False, True], na_position="last"
|
| 195 |
+
).reset_index(drop=True)
|
| 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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""The eleven PLUG benchmarks: submission schema, ground-truth schema, metrics.
|
| 2 |
+
|
| 3 |
+
This module is the **single source of truth** for the challenge. Everything else
|
| 4 |
+
— the submission validator, the scorer, the leaderboard builder, the Space's
|
| 5 |
+
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 must
|
| 10 |
+
carry all eleven (see ``config.REQUIRE_COMPLETE_BUNDLE``).
|
| 11 |
+
|
| 12 |
+
Naming
|
| 13 |
+
------
|
| 14 |
+
``entity`` is what a split is decided over (a protein, a PDB chain, a ligand);
|
| 15 |
+
``datapoint`` is one scored row (a mutation, a residue, a pair, a measurement).
|
| 16 |
+
An entity contributes many datapoints. ``datapoint_id`` is the stable join key
|
| 17 |
+
between a test manifest, a submission and the ground truth — see
|
| 18 |
+
``scripts/build_challenge_data.py`` for how it is derived.
|
| 19 |
+
"""
|
| 20 |
+
|
| 21 |
+
from dataclasses import dataclass, field
|
| 22 |
+
from typing import Literal
|
| 23 |
+
|
| 24 |
+
# The datapoint identifier column. Present in every test manifest, every
|
| 25 |
+
# ground-truth file, and required in every submission file — it is the only
|
| 26 |
+
# thing a participant has to echo back, so a submission never has to
|
| 27 |
+
# re-derive a composite key and the scorer never has to guess a row order.
|
| 28 |
+
ID_COLUMN = "datapoint_id"
|
| 29 |
+
|
| 30 |
+
# STRING interaction modes scored by shs27k, in a fixed order — the order of the
|
| 31 |
+
# per-mode columns in both the ground truth and a submission.
|
| 32 |
+
SHS27K_MODES = (
|
| 33 |
+
"reaction",
|
| 34 |
+
"binding",
|
| 35 |
+
"catalysis",
|
| 36 |
+
"activation",
|
| 37 |
+
"inhibition",
|
| 38 |
+
"ptmod",
|
| 39 |
+
"expression",
|
| 40 |
+
)
|
| 41 |
+
|
| 42 |
+
# The three GO branches scored by cafa5, in a fixed order.
|
| 43 |
+
GO_ASPECTS = ("bp", "mf", "cc")
|
| 44 |
+
|
| 45 |
+
MetricKind = Literal[
|
| 46 |
+
"spearman",
|
| 47 |
+
"grouped_spearman",
|
| 48 |
+
"auroc",
|
| 49 |
+
"grouped_auroc",
|
| 50 |
+
"macro_auroc",
|
| 51 |
+
"fmax",
|
| 52 |
+
]
|
| 53 |
+
|
| 54 |
+
TaskKind = Literal["regression", "binary", "multilabel", "go_terms"]
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
@dataclass(frozen=True)
|
| 58 |
+
class MetricSpec:
|
| 59 |
+
"""One number reported for one benchmark.
|
| 60 |
+
|
| 61 |
+
Attributes
|
| 62 |
+
----------
|
| 63 |
+
key : str
|
| 64 |
+
Column stem used in score files and leaderboard CSVs (e.g. ``spearman``
|
| 65 |
+
becomes ``spearman_mean`` / ``spearman_std``).
|
| 66 |
+
label : str
|
| 67 |
+
How the metric is labelled in the Space's leaderboard header.
|
| 68 |
+
kind : MetricKind
|
| 69 |
+
Which function in ``metrics.py`` computes it. ``scoring.py`` dispatches
|
| 70 |
+
on this.
|
| 71 |
+
higher_is_better : bool
|
| 72 |
+
Sort direction. Every PLUG metric happens to be higher-is-better, but
|
| 73 |
+
the leaderboard reads this rather than assuming it.
|
| 74 |
+
aspect : str
|
| 75 |
+
For ``fmax``, the GO branch to restrict to — one of ``GO_ASPECTS``, or
|
| 76 |
+
``""`` for the macro-average over all three.
|
| 77 |
+
grouped_by : str
|
| 78 |
+
For the ``grouped_*`` kinds, the ground-truth column holding the group
|
| 79 |
+
label.
|
| 80 |
+
scale : tuple[float, float]
|
| 81 |
+
The metric's natural range, used to normalise it onto ``[0, 1]`` for the
|
| 82 |
+
PLUG Score (see ``aggregate.normalise``). Spearman is ``(-1, 1)``;
|
| 83 |
+
AUROC and Fmax are ``(0, 1)``.
|
| 84 |
+
|
| 85 |
+
"""
|
| 86 |
+
|
| 87 |
+
key: str
|
| 88 |
+
label: str
|
| 89 |
+
kind: MetricKind
|
| 90 |
+
higher_is_better: bool = True
|
| 91 |
+
aspect: str = ""
|
| 92 |
+
grouped_by: str = ""
|
| 93 |
+
scale: tuple[float, float] = (0.0, 1.0)
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
@dataclass(frozen=True)
|
| 97 |
+
class BenchmarkSpec:
|
| 98 |
+
"""One PLUG benchmark: what participants upload and how it is scored.
|
| 99 |
+
|
| 100 |
+
Attributes
|
| 101 |
+
----------
|
| 102 |
+
name : str
|
| 103 |
+
The benchmark's ``plug`` registry name, and its directory name under
|
| 104 |
+
``data/``. Also the leaderboard tab slug.
|
| 105 |
+
label : str
|
| 106 |
+
Display name on the Space.
|
| 107 |
+
task : TaskKind
|
| 108 |
+
Shape of the prediction, which decides the validator applied
|
| 109 |
+
(``validation.py``) and the schema block rendered on the Submit tab.
|
| 110 |
+
filename : str
|
| 111 |
+
This benchmark's file inside the submission bundle.
|
| 112 |
+
pred_columns : tuple[str, ...]
|
| 113 |
+
Prediction columns a submission must carry, on top of ``ID_COLUMN``.
|
| 114 |
+
truth_columns : tuple[str, ...]
|
| 115 |
+
Label columns the ground-truth file carries, positionally matching
|
| 116 |
+
``pred_columns``.
|
| 117 |
+
metrics : tuple[MetricSpec, ...]
|
| 118 |
+
Every number reported for this benchmark. The **first** is the primary
|
| 119 |
+
metric: what the benchmark's own leaderboard sorts by and what feeds the
|
| 120 |
+
PLUG Score.
|
| 121 |
+
entity_column : str
|
| 122 |
+
The ground-truth column naming the entity a datapoint is about — the
|
| 123 |
+
unit the leakage-free split was decided over.
|
| 124 |
+
unit : str
|
| 125 |
+
What one scored row is, for participant-facing copy ("mutation",
|
| 126 |
+
"residue", "protein pair", ...).
|
| 127 |
+
long_form : bool
|
| 128 |
+
True for a benchmark whose submission has a variable number of rows per
|
| 129 |
+
datapoint (only ``cafa5``: one row per predicted GO term). A long-form
|
| 130 |
+
file is validated on the *set* of ids it covers rather than on an exact
|
| 131 |
+
row match.
|
| 132 |
+
extra_columns : tuple[str, ...]
|
| 133 |
+
Additional required submission columns for a long-form benchmark.
|
| 134 |
+
score_range : tuple[float, float] | None
|
| 135 |
+
When set, every prediction must fall inside this closed interval.
|
| 136 |
+
Probabilities are constrained to ``(0, 1)``; an unbounded regression
|
| 137 |
+
target leaves this ``None``.
|
| 138 |
+
allowed_values : dict[str, tuple[str, ...]]
|
| 139 |
+
Column -> the closed set of values it may take, for the categorical
|
| 140 |
+
columns of a long-form submission (cafa5's ``aspect``).
|
| 141 |
+
description : str
|
| 142 |
+
One line shown on the Submit tab and in the format docs.
|
| 143 |
+
|
| 144 |
+
"""
|
| 145 |
+
|
| 146 |
+
name: str
|
| 147 |
+
label: str
|
| 148 |
+
task: TaskKind
|
| 149 |
+
pred_columns: tuple[str, ...]
|
| 150 |
+
truth_columns: tuple[str, ...]
|
| 151 |
+
metrics: tuple[MetricSpec, ...]
|
| 152 |
+
entity_column: str
|
| 153 |
+
unit: str
|
| 154 |
+
description: str
|
| 155 |
+
long_form: bool = False
|
| 156 |
+
extra_columns: tuple[str, ...] = ()
|
| 157 |
+
score_range: tuple[float, float] | None = None
|
| 158 |
+
allowed_values: dict[str, tuple[str, ...]] = field(default_factory=dict)
|
| 159 |
+
manifest_columns: tuple[str, ...] = field(default=())
|
| 160 |
+
|
| 161 |
+
@property
|
| 162 |
+
def filename(self) -> str:
|
| 163 |
+
"""Name of this benchmark's file inside the submission bundle."""
|
| 164 |
+
return f"{self.name}.csv"
|
| 165 |
+
|
| 166 |
+
@property
|
| 167 |
+
def primary(self) -> MetricSpec:
|
| 168 |
+
"""The metric this benchmark's leaderboard sorts by and the PLUG Score uses."""
|
| 169 |
+
return self.metrics[0]
|
| 170 |
+
|
| 171 |
+
@property
|
| 172 |
+
def required_columns(self) -> tuple[str, ...]:
|
| 173 |
+
"""Every column a submission file for this benchmark must contain."""
|
| 174 |
+
return (ID_COLUMN, *self.extra_columns, *self.pred_columns)
|
| 175 |
+
|
| 176 |
+
@property
|
| 177 |
+
def needs_varying_predictions(self) -> bool:
|
| 178 |
+
"""Whether a constant prediction column makes this benchmark unscorable.
|
| 179 |
+
|
| 180 |
+
True for the rank statistics (Spearman, AUROC), which are undefined with
|
| 181 |
+
zero variance — a constant column there is rejected at validation rather
|
| 182 |
+
than scored as NaN.
|
| 183 |
+
|
| 184 |
+
False for Fmax, which sweeps a confidence threshold rather than ranking:
|
| 185 |
+
predicting every term at 1.0 means "I am confident in all of these", which
|
| 186 |
+
is a legitimate (and common) CAFA submission and scores perfectly well.
|
| 187 |
+
"""
|
| 188 |
+
return any(metric.kind != "fmax" for metric in self.metrics)
|
| 189 |
+
|
| 190 |
+
|
| 191 |
+
_SPEARMAN_SCALE = (-1.0, 1.0)
|
| 192 |
+
|
| 193 |
+
SPEARMAN = MetricSpec(
|
| 194 |
+
key="spearman", label="Spearman's ρ", kind="spearman", scale=_SPEARMAN_SCALE
|
| 195 |
+
)
|
| 196 |
+
AUROC = MetricSpec(key="auroc", label="AUROC", kind="auroc")
|
| 197 |
+
|
| 198 |
+
|
| 199 |
+
def _per_entity(kind: MetricKind, entity_column: str, label: str, key: str,
|
| 200 |
+
scale: tuple[float, float] = (0.0, 1.0)) -> MetricSpec:
|
| 201 |
+
"""Build the per-entity counterpart of a pooled metric."""
|
| 202 |
+
return MetricSpec(
|
| 203 |
+
key=key, label=label, kind=kind, grouped_by=entity_column, scale=scale
|
| 204 |
+
)
|
| 205 |
+
|
| 206 |
+
|
| 207 |
+
BENCHMARKS: tuple[BenchmarkSpec, ...] = (
|
| 208 |
+
# ---------------------------------------------------------------- stability
|
| 209 |
+
BenchmarkSpec(
|
| 210 |
+
name="megascale",
|
| 211 |
+
label="Megascale ΔΔG",
|
| 212 |
+
task="regression",
|
| 213 |
+
pred_columns=("pred",),
|
| 214 |
+
truth_columns=("ddg",),
|
| 215 |
+
metrics=(
|
| 216 |
+
SPEARMAN,
|
| 217 |
+
_per_entity("grouped_spearman", "pdb", "Spearman (per protein)",
|
| 218 |
+
"spearman_per_protein", _SPEARMAN_SCALE),
|
| 219 |
+
),
|
| 220 |
+
entity_column="pdb",
|
| 221 |
+
unit="mutation",
|
| 222 |
+
manifest_columns=("pdb", "mutation"),
|
| 223 |
+
description=(
|
| 224 |
+
"Predicted folding free-energy change (ΔΔG, kcal/mol) for one point "
|
| 225 |
+
"mutation of a mini-protein. Sign convention follows plug: destabilising "
|
| 226 |
+
"mutations are negative."
|
| 227 |
+
),
|
| 228 |
+
),
|
| 229 |
+
BenchmarkSpec(
|
| 230 |
+
name="fireprot",
|
| 231 |
+
label="FireProt ΔΔG",
|
| 232 |
+
task="regression",
|
| 233 |
+
pred_columns=("pred",),
|
| 234 |
+
truth_columns=("ddg",),
|
| 235 |
+
metrics=(
|
| 236 |
+
SPEARMAN,
|
| 237 |
+
_per_entity("grouped_spearman", "pdb", "Spearman (per protein)",
|
| 238 |
+
"spearman_per_protein", _SPEARMAN_SCALE),
|
| 239 |
+
),
|
| 240 |
+
entity_column="pdb",
|
| 241 |
+
unit="mutation",
|
| 242 |
+
manifest_columns=("pdb", "mutation"),
|
| 243 |
+
description=(
|
| 244 |
+
"Predicted ΔΔG (kcal/mol) for one point mutation of a natural protein, "
|
| 245 |
+
"curated from the literature."
|
| 246 |
+
),
|
| 247 |
+
),
|
| 248 |
+
# --------------------------------------------------------------- DMS fitness
|
| 249 |
+
BenchmarkSpec(
|
| 250 |
+
name="dms",
|
| 251 |
+
label="ProteinGym DMS",
|
| 252 |
+
task="regression",
|
| 253 |
+
pred_columns=("pred",),
|
| 254 |
+
truth_columns=("score",),
|
| 255 |
+
metrics=(
|
| 256 |
+
MetricSpec(
|
| 257 |
+
key="spearman_per_assay",
|
| 258 |
+
label="Spearman (per assay)",
|
| 259 |
+
kind="grouped_spearman",
|
| 260 |
+
grouped_by="dms_id",
|
| 261 |
+
scale=_SPEARMAN_SCALE,
|
| 262 |
+
),
|
| 263 |
+
SPEARMAN,
|
| 264 |
+
),
|
| 265 |
+
entity_column="dms_id",
|
| 266 |
+
unit="variant",
|
| 267 |
+
manifest_columns=("dms_id", "uniprot", "assay", "mutation"),
|
| 268 |
+
description=(
|
| 269 |
+
"Predicted fitness for one variant in one deep mutational scanning assay. "
|
| 270 |
+
"Scored per assay and averaged, because assay scores share no common scale."
|
| 271 |
+
),
|
| 272 |
+
),
|
| 273 |
+
# ------------------------------------------------------------ GO / function
|
| 274 |
+
BenchmarkSpec(
|
| 275 |
+
name="cafa5",
|
| 276 |
+
label="CAFA5 GO",
|
| 277 |
+
task="go_terms",
|
| 278 |
+
pred_columns=("score",),
|
| 279 |
+
truth_columns=(),
|
| 280 |
+
metrics=(
|
| 281 |
+
MetricSpec(key="fmax", label="Fmax (macro)", kind="fmax"),
|
| 282 |
+
MetricSpec(key="fmax_bp", label="Fmax BP", kind="fmax", aspect="bp"),
|
| 283 |
+
MetricSpec(key="fmax_mf", label="Fmax MF", kind="fmax", aspect="mf"),
|
| 284 |
+
MetricSpec(key="fmax_cc", label="Fmax CC", kind="fmax", aspect="cc"),
|
| 285 |
+
),
|
| 286 |
+
entity_column="protein_id",
|
| 287 |
+
unit="protein",
|
| 288 |
+
long_form=True,
|
| 289 |
+
extra_columns=("aspect", "term"),
|
| 290 |
+
score_range=(0.0, 1.0),
|
| 291 |
+
allowed_values={"aspect": GO_ASPECTS},
|
| 292 |
+
manifest_columns=("protein_id", "organism"),
|
| 293 |
+
description=(
|
| 294 |
+
"Predicted Gene Ontology annotations, in CAFA's long form: one row per "
|
| 295 |
+
"(protein, branch, GO term) you predict, with a confidence in [0, 1]. "
|
| 296 |
+
"Terms you do not predict are simply absent — declining to annotate a "
|
| 297 |
+
"protein costs recall but not precision. Scored as target-centric Fmax "
|
| 298 |
+
"per GO branch (BP/MF/CC), macro-averaged over the three."
|
| 299 |
+
),
|
| 300 |
+
),
|
| 301 |
+
# ------------------------------------------------------------- allostery
|
| 302 |
+
BenchmarkSpec(
|
| 303 |
+
name="allobench",
|
| 304 |
+
label="AlloBench sites",
|
| 305 |
+
task="binary",
|
| 306 |
+
pred_columns=("pred",),
|
| 307 |
+
truth_columns=("is_allosteric_site",),
|
| 308 |
+
metrics=(
|
| 309 |
+
AUROC,
|
| 310 |
+
_per_entity("grouped_auroc", "target_id", "AUROC (per protein)",
|
| 311 |
+
"auroc_per_protein"),
|
| 312 |
+
),
|
| 313 |
+
entity_column="target_id",
|
| 314 |
+
unit="residue",
|
| 315 |
+
score_range=None,
|
| 316 |
+
manifest_columns=("target_id", "uniprot", "pdb", "position"),
|
| 317 |
+
description=(
|
| 318 |
+
"Per-residue score that a residue belongs to an allosteric site. Any "
|
| 319 |
+
"monotone score works — only the ranking is used."
|
| 320 |
+
),
|
| 321 |
+
),
|
| 322 |
+
BenchmarkSpec(
|
| 323 |
+
name="passerrank",
|
| 324 |
+
label="PASSerRank sites",
|
| 325 |
+
task="binary",
|
| 326 |
+
pred_columns=("pred",),
|
| 327 |
+
truth_columns=("is_allosteric_site",),
|
| 328 |
+
metrics=(
|
| 329 |
+
AUROC,
|
| 330 |
+
_per_entity("grouped_auroc", "uniprot", "AUROC (per protein)",
|
| 331 |
+
"auroc_per_protein"),
|
| 332 |
+
),
|
| 333 |
+
entity_column="uniprot",
|
| 334 |
+
unit="residue",
|
| 335 |
+
manifest_columns=("uniprot", "pdb", "position"),
|
| 336 |
+
description=(
|
| 337 |
+
"Per-residue score that a residue belongs to an allosteric site, over "
|
| 338 |
+
"the PASSerRank targets."
|
| 339 |
+
),
|
| 340 |
+
),
|
| 341 |
+
# --------------------------------------------------------------------- PPI
|
| 342 |
+
BenchmarkSpec(
|
| 343 |
+
name="ppi",
|
| 344 |
+
label="Human PPI",
|
| 345 |
+
task="binary",
|
| 346 |
+
pred_columns=("pred",),
|
| 347 |
+
truth_columns=("label",),
|
| 348 |
+
metrics=(AUROC,),
|
| 349 |
+
entity_column="id_a",
|
| 350 |
+
unit="protein pair",
|
| 351 |
+
manifest_columns=("id_a", "id_b"),
|
| 352 |
+
description=(
|
| 353 |
+
"Score that two human proteins interact. Pairs are undirected: your "
|
| 354 |
+
"score should not depend on which partner is listed first."
|
| 355 |
+
),
|
| 356 |
+
),
|
| 357 |
+
BenchmarkSpec(
|
| 358 |
+
name="shs27k",
|
| 359 |
+
label="STRING SHS27k modes",
|
| 360 |
+
task="multilabel",
|
| 361 |
+
pred_columns=tuple(f"pred_{mode}" for mode in SHS27K_MODES),
|
| 362 |
+
truth_columns=tuple(SHS27K_MODES),
|
| 363 |
+
metrics=(
|
| 364 |
+
MetricSpec(key="macro_auroc", label="Macro AUROC", kind="macro_auroc"),
|
| 365 |
+
),
|
| 366 |
+
entity_column="id_a",
|
| 367 |
+
unit="protein pair",
|
| 368 |
+
manifest_columns=("id_a", "id_b"),
|
| 369 |
+
description=(
|
| 370 |
+
"Seven scores per pair, one per STRING interaction mode. SHS27k ships no "
|
| 371 |
+
"negative pairs, so this is multi-label mode prediction rather than an "
|
| 372 |
+
"interact/does-not task. Scored as AUROC per mode, macro-averaged over "
|
| 373 |
+
"the modes present in the test split."
|
| 374 |
+
),
|
| 375 |
+
),
|
| 376 |
+
# ---------------------------------------------------------------- affinity
|
| 377 |
+
BenchmarkSpec(
|
| 378 |
+
name="lp-pdbbind",
|
| 379 |
+
label="LP-PDBBind affinity",
|
| 380 |
+
task="regression",
|
| 381 |
+
pred_columns=("pred",),
|
| 382 |
+
truth_columns=("value",),
|
| 383 |
+
metrics=(SPEARMAN,),
|
| 384 |
+
entity_column="pdb",
|
| 385 |
+
unit="complex",
|
| 386 |
+
manifest_columns=("pdb", "smiles"),
|
| 387 |
+
description=(
|
| 388 |
+
"Predicted binding affinity for one protein–ligand complex, on "
|
| 389 |
+
"LP-PDBBind's scale (−log Kd/Ki)."
|
| 390 |
+
),
|
| 391 |
+
),
|
| 392 |
+
BenchmarkSpec(
|
| 393 |
+
name="bindingdb",
|
| 394 |
+
label="BindingDB affinity",
|
| 395 |
+
task="regression",
|
| 396 |
+
pred_columns=("pred",),
|
| 397 |
+
truth_columns=("value",),
|
| 398 |
+
metrics=(
|
| 399 |
+
SPEARMAN,
|
| 400 |
+
_per_entity("grouped_spearman", "target_key", "Spearman (per target)",
|
| 401 |
+
"spearman_per_target", _SPEARMAN_SCALE),
|
| 402 |
+
),
|
| 403 |
+
entity_column="target_key",
|
| 404 |
+
unit="measurement",
|
| 405 |
+
manifest_columns=("target_key", "uniprot", "target_name", "smiles", "measure"),
|
| 406 |
+
description=(
|
| 407 |
+
"Predicted binding affinity for one (target, ligand) measurement from "
|
| 408 |
+
"BindingDB, on the benchmark's own scale."
|
| 409 |
+
),
|
| 410 |
+
),
|
| 411 |
+
# ------------------------------------------------------------------- MD/RMSF
|
| 412 |
+
BenchmarkSpec(
|
| 413 |
+
name="atlas",
|
| 414 |
+
label="ATLAS RMSF",
|
| 415 |
+
task="regression",
|
| 416 |
+
pred_columns=("pred",),
|
| 417 |
+
truth_columns=("rmsf",),
|
| 418 |
+
metrics=(
|
| 419 |
+
SPEARMAN,
|
| 420 |
+
_per_entity("grouped_spearman", "pdb_chain", "Spearman (per chain)",
|
| 421 |
+
"spearman_per_chain", _SPEARMAN_SCALE),
|
| 422 |
+
),
|
| 423 |
+
entity_column="pdb_chain",
|
| 424 |
+
unit="residue",
|
| 425 |
+
manifest_columns=("pdb_chain", "position"),
|
| 426 |
+
description=(
|
| 427 |
+
"Predicted per-residue flexibility (RMSF, Å) from the ATLAS molecular "
|
| 428 |
+
"dynamics ensembles, averaged over the three replicas."
|
| 429 |
+
),
|
| 430 |
+
),
|
| 431 |
+
)
|
| 432 |
+
|
| 433 |
+
BENCHMARKS_BY_NAME: dict[str, BenchmarkSpec] = {b.name: b for b in BENCHMARKS}
|
| 434 |
+
BENCHMARK_NAMES: tuple[str, ...] = tuple(b.name for b in BENCHMARKS)
|
| 435 |
+
|
| 436 |
+
|
| 437 |
+
def get(name: str) -> BenchmarkSpec:
|
| 438 |
+
"""Look up a benchmark spec by its ``plug`` registry name.
|
| 439 |
+
|
| 440 |
+
Parameters
|
| 441 |
+
----------
|
| 442 |
+
name : str
|
| 443 |
+
The benchmark name, e.g. ``"megascale"``.
|
| 444 |
+
|
| 445 |
+
Returns
|
| 446 |
+
-------
|
| 447 |
+
BenchmarkSpec
|
| 448 |
+
That benchmark's spec.
|
| 449 |
+
|
| 450 |
+
Raises
|
| 451 |
+
------
|
| 452 |
+
KeyError
|
| 453 |
+
If ``name`` is not one of the eleven PLUG benchmarks.
|
| 454 |
+
|
| 455 |
+
"""
|
| 456 |
+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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Command line entry points for the PLUG challenge.
|
| 2 |
+
|
| 3 |
+
Participant-facing::
|
| 4 |
+
|
| 5 |
+
plug-challenge template ./my_submission # write an empty bundle skeleton
|
| 6 |
+
plug-challenge validate my_submission.zip # check it before uploading
|
| 7 |
+
|
| 8 |
+
Organiser-facing::
|
| 9 |
+
|
| 10 |
+
plug-challenge score my_submission.zip --ground-truth ./gt
|
| 11 |
+
plug-challenge rebuild # leaderboard <- scores/**
|
| 12 |
+
|
| 13 |
+
``validate`` needs only the public test manifests, so a participant can run it
|
| 14 |
+
offline against a downloaded copy of the data repo (``--data-dir``) or let it
|
| 15 |
+
fetch the manifests from the Hub.
|
| 16 |
+
"""
|
| 17 |
+
|
| 18 |
+
import argparse
|
| 19 |
+
import json
|
| 20 |
+
import sys
|
| 21 |
+
from pathlib import Path
|
| 22 |
+
|
| 23 |
+
import pandas as pd
|
| 24 |
+
from loguru import logger
|
| 25 |
+
|
| 26 |
+
from . import aggregate, scoring, store
|
| 27 |
+
from .benchmarks import BENCHMARKS, ID_COLUMN
|
| 28 |
+
from .validation import validate_bundle
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def _add_common(parser: argparse.ArgumentParser) -> None:
|
| 32 |
+
"""Add the arguments shared by ``validate`` and ``score``."""
|
| 33 |
+
parser.add_argument("bundle", type=Path, help="The submission .zip to check")
|
| 34 |
+
parser.add_argument(
|
| 35 |
+
"--data-dir",
|
| 36 |
+
type=Path,
|
| 37 |
+
default=None,
|
| 38 |
+
help="Directory holding <benchmark>/test_manifest.parquet "
|
| 39 |
+
"(default: fetch from the Hub)",
|
| 40 |
+
)
|
| 41 |
+
parser.add_argument(
|
| 42 |
+
"--allow-partial",
|
| 43 |
+
action="store_true",
|
| 44 |
+
help="Do not fail on a bundle that is missing some benchmarks",
|
| 45 |
+
)
|
| 46 |
+
|
| 47 |
+
|
| 48 |
+
def build_parser() -> argparse.ArgumentParser:
|
| 49 |
+
"""Build the argument parser.
|
| 50 |
+
|
| 51 |
+
Returns
|
| 52 |
+
-------
|
| 53 |
+
argparse.ArgumentParser
|
| 54 |
+
The configured parser with one subcommand per entry point.
|
| 55 |
+
|
| 56 |
+
"""
|
| 57 |
+
parser = argparse.ArgumentParser(
|
| 58 |
+
prog="plug-challenge",
|
| 59 |
+
description="Build, check and score PLUG challenge submissions.",
|
| 60 |
+
epilog=(
|
| 61 |
+
"typical use:\n"
|
| 62 |
+
" plug-challenge template ./my_submission # one file per benchmark\n"
|
| 63 |
+
" cd my_submission && zip ../plug_submission.zip *.csv && cd ..\n"
|
| 64 |
+
" plug-challenge validate plug_submission.zip # the checks the Space runs\n"
|
| 65 |
+
),
|
| 66 |
+
formatter_class=argparse.RawDescriptionHelpFormatter,
|
| 67 |
+
)
|
| 68 |
+
sub = parser.add_subparsers(dest="command", required=True)
|
| 69 |
+
|
| 70 |
+
_add_common(sub.add_parser("validate", help="Validate a submission bundle"))
|
| 71 |
+
|
| 72 |
+
score = sub.add_parser("score", help="Validate and score a bundle (organisers)")
|
| 73 |
+
_add_common(score)
|
| 74 |
+
score.add_argument(
|
| 75 |
+
"--ground-truth",
|
| 76 |
+
type=Path,
|
| 77 |
+
required=True,
|
| 78 |
+
help="Directory holding <benchmark>.parquet ground-truth files",
|
| 79 |
+
)
|
| 80 |
+
score.add_argument(
|
| 81 |
+
"--bootstrap",
|
| 82 |
+
type=int,
|
| 83 |
+
default=0,
|
| 84 |
+
help="Bootstrap resamples per metric (0 = point estimates only)",
|
| 85 |
+
)
|
| 86 |
+
|
| 87 |
+
sub.add_parser("rebuild", help="Rebuild the leaderboard file from scores/** (organisers)")
|
| 88 |
+
|
| 89 |
+
template = sub.add_parser("template", help="Write an empty submission bundle skeleton")
|
| 90 |
+
template.add_argument(
|
| 91 |
+
"out_dir", type=Path, help="Directory to write the per-benchmark CSVs into"
|
| 92 |
+
)
|
| 93 |
+
template.add_argument(
|
| 94 |
+
"--data-dir",
|
| 95 |
+
type=Path,
|
| 96 |
+
default=None,
|
| 97 |
+
help="Directory holding the test manifests (default: fetch from the Hub)",
|
| 98 |
+
)
|
| 99 |
+
return parser
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
def _expected_ids(data_dir: Path | None) -> dict[str, set[str]]:
|
| 103 |
+
"""Load the per-benchmark test id sets from the manifests."""
|
| 104 |
+
ids = store.manifest_ids(local_dir=data_dir)
|
| 105 |
+
if not ids:
|
| 106 |
+
logger.error(
|
| 107 |
+
"No test manifests found. Pass --data-dir pointing at a local copy of "
|
| 108 |
+
"the challenge data repo, or check network access to the Hub."
|
| 109 |
+
)
|
| 110 |
+
raise SystemExit(2)
|
| 111 |
+
return ids
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
def command_validate(args: argparse.Namespace) -> int:
|
| 115 |
+
"""Validate a bundle and print the report.
|
| 116 |
+
|
| 117 |
+
Parameters
|
| 118 |
+
----------
|
| 119 |
+
args : argparse.Namespace
|
| 120 |
+
Parsed arguments.
|
| 121 |
+
|
| 122 |
+
Returns
|
| 123 |
+
-------
|
| 124 |
+
int
|
| 125 |
+
0 if the bundle is valid, 1 otherwise.
|
| 126 |
+
|
| 127 |
+
"""
|
| 128 |
+
result = validate_bundle(
|
| 129 |
+
args.bundle,
|
| 130 |
+
expected_ids=_expected_ids(args.data_dir),
|
| 131 |
+
require_complete=not args.allow_partial,
|
| 132 |
+
)
|
| 133 |
+
if result.ok:
|
| 134 |
+
print(f"OK — {len(result.frames)} benchmark file(s) validated.")
|
| 135 |
+
if result.warnings:
|
| 136 |
+
print("\nWarnings:")
|
| 137 |
+
print(result.report(limit=100))
|
| 138 |
+
return 0
|
| 139 |
+
print("Bundle is not valid:")
|
| 140 |
+
print(result.report(limit=100))
|
| 141 |
+
return 1
|
| 142 |
+
|
| 143 |
+
|
| 144 |
+
def command_score(args: argparse.Namespace) -> int:
|
| 145 |
+
"""Validate, score and print one bundle's metrics.
|
| 146 |
+
|
| 147 |
+
Parameters
|
| 148 |
+
----------
|
| 149 |
+
args : argparse.Namespace
|
| 150 |
+
Parsed arguments.
|
| 151 |
+
|
| 152 |
+
Returns
|
| 153 |
+
-------
|
| 154 |
+
int
|
| 155 |
+
0 if the bundle scored, 1 if validation failed.
|
| 156 |
+
|
| 157 |
+
"""
|
| 158 |
+
truth: dict[str, pd.DataFrame] = {}
|
| 159 |
+
for spec in BENCHMARKS:
|
| 160 |
+
path = args.ground_truth / f"{spec.name}.parquet"
|
| 161 |
+
if path.exists():
|
| 162 |
+
frame = pd.read_parquet(path)
|
| 163 |
+
frame[ID_COLUMN] = frame[ID_COLUMN].astype(str)
|
| 164 |
+
truth[spec.name] = frame
|
| 165 |
+
else:
|
| 166 |
+
logger.warning("No ground truth for {} at {}", spec.name, path)
|
| 167 |
+
|
| 168 |
+
result = validate_bundle(
|
| 169 |
+
args.bundle,
|
| 170 |
+
expected_ids={name: set(frame[ID_COLUMN]) for name, frame in truth.items()},
|
| 171 |
+
require_complete=not args.allow_partial,
|
| 172 |
+
)
|
| 173 |
+
if not result.ok:
|
| 174 |
+
print("Bundle is not valid:")
|
| 175 |
+
print(result.report(limit=100))
|
| 176 |
+
return 1
|
| 177 |
+
if result.warnings:
|
| 178 |
+
print("Warnings:")
|
| 179 |
+
print(result.report(limit=100))
|
| 180 |
+
print()
|
| 181 |
+
|
| 182 |
+
scores = scoring.score_bundle(
|
| 183 |
+
result.frames, truth, BENCHMARKS, bootstrap_samples=args.bootstrap
|
| 184 |
+
)
|
| 185 |
+
print(json.dumps(scores, indent=2))
|
| 186 |
+
print(f"\nPLUG Score: {aggregate.plug_score(scores):.4f}")
|
| 187 |
+
return 0
|
| 188 |
+
|
| 189 |
+
|
| 190 |
+
def command_rebuild(_: argparse.Namespace) -> int:
|
| 191 |
+
"""Rebuild the leaderboard file from the per-submission score files.
|
| 192 |
+
|
| 193 |
+
Parameters
|
| 194 |
+
----------
|
| 195 |
+
_ : argparse.Namespace
|
| 196 |
+
Unused.
|
| 197 |
+
|
| 198 |
+
Returns
|
| 199 |
+
-------
|
| 200 |
+
int
|
| 201 |
+
0 on success, 2 when no token is configured.
|
| 202 |
+
|
| 203 |
+
"""
|
| 204 |
+
if not store.configured():
|
| 205 |
+
logger.error("HF_TOKEN is not set — cannot write to the private repo.")
|
| 206 |
+
return 2
|
| 207 |
+
entries = store.all_scores()
|
| 208 |
+
frame = pd.DataFrame(entries) if entries else pd.DataFrame()
|
| 209 |
+
store.write_leaderboard(frame)
|
| 210 |
+
print(f"Rebuilt the leaderboard from {len(entries)} score file(s).")
|
| 211 |
+
return 0
|
| 212 |
+
|
| 213 |
+
|
| 214 |
+
def command_template(args: argparse.Namespace) -> int:
|
| 215 |
+
"""Write an empty per-benchmark CSV skeleton with the right ids and columns.
|
| 216 |
+
|
| 217 |
+
Every file comes out with the correct ``datapoint_id`` values already in
|
| 218 |
+
place and the prediction columns filled with zeros, so a participant only has
|
| 219 |
+
to overwrite the prediction column(s). cafa5 is the exception: it is long
|
| 220 |
+
form, so its file is written with the header alone.
|
| 221 |
+
|
| 222 |
+
Parameters
|
| 223 |
+
----------
|
| 224 |
+
args : argparse.Namespace
|
| 225 |
+
Parsed arguments.
|
| 226 |
+
|
| 227 |
+
Returns
|
| 228 |
+
-------
|
| 229 |
+
int
|
| 230 |
+
0 on success.
|
| 231 |
+
|
| 232 |
+
"""
|
| 233 |
+
args.out_dir.mkdir(parents=True, exist_ok=True)
|
| 234 |
+
for spec in BENCHMARKS:
|
| 235 |
+
try:
|
| 236 |
+
manifest = store.load_test_manifest(spec.name, local_dir=args.data_dir)
|
| 237 |
+
except FileNotFoundError:
|
| 238 |
+
logger.warning("Skipping {} — no test manifest available.", spec.name)
|
| 239 |
+
continue
|
| 240 |
+
path = args.out_dir / spec.filename
|
| 241 |
+
if spec.long_form:
|
| 242 |
+
pd.DataFrame(columns=list(spec.required_columns)).to_csv(path, index=False)
|
| 243 |
+
print(
|
| 244 |
+
f"wrote {path} (header only — add one row per (protein, branch, GO term) "
|
| 245 |
+
f"you predict, for any of the {len(manifest)} test proteins)"
|
| 246 |
+
)
|
| 247 |
+
else:
|
| 248 |
+
frame = manifest[[ID_COLUMN]].copy()
|
| 249 |
+
for column in spec.pred_columns:
|
| 250 |
+
frame[column] = 0.0
|
| 251 |
+
frame.to_csv(path, index=False)
|
| 252 |
+
print(f"wrote {path} ({len(manifest)} rows — replace the zeros)")
|
| 253 |
+
print(
|
| 254 |
+
f"\nFill in the prediction columns, then zip the directory's contents:\n"
|
| 255 |
+
f" cd {args.out_dir} && zip ../plug_submission.zip *.csv"
|
| 256 |
+
)
|
| 257 |
+
return 0
|
| 258 |
+
|
| 259 |
+
|
| 260 |
+
def main(argv: list[str] | None = None) -> int:
|
| 261 |
+
"""Parse arguments and dispatch.
|
| 262 |
+
|
| 263 |
+
Parameters
|
| 264 |
+
----------
|
| 265 |
+
argv : list[str] | None
|
| 266 |
+
Argument list; ``None`` reads ``sys.argv``.
|
| 267 |
+
|
| 268 |
+
Returns
|
| 269 |
+
-------
|
| 270 |
+
int
|
| 271 |
+
Process exit status.
|
| 272 |
+
|
| 273 |
+
"""
|
| 274 |
+
args = build_parser().parse_args(argv)
|
| 275 |
+
handlers = {
|
| 276 |
+
"validate": command_validate,
|
| 277 |
+
"score": command_score,
|
| 278 |
+
"rebuild": command_rebuild,
|
| 279 |
+
"template": command_template,
|
| 280 |
+
}
|
| 281 |
+
return handlers[args.command](args)
|
| 282 |
+
|
| 283 |
+
|
| 284 |
+
if __name__ == "__main__":
|
| 285 |
+
sys.exit(main())
|
plug_challenge/metrics.py
ADDED
|
@@ -0,0 +1,453 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Metric implementations for the PLUG challenge.
|
| 2 |
+
|
| 3 |
+
Ported from ``plug-baselines/utils.py`` so that a leaderboard number and a
|
| 4 |
+
published baseline number are computed by the same arithmetic. Every function
|
| 5 |
+
here takes plain arrays and returns a plain float — nothing in this module
|
| 6 |
+
knows about submissions, S3/Hub storage, or benchmarks.
|
| 7 |
+
|
| 8 |
+
Three families cover all eleven benchmarks:
|
| 9 |
+
|
| 10 |
+
- **Rank correlation** (``spearman``, ``grouped_spearman``) — the ddG, DMS,
|
| 11 |
+
affinity and RMSF benchmarks.
|
| 12 |
+
- **Ranking/detection** (``auroc``, ``macro_auroc``, ``grouped_auroc``) — the
|
| 13 |
+
PPI and allosteric-site benchmarks.
|
| 14 |
+
- **CAFA Fmax** (``fmax``) — GO term prediction.
|
| 15 |
+
"""
|
| 16 |
+
|
| 17 |
+
import warnings
|
| 18 |
+
|
| 19 |
+
import numpy as np
|
| 20 |
+
import numpy.typing as npt
|
| 21 |
+
from loguru import logger
|
| 22 |
+
from scipy.stats import ConstantInputWarning, spearmanr
|
| 23 |
+
from sklearn.metrics import roc_auc_score
|
| 24 |
+
|
| 25 |
+
# Returned instead of a float when a metric is mathematically undefined for the
|
| 26 |
+
# data it was handed (a constant prediction column, a single-class label column,
|
| 27 |
+
# a group with one member). Callers decide whether that is a validation failure
|
| 28 |
+
# or a group to skip; nothing here raises.
|
| 29 |
+
UNDEFINED = float("nan")
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def spearman(y_true: npt.ArrayLike, y_pred: npt.ArrayLike) -> float:
|
| 33 |
+
"""Spearman rank correlation, ignoring positions where either side is NaN.
|
| 34 |
+
|
| 35 |
+
Parameters
|
| 36 |
+
----------
|
| 37 |
+
y_true : npt.ArrayLike
|
| 38 |
+
Ground-truth values.
|
| 39 |
+
y_pred : npt.ArrayLike
|
| 40 |
+
Predicted values.
|
| 41 |
+
|
| 42 |
+
Returns
|
| 43 |
+
-------
|
| 44 |
+
float
|
| 45 |
+
Spearman's rho, or ``UNDEFINED`` when fewer than two finite pairs
|
| 46 |
+
remain or either side is constant (rho is undefined with zero variance —
|
| 47 |
+
scipy returns NaN there rather than raising).
|
| 48 |
+
|
| 49 |
+
"""
|
| 50 |
+
y_true = np.asarray(y_true, dtype=float)
|
| 51 |
+
y_pred = np.asarray(y_pred, dtype=float)
|
| 52 |
+
keep = ~(np.isnan(y_true) | np.isnan(y_pred))
|
| 53 |
+
if keep.sum() < 2:
|
| 54 |
+
return UNDEFINED
|
| 55 |
+
# A constant column makes rho undefined; scipy warns and returns NaN, which
|
| 56 |
+
# is exactly the UNDEFINED contract here, so the warning is noise.
|
| 57 |
+
with warnings.catch_warnings():
|
| 58 |
+
warnings.simplefilter("ignore", category=ConstantInputWarning)
|
| 59 |
+
rho = spearmanr(y_true[keep], y_pred[keep]).correlation
|
| 60 |
+
return float(rho) if np.isfinite(rho) else UNDEFINED
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
def auroc(y_true: npt.ArrayLike, y_score: npt.ArrayLike) -> float:
|
| 64 |
+
"""Area under the ROC curve for a binary label.
|
| 65 |
+
|
| 66 |
+
Parameters
|
| 67 |
+
----------
|
| 68 |
+
y_true : npt.ArrayLike
|
| 69 |
+
Binary labels (0/1 or bool).
|
| 70 |
+
y_score : npt.ArrayLike
|
| 71 |
+
Predicted scores; higher must mean "more likely positive".
|
| 72 |
+
|
| 73 |
+
Returns
|
| 74 |
+
-------
|
| 75 |
+
float
|
| 76 |
+
AUROC, or ``UNDEFINED`` when the labels are single-class (AUROC is
|
| 77 |
+
undefined without both classes present).
|
| 78 |
+
|
| 79 |
+
"""
|
| 80 |
+
y_true = np.asarray(y_true)
|
| 81 |
+
y_score = np.asarray(y_score, dtype=float)
|
| 82 |
+
if y_true.size == 0 or y_true.min() == y_true.max():
|
| 83 |
+
return UNDEFINED
|
| 84 |
+
return float(roc_auc_score(y_true, y_score))
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
def macro_auroc(y_true: npt.ArrayLike, y_score: npt.ArrayLike) -> float:
|
| 88 |
+
"""Mean AUROC over the label columns that have both classes present.
|
| 89 |
+
|
| 90 |
+
Single-class columns are skipped rather than scored as 0.5, matching
|
| 91 |
+
``plug-baselines``: a mode no test pair carries says nothing about the
|
| 92 |
+
submission either way.
|
| 93 |
+
|
| 94 |
+
Parameters
|
| 95 |
+
----------
|
| 96 |
+
y_true : npt.ArrayLike
|
| 97 |
+
Binary label matrix, shape ``(n_samples, n_labels)``.
|
| 98 |
+
y_score : npt.ArrayLike
|
| 99 |
+
Predicted score matrix of the same shape.
|
| 100 |
+
|
| 101 |
+
Returns
|
| 102 |
+
-------
|
| 103 |
+
float
|
| 104 |
+
Macro-averaged AUROC, or ``UNDEFINED`` when no column is scorable.
|
| 105 |
+
|
| 106 |
+
"""
|
| 107 |
+
y_true = np.asarray(y_true)
|
| 108 |
+
y_score = np.asarray(y_score, dtype=float)
|
| 109 |
+
per_label = [
|
| 110 |
+
roc_auc_score(y_true[:, k], y_score[:, k])
|
| 111 |
+
for k in range(y_true.shape[1])
|
| 112 |
+
if y_true[:, k].min() != y_true[:, k].max()
|
| 113 |
+
]
|
| 114 |
+
return float(np.mean(per_label)) if per_label else UNDEFINED
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
def fmax(
|
| 118 |
+
y_true: npt.ArrayLike,
|
| 119 |
+
y_score: npt.ArrayLike,
|
| 120 |
+
step: float = 0.01,
|
| 121 |
+
weights: npt.ArrayLike | None = None,
|
| 122 |
+
) -> dict[str, float | None]:
|
| 123 |
+
"""CAFA target-centric Fmax over a confidence-threshold sweep.
|
| 124 |
+
|
| 125 |
+
Scores must be probabilities, hence the 0..1 grid. At each threshold,
|
| 126 |
+
precision is averaged over the targets that predict at least one term while
|
| 127 |
+
recall is averaged over every annotated target — that asymmetry is CAFA's: a
|
| 128 |
+
target you decline to predict costs recall but not precision. Unannotated
|
| 129 |
+
targets are dropped.
|
| 130 |
+
|
| 131 |
+
Parameters
|
| 132 |
+
----------
|
| 133 |
+
y_true : npt.ArrayLike
|
| 134 |
+
Boolean annotation matrix, shape ``(n_targets, n_terms)``.
|
| 135 |
+
y_score : npt.ArrayLike
|
| 136 |
+
Predicted probability matrix of the same shape.
|
| 137 |
+
step : float
|
| 138 |
+
Threshold grid spacing over ``[0, 1]``.
|
| 139 |
+
weights : npt.ArrayLike | None
|
| 140 |
+
Optional per-term information accretion, for the information-weighted
|
| 141 |
+
variant. ``None`` weights every term equally.
|
| 142 |
+
|
| 143 |
+
Returns
|
| 144 |
+
-------
|
| 145 |
+
dict[str, float | None]
|
| 146 |
+
``fmax``, the ``threshold`` that achieved it, the ``precision`` and
|
| 147 |
+
``recall`` there, ``coverage`` (fraction of targets still predicting at
|
| 148 |
+
that threshold), and the number of annotated ``targets``. Every value
|
| 149 |
+
except ``targets`` is ``None`` when no target is annotated.
|
| 150 |
+
|
| 151 |
+
"""
|
| 152 |
+
y_true = np.asarray(y_true, dtype=bool)
|
| 153 |
+
y_score = np.asarray(y_score, dtype=float)
|
| 154 |
+
annotated = y_true.sum(axis=1) > 0
|
| 155 |
+
if not annotated.any():
|
| 156 |
+
return {
|
| 157 |
+
"fmax": None,
|
| 158 |
+
"threshold": None,
|
| 159 |
+
"precision": None,
|
| 160 |
+
"recall": None,
|
| 161 |
+
"coverage": None,
|
| 162 |
+
"targets": 0,
|
| 163 |
+
}
|
| 164 |
+
y_true, y_score = y_true[annotated], y_score[annotated]
|
| 165 |
+
w = None if weights is None else np.asarray(weights, dtype=float)
|
| 166 |
+
true_weight = (y_true * w).sum(axis=1) if w is not None else y_true.sum(axis=1).astype(float)
|
| 167 |
+
|
| 168 |
+
best: dict[str, float | None] = {
|
| 169 |
+
"fmax": 0.0,
|
| 170 |
+
"threshold": None,
|
| 171 |
+
"precision": None,
|
| 172 |
+
"recall": None,
|
| 173 |
+
"coverage": None,
|
| 174 |
+
"targets": int(y_true.shape[0]),
|
| 175 |
+
}
|
| 176 |
+
for threshold in np.arange(0.0, 1.0 + step / 2, step):
|
| 177 |
+
predicted = y_score >= threshold
|
| 178 |
+
pred_weight = (
|
| 179 |
+
(predicted * w).sum(axis=1) if w is not None else predicted.sum(axis=1).astype(float)
|
| 180 |
+
)
|
| 181 |
+
hit_weight = (
|
| 182 |
+
((predicted & y_true) * w).sum(axis=1)
|
| 183 |
+
if w is not None
|
| 184 |
+
else (predicted & y_true).sum(axis=1).astype(float)
|
| 185 |
+
)
|
| 186 |
+
predicting = pred_weight > 0
|
| 187 |
+
if not predicting.any():
|
| 188 |
+
continue
|
| 189 |
+
precision = float((hit_weight[predicting] / pred_weight[predicting]).mean())
|
| 190 |
+
recall = float((hit_weight / true_weight).mean())
|
| 191 |
+
if precision + recall == 0:
|
| 192 |
+
continue
|
| 193 |
+
f1 = 2 * precision * recall / (precision + recall)
|
| 194 |
+
current_best = best["fmax"]
|
| 195 |
+
if current_best is None or f1 > current_best:
|
| 196 |
+
best.update(
|
| 197 |
+
fmax=f1,
|
| 198 |
+
threshold=float(threshold),
|
| 199 |
+
precision=precision,
|
| 200 |
+
recall=recall,
|
| 201 |
+
coverage=float(predicting.mean()),
|
| 202 |
+
)
|
| 203 |
+
return best
|
| 204 |
+
|
| 205 |
+
|
| 206 |
+
def grouped_spearman(
|
| 207 |
+
y_true: npt.ArrayLike, y_pred: npt.ArrayLike, groups: npt.ArrayLike
|
| 208 |
+
) -> float:
|
| 209 |
+
"""Mean of the within-group Spearman correlations.
|
| 210 |
+
|
| 211 |
+
Used where the ground-truth values are not on a common scale across groups
|
| 212 |
+
and pooling them would measure between-group spread instead of within-group
|
| 213 |
+
ranking — DMS (one assay per ``dms_id``) is the canonical case. Groups whose
|
| 214 |
+
correlation is undefined (fewer than two points, or constant on either side)
|
| 215 |
+
are skipped.
|
| 216 |
+
|
| 217 |
+
Parameters
|
| 218 |
+
----------
|
| 219 |
+
y_true : npt.ArrayLike
|
| 220 |
+
Ground-truth values.
|
| 221 |
+
y_pred : npt.ArrayLike
|
| 222 |
+
Predicted values.
|
| 223 |
+
groups : npt.ArrayLike
|
| 224 |
+
Group label per row.
|
| 225 |
+
|
| 226 |
+
Returns
|
| 227 |
+
-------
|
| 228 |
+
float
|
| 229 |
+
Unweighted mean over scorable groups — every group counts once
|
| 230 |
+
regardless of size — or ``UNDEFINED`` when no group is scorable.
|
| 231 |
+
|
| 232 |
+
"""
|
| 233 |
+
return _grouped_mean(spearman, y_true, y_pred, groups)
|
| 234 |
+
|
| 235 |
+
|
| 236 |
+
def grouped_auroc(y_true: npt.ArrayLike, y_score: npt.ArrayLike, groups: npt.ArrayLike) -> float:
|
| 237 |
+
"""Mean of the within-group AUROCs.
|
| 238 |
+
|
| 239 |
+
The per-protein counterpart to ``auroc`` for the per-residue benchmarks:
|
| 240 |
+
it asks whether the sites are ranked correctly *within* each protein, which
|
| 241 |
+
a pooled AUROC can hide when scores are calibrated differently per protein.
|
| 242 |
+
Single-class groups are skipped.
|
| 243 |
+
|
| 244 |
+
Parameters
|
| 245 |
+
----------
|
| 246 |
+
y_true : npt.ArrayLike
|
| 247 |
+
Binary labels.
|
| 248 |
+
y_score : npt.ArrayLike
|
| 249 |
+
Predicted scores.
|
| 250 |
+
groups : npt.ArrayLike
|
| 251 |
+
Group label per row.
|
| 252 |
+
|
| 253 |
+
Returns
|
| 254 |
+
-------
|
| 255 |
+
float
|
| 256 |
+
Unweighted mean over scorable groups, or ``UNDEFINED`` when no group is
|
| 257 |
+
scorable.
|
| 258 |
+
|
| 259 |
+
"""
|
| 260 |
+
return _grouped_mean(auroc, y_true, y_score, groups)
|
| 261 |
+
|
| 262 |
+
|
| 263 |
+
def _grouped_mean(
|
| 264 |
+
metric, y_true: npt.ArrayLike, y_pred: npt.ArrayLike, groups: npt.ArrayLike
|
| 265 |
+
) -> float:
|
| 266 |
+
"""Apply ``metric`` within each group and average the defined results.
|
| 267 |
+
|
| 268 |
+
Parameters
|
| 269 |
+
----------
|
| 270 |
+
metric : Callable[[npt.ArrayLike, npt.ArrayLike], float]
|
| 271 |
+
A two-argument metric returning a float or ``UNDEFINED``.
|
| 272 |
+
y_true : npt.ArrayLike
|
| 273 |
+
Ground-truth values.
|
| 274 |
+
y_pred : npt.ArrayLike
|
| 275 |
+
Predicted values.
|
| 276 |
+
groups : npt.ArrayLike
|
| 277 |
+
Group label per row.
|
| 278 |
+
|
| 279 |
+
Returns
|
| 280 |
+
-------
|
| 281 |
+
float
|
| 282 |
+
Mean over groups with a defined metric, or ``UNDEFINED`` if there are
|
| 283 |
+
none.
|
| 284 |
+
|
| 285 |
+
"""
|
| 286 |
+
y_true = np.asarray(y_true)
|
| 287 |
+
y_pred = np.asarray(y_pred)
|
| 288 |
+
groups = np.asarray(groups)
|
| 289 |
+
values = []
|
| 290 |
+
for group in np.unique(groups):
|
| 291 |
+
mask = groups == group
|
| 292 |
+
value = metric(y_true[mask], y_pred[mask])
|
| 293 |
+
if np.isfinite(value):
|
| 294 |
+
values.append(value)
|
| 295 |
+
if not values:
|
| 296 |
+
logger.warning("No scorable groups — metric is undefined for this submission.")
|
| 297 |
+
return UNDEFINED
|
| 298 |
+
return float(np.mean(values))
|
| 299 |
+
|
| 300 |
+
|
| 301 |
+
def bootstrap(
|
| 302 |
+
metric,
|
| 303 |
+
n_samples: int,
|
| 304 |
+
n_rows: int,
|
| 305 |
+
seed: int = 0,
|
| 306 |
+
groups: npt.ArrayLike | None = None,
|
| 307 |
+
) -> tuple[float, float]:
|
| 308 |
+
"""Resample row indices and return the mean and standard deviation of ``metric``.
|
| 309 |
+
|
| 310 |
+
Resampling is at the row level by default. When ``groups`` is given, whole
|
| 311 |
+
groups are resampled instead (every row of a drawn group comes along), which
|
| 312 |
+
is the correct unit for the grouped metrics: a per-assay mean has as many
|
| 313 |
+
independent observations as there are assays, not as there are variants.
|
| 314 |
+
|
| 315 |
+
Parameters
|
| 316 |
+
----------
|
| 317 |
+
metric : Callable[[np.ndarray], float]
|
| 318 |
+
Takes an array of row indices and returns that resample's metric value.
|
| 319 |
+
n_samples : int
|
| 320 |
+
Number of bootstrap resamples. ``0`` skips resampling entirely and
|
| 321 |
+
returns the point estimate on all rows with a standard deviation of 0.
|
| 322 |
+
n_rows : int
|
| 323 |
+
Number of rows available to sample from.
|
| 324 |
+
seed : int
|
| 325 |
+
Seed for the resampling RNG, so a rescore reproduces the same interval.
|
| 326 |
+
groups : npt.ArrayLike | None
|
| 327 |
+
Optional group label per row; when given, groups rather than rows are
|
| 328 |
+
the resampling unit.
|
| 329 |
+
|
| 330 |
+
Returns
|
| 331 |
+
-------
|
| 332 |
+
tuple[float, float]
|
| 333 |
+
The mean and standard deviation of the metric over the resamples. With
|
| 334 |
+
``n_samples == 0``, the point estimate and ``0.0``.
|
| 335 |
+
|
| 336 |
+
"""
|
| 337 |
+
all_rows = np.arange(n_rows)
|
| 338 |
+
if n_samples <= 0:
|
| 339 |
+
return metric(all_rows), 0.0
|
| 340 |
+
|
| 341 |
+
rng = np.random.default_rng(seed)
|
| 342 |
+
if groups is None:
|
| 343 |
+
draws = [metric(rng.integers(0, n_rows, size=n_rows)) for _ in range(n_samples)]
|
| 344 |
+
else:
|
| 345 |
+
groups = np.asarray(groups)
|
| 346 |
+
unique = np.unique(groups)
|
| 347 |
+
rows_by_group = {g: all_rows[groups == g] for g in unique}
|
| 348 |
+
draws = []
|
| 349 |
+
for _ in range(n_samples):
|
| 350 |
+
drawn = unique[rng.integers(0, unique.size, size=unique.size)]
|
| 351 |
+
draws.append(metric(np.concatenate([rows_by_group[g] for g in drawn])))
|
| 352 |
+
|
| 353 |
+
finite = np.asarray([d for d in draws if np.isfinite(d)], dtype=float)
|
| 354 |
+
if finite.size == 0:
|
| 355 |
+
return UNDEFINED, UNDEFINED
|
| 356 |
+
return float(finite.mean()), float(finite.std())
|
| 357 |
+
|
| 358 |
+
|
| 359 |
+
def fmax_long(
|
| 360 |
+
target_index: npt.ArrayLike,
|
| 361 |
+
scores: npt.ArrayLike,
|
| 362 |
+
is_true: npt.ArrayLike,
|
| 363 |
+
true_per_target: npt.ArrayLike,
|
| 364 |
+
step: float = 0.01,
|
| 365 |
+
) -> dict[str, float | None]:
|
| 366 |
+
"""CAFA Fmax computed from long-form predictions, without a dense matrix.
|
| 367 |
+
|
| 368 |
+
Mathematically identical to ``fmax`` with equal term weights (the two are
|
| 369 |
+
cross-checked against each other in the tests), but it consumes the
|
| 370 |
+
``(target, term, score)`` triples a submission actually carries. A dense
|
| 371 |
+
``targets × terms`` score matrix for CAFA5 runs to hundreds of megabytes,
|
| 372 |
+
while this is linear in the number of predicted rows.
|
| 373 |
+
|
| 374 |
+
Only annotated targets contribute, again matching CAFA: ``true_per_target``
|
| 375 |
+
carries a zero for an unannotated target and those targets are dropped from
|
| 376 |
+
both the precision and the recall average.
|
| 377 |
+
|
| 378 |
+
Parameters
|
| 379 |
+
----------
|
| 380 |
+
target_index : npt.ArrayLike
|
| 381 |
+
Integer target index per predicted row, in ``[0, n_targets)``.
|
| 382 |
+
scores : npt.ArrayLike
|
| 383 |
+
Predicted confidence per row, in ``[0, 1]``.
|
| 384 |
+
is_true : npt.ArrayLike
|
| 385 |
+
Whether each predicted row's term is actually annotated on that target.
|
| 386 |
+
true_per_target : npt.ArrayLike
|
| 387 |
+
Number of annotated terms per target, length ``n_targets``. Zero marks an
|
| 388 |
+
unannotated target.
|
| 389 |
+
step : float
|
| 390 |
+
Threshold grid spacing over ``[0, 1]``.
|
| 391 |
+
|
| 392 |
+
Returns
|
| 393 |
+
-------
|
| 394 |
+
dict[str, float | None]
|
| 395 |
+
The same keys as ``fmax``.
|
| 396 |
+
|
| 397 |
+
"""
|
| 398 |
+
targets = np.asarray(target_index, dtype=np.int64)
|
| 399 |
+
confidences = np.asarray(scores, dtype=float)
|
| 400 |
+
correct = np.asarray(is_true, dtype=bool)
|
| 401 |
+
true_counts = np.asarray(true_per_target, dtype=float)
|
| 402 |
+
n_targets = true_counts.size
|
| 403 |
+
|
| 404 |
+
annotated = true_counts > 0
|
| 405 |
+
n_annotated = int(annotated.sum())
|
| 406 |
+
if n_annotated == 0:
|
| 407 |
+
return {
|
| 408 |
+
"fmax": None,
|
| 409 |
+
"threshold": None,
|
| 410 |
+
"precision": None,
|
| 411 |
+
"recall": None,
|
| 412 |
+
"coverage": None,
|
| 413 |
+
"targets": 0,
|
| 414 |
+
}
|
| 415 |
+
|
| 416 |
+
# Rows about unannotated targets cannot affect either average, so drop them up
|
| 417 |
+
# front rather than masking inside the sweep.
|
| 418 |
+
keep = annotated[targets]
|
| 419 |
+
targets, confidences, correct = targets[keep], confidences[keep], correct[keep]
|
| 420 |
+
|
| 421 |
+
best: dict[str, float | None] = {
|
| 422 |
+
"fmax": 0.0,
|
| 423 |
+
"threshold": None,
|
| 424 |
+
"precision": None,
|
| 425 |
+
"recall": None,
|
| 426 |
+
"coverage": None,
|
| 427 |
+
"targets": n_annotated,
|
| 428 |
+
}
|
| 429 |
+
for threshold in np.arange(0.0, 1.0 + step / 2, step):
|
| 430 |
+
above = confidences >= threshold
|
| 431 |
+
if not above.any():
|
| 432 |
+
continue
|
| 433 |
+
hits = targets[above]
|
| 434 |
+
predicted_per_target = np.bincount(hits, minlength=n_targets).astype(float)
|
| 435 |
+
true_positive = np.bincount(hits[correct[above]], minlength=n_targets).astype(float)
|
| 436 |
+
predicting = predicted_per_target > 0
|
| 437 |
+
if not predicting.any():
|
| 438 |
+
continue
|
| 439 |
+
precision = float((true_positive[predicting] / predicted_per_target[predicting]).mean())
|
| 440 |
+
recall = float((true_positive[annotated] / true_counts[annotated]).mean())
|
| 441 |
+
if precision + recall == 0:
|
| 442 |
+
continue
|
| 443 |
+
f1 = 2 * precision * recall / (precision + recall)
|
| 444 |
+
current_best = best["fmax"]
|
| 445 |
+
if current_best is None or f1 > current_best:
|
| 446 |
+
best.update(
|
| 447 |
+
fmax=f1,
|
| 448 |
+
threshold=float(threshold),
|
| 449 |
+
precision=precision,
|
| 450 |
+
recall=recall,
|
| 451 |
+
coverage=float(predicting.sum() / n_annotated),
|
| 452 |
+
)
|
| 453 |
+
return best
|
plug_challenge/scoring.py
ADDED
|
@@ -0,0 +1,268 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Turn a validated submission bundle into per-benchmark metric values.
|
| 2 |
+
|
| 3 |
+
One function per submission (``score_bundle``) and one per benchmark
|
| 4 |
+
(``score_benchmark``); which arithmetic runs is decided entirely by the
|
| 5 |
+
``MetricSpec.kind`` values in ``benchmarks.py``, so adding a metric to a
|
| 6 |
+
benchmark is a one-line change there and needs no edit here.
|
| 7 |
+
|
| 8 |
+
Scoring is deliberately separate from validation: by the time anything in this
|
| 9 |
+
module runs, the frames are known to have the right columns, the right ids and
|
| 10 |
+
finite values, so the metric code can assume a clean join.
|
| 11 |
+
"""
|
| 12 |
+
|
| 13 |
+
import numpy as np
|
| 14 |
+
import pandas as pd
|
| 15 |
+
from loguru import logger
|
| 16 |
+
|
| 17 |
+
from . import metrics
|
| 18 |
+
from .benchmarks import GO_ASPECTS, ID_COLUMN, BenchmarkSpec, MetricSpec
|
| 19 |
+
|
| 20 |
+
# Bootstrap resampling is not implemented for the long-form (cafa5) scorer: a
|
| 21 |
+
# resample has to redraw whole targets and recount each one's annotations, and a
|
| 22 |
+
# 101-point Fmax sweep per resample is far too slow to run inside a submission
|
| 23 |
+
# request. Its std is reported as 0.0 and the point estimate is exact.
|
| 24 |
+
_BOOTSTRAP_UNSUPPORTED = ("fmax",)
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def score_bundle(
|
| 28 |
+
frames: dict[str, pd.DataFrame],
|
| 29 |
+
truth: dict[str, pd.DataFrame],
|
| 30 |
+
specs: tuple[BenchmarkSpec, ...],
|
| 31 |
+
bootstrap_samples: int = 0,
|
| 32 |
+
seed: int = 0,
|
| 33 |
+
) -> dict[str, dict[str, float]]:
|
| 34 |
+
"""Score every benchmark present in both the submission and the ground truth.
|
| 35 |
+
|
| 36 |
+
Parameters
|
| 37 |
+
----------
|
| 38 |
+
frames : dict[str, pd.DataFrame]
|
| 39 |
+
Benchmark name -> validated predictions, as returned by
|
| 40 |
+
``validation.ValidationResult.frames``.
|
| 41 |
+
truth : dict[str, pd.DataFrame]
|
| 42 |
+
Benchmark name -> that benchmark's test ground truth.
|
| 43 |
+
specs : tuple[BenchmarkSpec, ...]
|
| 44 |
+
The benchmarks to score, in leaderboard order.
|
| 45 |
+
bootstrap_samples : int
|
| 46 |
+
Resamples per metric for the standard deviation. ``0`` reports point
|
| 47 |
+
estimates only, which is the Space default — see ``config``.
|
| 48 |
+
seed : int
|
| 49 |
+
Seed for the bootstrap RNG, so rescoring a submission reproduces it.
|
| 50 |
+
|
| 51 |
+
Returns
|
| 52 |
+
-------
|
| 53 |
+
dict[str, dict[str, float]]
|
| 54 |
+
Benchmark name -> ``{"<metric>_mean": ..., "<metric>_std": ..., "n": ...}``.
|
| 55 |
+
A benchmark absent from either input is absent from the result rather
|
| 56 |
+
than scored as zero.
|
| 57 |
+
|
| 58 |
+
"""
|
| 59 |
+
scores: dict[str, dict[str, float]] = {}
|
| 60 |
+
for spec in specs:
|
| 61 |
+
if spec.name not in frames or spec.name not in truth:
|
| 62 |
+
continue
|
| 63 |
+
scores[spec.name] = score_benchmark(
|
| 64 |
+
spec,
|
| 65 |
+
frames[spec.name],
|
| 66 |
+
truth[spec.name],
|
| 67 |
+
bootstrap_samples=bootstrap_samples,
|
| 68 |
+
seed=seed,
|
| 69 |
+
)
|
| 70 |
+
logger.info(
|
| 71 |
+
"Scored {}: {} = {:.4f} (n={})",
|
| 72 |
+
spec.name,
|
| 73 |
+
spec.primary.key,
|
| 74 |
+
scores[spec.name][f"{spec.primary.key}_mean"],
|
| 75 |
+
scores[spec.name]["n"],
|
| 76 |
+
)
|
| 77 |
+
return scores
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
def score_benchmark(
|
| 81 |
+
spec: BenchmarkSpec,
|
| 82 |
+
predictions: pd.DataFrame,
|
| 83 |
+
truth: pd.DataFrame,
|
| 84 |
+
bootstrap_samples: int = 0,
|
| 85 |
+
seed: int = 0,
|
| 86 |
+
) -> dict[str, float]:
|
| 87 |
+
"""Compute every metric one benchmark reports.
|
| 88 |
+
|
| 89 |
+
Parameters
|
| 90 |
+
----------
|
| 91 |
+
spec : BenchmarkSpec
|
| 92 |
+
The benchmark being scored.
|
| 93 |
+
predictions : pd.DataFrame
|
| 94 |
+
Validated predictions for this benchmark.
|
| 95 |
+
truth : pd.DataFrame
|
| 96 |
+
This benchmark's test ground truth.
|
| 97 |
+
bootstrap_samples : int
|
| 98 |
+
Resamples per metric; ``0`` for point estimates only.
|
| 99 |
+
seed : int
|
| 100 |
+
Bootstrap RNG seed.
|
| 101 |
+
|
| 102 |
+
Returns
|
| 103 |
+
-------
|
| 104 |
+
dict[str, float]
|
| 105 |
+
``{"<metric>_mean": ..., "<metric>_std": ..., "n": ...}`` for every metric
|
| 106 |
+
in ``spec.metrics``. ``n`` is the number of scored rows (datapoints for a
|
| 107 |
+
row-per-datapoint benchmark, annotated targets for cafa5).
|
| 108 |
+
|
| 109 |
+
"""
|
| 110 |
+
if spec.long_form:
|
| 111 |
+
return _score_long_form(spec, predictions, truth)
|
| 112 |
+
|
| 113 |
+
merged = truth.merge(
|
| 114 |
+
predictions[list(spec.required_columns)],
|
| 115 |
+
on=ID_COLUMN,
|
| 116 |
+
how="inner",
|
| 117 |
+
validate="one_to_one",
|
| 118 |
+
)
|
| 119 |
+
out: dict[str, float] = {"n": float(len(merged))}
|
| 120 |
+
for metric in spec.metrics:
|
| 121 |
+
mean, std = _bootstrap_metric(spec, metric, merged, bootstrap_samples, seed)
|
| 122 |
+
out[f"{metric.key}_mean"] = mean
|
| 123 |
+
out[f"{metric.key}_std"] = std
|
| 124 |
+
return out
|
| 125 |
+
|
| 126 |
+
|
| 127 |
+
def _bootstrap_metric(
|
| 128 |
+
spec: BenchmarkSpec,
|
| 129 |
+
metric: MetricSpec,
|
| 130 |
+
merged: pd.DataFrame,
|
| 131 |
+
bootstrap_samples: int,
|
| 132 |
+
seed: int,
|
| 133 |
+
) -> tuple[float, float]:
|
| 134 |
+
"""Compute one metric's point estimate and bootstrap standard deviation."""
|
| 135 |
+
groups = (
|
| 136 |
+
merged[metric.grouped_by].to_numpy()
|
| 137 |
+
if metric.grouped_by and metric.grouped_by in merged.columns
|
| 138 |
+
else None
|
| 139 |
+
)
|
| 140 |
+
|
| 141 |
+
def on_rows(rows: np.ndarray) -> float:
|
| 142 |
+
return _apply(spec, metric, merged.iloc[rows])
|
| 143 |
+
|
| 144 |
+
return metrics.bootstrap(
|
| 145 |
+
on_rows,
|
| 146 |
+
n_samples=bootstrap_samples,
|
| 147 |
+
n_rows=len(merged),
|
| 148 |
+
seed=seed,
|
| 149 |
+
groups=groups,
|
| 150 |
+
)
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
def _apply(spec: BenchmarkSpec, metric: MetricSpec, merged: pd.DataFrame) -> float:
|
| 154 |
+
"""Dispatch one ``MetricSpec`` against a merged truth/prediction frame."""
|
| 155 |
+
truth_column = spec.truth_columns[0] if spec.truth_columns else ""
|
| 156 |
+
pred_column = spec.pred_columns[0]
|
| 157 |
+
|
| 158 |
+
if metric.kind == "spearman":
|
| 159 |
+
return metrics.spearman(merged[truth_column], merged[pred_column])
|
| 160 |
+
if metric.kind == "auroc":
|
| 161 |
+
return metrics.auroc(merged[truth_column], merged[pred_column])
|
| 162 |
+
if metric.kind == "grouped_spearman":
|
| 163 |
+
return metrics.grouped_spearman(
|
| 164 |
+
merged[truth_column], merged[pred_column], merged[metric.grouped_by]
|
| 165 |
+
)
|
| 166 |
+
if metric.kind == "grouped_auroc":
|
| 167 |
+
return metrics.grouped_auroc(
|
| 168 |
+
merged[truth_column], merged[pred_column], merged[metric.grouped_by]
|
| 169 |
+
)
|
| 170 |
+
if metric.kind == "macro_auroc":
|
| 171 |
+
return metrics.macro_auroc(
|
| 172 |
+
merged[list(spec.truth_columns)].to_numpy(),
|
| 173 |
+
merged[list(spec.pred_columns)].to_numpy(),
|
| 174 |
+
)
|
| 175 |
+
raise ValueError(f"{spec.name}: metric kind {metric.kind!r} has no scorer here")
|
| 176 |
+
|
| 177 |
+
|
| 178 |
+
def _score_long_form(
|
| 179 |
+
spec: BenchmarkSpec, predictions: pd.DataFrame, truth: pd.DataFrame
|
| 180 |
+
) -> dict[str, float]:
|
| 181 |
+
"""Score cafa5: Fmax per GO branch plus the macro-average over the branches.
|
| 182 |
+
|
| 183 |
+
``truth`` is long form as well — one row per ``(datapoint_id, aspect, term)``
|
| 184 |
+
annotation — so both sides are reduced to the same three arrays per aspect
|
| 185 |
+
and handed to ``metrics.fmax_long``.
|
| 186 |
+
"""
|
| 187 |
+
pred = predictions.copy()
|
| 188 |
+
pred["aspect"] = pred["aspect"].astype(str).str.strip().str.lower()
|
| 189 |
+
pred["term"] = pred["term"].astype(str).str.strip()
|
| 190 |
+
gt = truth.copy()
|
| 191 |
+
gt["aspect"] = gt["aspect"].astype(str).str.strip().str.lower()
|
| 192 |
+
gt["term"] = gt["term"].astype(str).str.strip()
|
| 193 |
+
|
| 194 |
+
# Every test protein is a target, annotated or not — an unannotated one is
|
| 195 |
+
# dropped inside fmax_long, but it must be in the index so that a prediction
|
| 196 |
+
# about it is still counted against precision.
|
| 197 |
+
targets = pd.Index(sorted(set(gt[ID_COLUMN].astype(str)) | set(pred[ID_COLUMN].astype(str))))
|
| 198 |
+
target_of = {target: i for i, target in enumerate(targets)}
|
| 199 |
+
|
| 200 |
+
out: dict[str, float] = {}
|
| 201 |
+
per_aspect: dict[str, float] = {}
|
| 202 |
+
for aspect in GO_ASPECTS:
|
| 203 |
+
result = _fmax_for_aspect(aspect, pred, gt, targets, target_of)
|
| 204 |
+
value = result["fmax"]
|
| 205 |
+
per_aspect[aspect] = float("nan") if value is None else float(value)
|
| 206 |
+
out[f"fmax_{aspect}_mean"] = per_aspect[aspect]
|
| 207 |
+
out[f"fmax_{aspect}_std"] = 0.0
|
| 208 |
+
# Per-branch target counts differ a lot (a protein commonly carries BP
|
| 209 |
+
# annotations but no CC ones), so each is reported rather than collapsed.
|
| 210 |
+
out[f"fmax_{aspect}_n"] = float(result["targets"] or 0)
|
| 211 |
+
|
| 212 |
+
finite = [v for v in per_aspect.values() if np.isfinite(v)]
|
| 213 |
+
out["fmax_mean"] = float(np.mean(finite)) if finite else metrics.UNDEFINED
|
| 214 |
+
out["fmax_std"] = 0.0
|
| 215 |
+
# `n` is the number of test targets carrying at least one annotation in any
|
| 216 |
+
# branch — the targets this benchmark could score at all.
|
| 217 |
+
out["n"] = float(gt[ID_COLUMN].astype(str).nunique())
|
| 218 |
+
return out
|
| 219 |
+
|
| 220 |
+
|
| 221 |
+
def _fmax_for_aspect(
|
| 222 |
+
aspect: str,
|
| 223 |
+
pred: pd.DataFrame,
|
| 224 |
+
gt: pd.DataFrame,
|
| 225 |
+
targets: pd.Index,
|
| 226 |
+
target_of: dict[str, int],
|
| 227 |
+
) -> dict[str, float | None]:
|
| 228 |
+
"""Reduce one GO branch to long-form arrays and Fmax them."""
|
| 229 |
+
gt_aspect = gt[gt["aspect"] == aspect]
|
| 230 |
+
pred_aspect = pred[pred["aspect"] == aspect]
|
| 231 |
+
|
| 232 |
+
true_per_target = np.zeros(len(targets), dtype=float)
|
| 233 |
+
if not gt_aspect.empty:
|
| 234 |
+
counts = gt_aspect.groupby(gt_aspect[ID_COLUMN].astype(str))["term"].nunique()
|
| 235 |
+
for target, count in counts.items():
|
| 236 |
+
true_per_target[target_of[str(target)]] = float(count)
|
| 237 |
+
|
| 238 |
+
if pred_aspect.empty:
|
| 239 |
+
return {
|
| 240 |
+
"fmax": None if not true_per_target.any() else 0.0,
|
| 241 |
+
"threshold": None,
|
| 242 |
+
"precision": None,
|
| 243 |
+
"recall": None,
|
| 244 |
+
"coverage": 0.0,
|
| 245 |
+
"targets": int((true_per_target > 0).sum()),
|
| 246 |
+
}
|
| 247 |
+
|
| 248 |
+
annotated_pairs = set(
|
| 249 |
+
zip(gt_aspect[ID_COLUMN].astype(str), gt_aspect["term"], strict=True)
|
| 250 |
+
)
|
| 251 |
+
target_index = np.asarray(
|
| 252 |
+
[target_of[t] for t in pred_aspect[ID_COLUMN].astype(str)], dtype=np.int64
|
| 253 |
+
)
|
| 254 |
+
is_true = np.asarray(
|
| 255 |
+
[
|
| 256 |
+
(t, term) in annotated_pairs
|
| 257 |
+
for t, term in zip(
|
| 258 |
+
pred_aspect[ID_COLUMN].astype(str), pred_aspect["term"], strict=True
|
| 259 |
+
)
|
| 260 |
+
],
|
| 261 |
+
dtype=bool,
|
| 262 |
+
)
|
| 263 |
+
return metrics.fmax_long(
|
| 264 |
+
target_index=target_index,
|
| 265 |
+
scores=pred_aspect["score"].to_numpy(dtype=float),
|
| 266 |
+
is_true=is_true,
|
| 267 |
+
true_per_target=true_per_target,
|
| 268 |
+
)
|
plug_challenge/store.py
ADDED
|
@@ -0,0 +1,463 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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ores
|
| 4 |
+
and leaderboards in S3 and scores them from a scheduled Lambda. PLUG is not
|
| 5 |
+
blinded, so scoring can run synchronously inside the Space the moment a bundle is
|
| 6 |
+
uploaded — which removes the queue, the container image and the whole AWS
|
| 7 |
+
account. What is left is a storage layer, and two Hub dataset repos cover it:
|
| 8 |
+
|
| 9 |
+
``PRIVATE_REPO`` (private dataset) — everything the organisers hold::
|
| 10 |
+
|
| 11 |
+
ground_truth/<benchmark>.parquet test labels; never published
|
| 12 |
+
submissions/<user>/<submission_id>/metadata.json
|
| 13 |
+
submissions/<user>/<submission_id>/bundle.zip
|
| 14 |
+
scores/<user>/<submission_id>/scores.json
|
| 15 |
+
leaderboard/entries.csv one row per submission, incl. private fields
|
| 16 |
+
|
| 17 |
+
``PUBLIC_REPO`` (public dataset) — what participants download::
|
| 18 |
+
|
| 19 |
+
<benchmark>/sequences.fasta
|
| 20 |
+
<benchmark>/train.parquet, <benchmark>/val.parquet
|
| 21 |
+
<benchmark>/test_manifest.parquet test rows, labels removed
|
| 22 |
+
|
| 23 |
+
The Space authenticates to both with a single ``HF_TOKEN`` secret. Test labels
|
| 24 |
+
live only in ``PRIVATE_REPO``: the test *entities* are public (PLUG's splits are
|
| 25 |
+
published), but their labels are not, so a leaderboard number cannot be
|
| 26 |
+
self-reported.
|
| 27 |
+
"""
|
| 28 |
+
|
| 29 |
+
import json
|
| 30 |
+
import os
|
| 31 |
+
import tempfile
|
| 32 |
+
import time
|
| 33 |
+
from datetime import UTC, datetime
|
| 34 |
+
from functools import cache
|
| 35 |
+
from pathlib import Path
|
| 36 |
+
|
| 37 |
+
import pandas as pd
|
| 38 |
+
from huggingface_hub import HfApi, hf_hub_download
|
| 39 |
+
from huggingface_hub.errors import EntryNotFoundError, RepositoryNotFoundError
|
| 40 |
+
from loguru import logger
|
| 41 |
+
|
| 42 |
+
from .benchmarks import BENCHMARKS, ID_COLUMN
|
| 43 |
+
|
| 44 |
+
# Dataset repos. Overridable by Space variables so a staging Space can point at
|
| 45 |
+
# throwaway repos without a code change.
|
| 46 |
+
PRIVATE_REPO: str = os.environ.get("PLUG_PRIVATE_REPO", "PrismScienceOrg/plug-challenge-private")
|
| 47 |
+
PUBLIC_REPO: str = os.environ.get("PLUG_PUBLIC_REPO", "PrismScienceOrg/plug-challenge-data")
|
| 48 |
+
HF_TOKEN: str | None = os.environ.get("HF_TOKEN") or None
|
| 49 |
+
|
| 50 |
+
GROUND_TRUTH_PREFIX = "ground_truth"
|
| 51 |
+
SUBMISSIONS_PREFIX = "submissions"
|
| 52 |
+
SCORES_PREFIX = "scores"
|
| 53 |
+
LEADERBOARD_PATH = "leaderboard/entries.csv"
|
| 54 |
+
|
| 55 |
+
# Seconds a fetched leaderboard is reused before the Hub is asked again. The
|
| 56 |
+
# Space refreshes its tables on a 30 s timer and on every page load, so without
|
| 57 |
+
# this a handful of open tabs would re-download the same file continuously.
|
| 58 |
+
LEADERBOARD_CACHE_TTL = 20.0
|
| 59 |
+
|
| 60 |
+
_leaderboard_cache: tuple[float, pd.DataFrame] | None = None
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
def api() -> HfApi:
|
| 64 |
+
"""Return an ``HfApi`` client carrying the Space's token.
|
| 65 |
+
|
| 66 |
+
Returns
|
| 67 |
+
-------
|
| 68 |
+
HfApi
|
| 69 |
+
Client for both dataset repos.
|
| 70 |
+
|
| 71 |
+
"""
|
| 72 |
+
return HfApi(token=HF_TOKEN)
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
def configured() -> bool:
|
| 76 |
+
"""Report whether a token is available, i.e. the Space can read and write the repos.
|
| 77 |
+
|
| 78 |
+
Returns
|
| 79 |
+
-------
|
| 80 |
+
bool
|
| 81 |
+
False in a local checkout with no ``HF_TOKEN``, which the Space surfaces
|
| 82 |
+
as a "storage not configured" message rather than a traceback.
|
| 83 |
+
|
| 84 |
+
"""
|
| 85 |
+
return HF_TOKEN is not None
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
@cache
|
| 89 |
+
def load_ground_truth(benchmark: str) -> pd.DataFrame:
|
| 90 |
+
"""Download and cache one benchmark's test ground truth.
|
| 91 |
+
|
| 92 |
+
Cached for the lifetime of the process: the labels do not change while a
|
| 93 |
+
Space is running, and re-reading them per submission would add seconds to
|
| 94 |
+
every upload.
|
| 95 |
+
|
| 96 |
+
Parameters
|
| 97 |
+
----------
|
| 98 |
+
benchmark : str
|
| 99 |
+
Benchmark name.
|
| 100 |
+
|
| 101 |
+
Returns
|
| 102 |
+
-------
|
| 103 |
+
pd.DataFrame
|
| 104 |
+
The test-split ground truth, with ``datapoint_id`` as a string column.
|
| 105 |
+
|
| 106 |
+
Raises
|
| 107 |
+
------
|
| 108 |
+
FileNotFoundError
|
| 109 |
+
If the benchmark has no ground-truth file in ``PRIVATE_REPO`` — i.e. it
|
| 110 |
+
has not been staged yet.
|
| 111 |
+
|
| 112 |
+
"""
|
| 113 |
+
path = f"{GROUND_TRUTH_PREFIX}/{benchmark}.parquet"
|
| 114 |
+
try:
|
| 115 |
+
local = hf_hub_download(
|
| 116 |
+
repo_id=PRIVATE_REPO, filename=path, repo_type="dataset", token=HF_TOKEN
|
| 117 |
+
)
|
| 118 |
+
except (EntryNotFoundError, RepositoryNotFoundError) as exc:
|
| 119 |
+
raise FileNotFoundError(
|
| 120 |
+
f"No ground truth for {benchmark!r} at {PRIVATE_REPO}:{path}"
|
| 121 |
+
) from exc
|
| 122 |
+
frame = pd.read_parquet(local)
|
| 123 |
+
frame[ID_COLUMN] = frame[ID_COLUMN].astype(str)
|
| 124 |
+
logger.info("Loaded ground truth for {}: {} rows.", benchmark, len(frame))
|
| 125 |
+
return frame
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
def available_ground_truth() -> dict[str, pd.DataFrame]:
|
| 129 |
+
"""Load the ground truth for every benchmark that has been staged.
|
| 130 |
+
|
| 131 |
+
Returns
|
| 132 |
+
-------
|
| 133 |
+
dict[str, pd.DataFrame]
|
| 134 |
+
Benchmark name -> ground truth, skipping benchmarks whose labels are not
|
| 135 |
+
in ``PRIVATE_REPO`` yet. An empty dict means nothing can be scored.
|
| 136 |
+
|
| 137 |
+
"""
|
| 138 |
+
truth: dict[str, pd.DataFrame] = {}
|
| 139 |
+
for spec in BENCHMARKS:
|
| 140 |
+
try:
|
| 141 |
+
truth[spec.name] = load_ground_truth(spec.name)
|
| 142 |
+
except FileNotFoundError:
|
| 143 |
+
logger.warning("Ground truth not staged for {} — skipping.", spec.name)
|
| 144 |
+
return truth
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
def expected_ids(truth: dict[str, pd.DataFrame]) -> dict[str, set[str]]:
|
| 148 |
+
"""Extract the set of test ``datapoint_id`` values per benchmark.
|
| 149 |
+
|
| 150 |
+
Parameters
|
| 151 |
+
----------
|
| 152 |
+
truth : dict[str, pd.DataFrame]
|
| 153 |
+
Per-benchmark ground truth.
|
| 154 |
+
|
| 155 |
+
Returns
|
| 156 |
+
-------
|
| 157 |
+
dict[str, set[str]]
|
| 158 |
+
Benchmark name -> the ids a submission must cover.
|
| 159 |
+
|
| 160 |
+
"""
|
| 161 |
+
return {name: set(frame[ID_COLUMN].astype(str)) for name, frame in truth.items()}
|
| 162 |
+
|
| 163 |
+
|
| 164 |
+
def upload_submission(
|
| 165 |
+
safe_username: str, submission_id: str, bundle_path: Path, metadata: dict
|
| 166 |
+
) -> str:
|
| 167 |
+
"""Store one submission's bundle and metadata in the private repo.
|
| 168 |
+
|
| 169 |
+
Parameters
|
| 170 |
+
----------
|
| 171 |
+
safe_username : str
|
| 172 |
+
Path-safe Hugging Face username (see ``utils._safeify_username``).
|
| 173 |
+
submission_id : str
|
| 174 |
+
The submission's UUID.
|
| 175 |
+
bundle_path : Path
|
| 176 |
+
Local path to the uploaded ``.zip``.
|
| 177 |
+
metadata : dict
|
| 178 |
+
The serialised ``Submission`` model.
|
| 179 |
+
|
| 180 |
+
Returns
|
| 181 |
+
-------
|
| 182 |
+
str
|
| 183 |
+
The repo path the bundle was stored at.
|
| 184 |
+
|
| 185 |
+
"""
|
| 186 |
+
prefix = f"{SUBMISSIONS_PREFIX}/{safe_username}/{submission_id}"
|
| 187 |
+
client = api()
|
| 188 |
+
client.upload_file(
|
| 189 |
+
path_or_fileobj=str(bundle_path),
|
| 190 |
+
path_in_repo=f"{prefix}/bundle.zip",
|
| 191 |
+
repo_id=PRIVATE_REPO,
|
| 192 |
+
repo_type="dataset",
|
| 193 |
+
commit_message=f"submission {submission_id} bundle",
|
| 194 |
+
)
|
| 195 |
+
client.upload_file(
|
| 196 |
+
path_or_fileobj=json.dumps(metadata, indent=2, default=str).encode(),
|
| 197 |
+
path_in_repo=f"{prefix}/metadata.json",
|
| 198 |
+
repo_id=PRIVATE_REPO,
|
| 199 |
+
repo_type="dataset",
|
| 200 |
+
commit_message=f"submission {submission_id} metadata",
|
| 201 |
+
)
|
| 202 |
+
logger.info("Stored submission {} for {}.", submission_id, safe_username)
|
| 203 |
+
return f"{prefix}/bundle.zip"
|
| 204 |
+
|
| 205 |
+
|
| 206 |
+
def save_scores(safe_username: str, submission_id: str, scores: dict) -> None:
|
| 207 |
+
"""Store one submission's scores, the per-submission source of truth.
|
| 208 |
+
|
| 209 |
+
The leaderboard CSV is a derived, rewritten-in-place file; these per-
|
| 210 |
+
submission JSONs are append-only and never overwritten, so
|
| 211 |
+
``rebuild_leaderboard`` can always reconstruct the board from them.
|
| 212 |
+
|
| 213 |
+
Parameters
|
| 214 |
+
----------
|
| 215 |
+
safe_username : str
|
| 216 |
+
Path-safe Hugging Face username.
|
| 217 |
+
submission_id : str
|
| 218 |
+
The submission's UUID.
|
| 219 |
+
scores : dict
|
| 220 |
+
Everything needed to rebuild one leaderboard row: the identity fields
|
| 221 |
+
and the flattened per-benchmark metrics.
|
| 222 |
+
|
| 223 |
+
"""
|
| 224 |
+
api().upload_file(
|
| 225 |
+
path_or_fileobj=json.dumps(scores, indent=2, default=str).encode(),
|
| 226 |
+
path_in_repo=f"{SCORES_PREFIX}/{safe_username}/{submission_id}/scores.json",
|
| 227 |
+
repo_id=PRIVATE_REPO,
|
| 228 |
+
repo_type="dataset",
|
| 229 |
+
commit_message=f"scores for submission {submission_id}",
|
| 230 |
+
)
|
| 231 |
+
|
| 232 |
+
|
| 233 |
+
def read_leaderboard(use_cache: bool = True) -> pd.DataFrame:
|
| 234 |
+
"""Read the stored leaderboard entries.
|
| 235 |
+
|
| 236 |
+
Parameters
|
| 237 |
+
----------
|
| 238 |
+
use_cache : bool
|
| 239 |
+
Reuse a copy fetched within ``LEADERBOARD_CACHE_TTL`` seconds. Writers
|
| 240 |
+
pass False so a read-modify-write never appends onto a stale table.
|
| 241 |
+
|
| 242 |
+
Returns
|
| 243 |
+
-------
|
| 244 |
+
pd.DataFrame
|
| 245 |
+
One row per submission, or an empty frame when no leaderboard file
|
| 246 |
+
exists yet (a fresh challenge) or the repo is unreachable.
|
| 247 |
+
|
| 248 |
+
"""
|
| 249 |
+
global _leaderboard_cache
|
| 250 |
+
now = time.monotonic()
|
| 251 |
+
if use_cache and _leaderboard_cache is not None:
|
| 252 |
+
fetched_at, cached = _leaderboard_cache
|
| 253 |
+
if now - fetched_at < LEADERBOARD_CACHE_TTL:
|
| 254 |
+
return cached.copy()
|
| 255 |
+
try:
|
| 256 |
+
local = hf_hub_download(
|
| 257 |
+
repo_id=PRIVATE_REPO,
|
| 258 |
+
filename=LEADERBOARD_PATH,
|
| 259 |
+
repo_type="dataset",
|
| 260 |
+
token=HF_TOKEN,
|
| 261 |
+
)
|
| 262 |
+
frame = pd.read_csv(local)
|
| 263 |
+
except (EntryNotFoundError, RepositoryNotFoundError):
|
| 264 |
+
logger.info("No leaderboard file yet at {}:{}.", PRIVATE_REPO, LEADERBOARD_PATH)
|
| 265 |
+
frame = pd.DataFrame()
|
| 266 |
+
except Exception as exc:
|
| 267 |
+
logger.warning("Could not read the leaderboard: {}", exc)
|
| 268 |
+
frame = pd.DataFrame()
|
| 269 |
+
_leaderboard_cache = (now, frame)
|
| 270 |
+
return frame.copy()
|
| 271 |
+
|
| 272 |
+
|
| 273 |
+
def append_leaderboard_entry(entry: dict) -> None:
|
| 274 |
+
"""Add one scored submission to the leaderboard file.
|
| 275 |
+
|
| 276 |
+
A read-modify-write, which can lose an entry if two submissions land in the
|
| 277 |
+
same instant. The per-submission ``scores/`` JSONs are what make that
|
| 278 |
+
recoverable — ``plug-challenge rebuild`` reconstructs the file from them.
|
| 279 |
+
|
| 280 |
+
Parameters
|
| 281 |
+
----------
|
| 282 |
+
entry : dict
|
| 283 |
+
The row to append.
|
| 284 |
+
|
| 285 |
+
"""
|
| 286 |
+
existing = read_leaderboard(use_cache=False)
|
| 287 |
+
combined = (
|
| 288 |
+
pd.concat([existing, pd.DataFrame([entry])], ignore_index=True)
|
| 289 |
+
if not existing.empty
|
| 290 |
+
else pd.DataFrame([entry])
|
| 291 |
+
)
|
| 292 |
+
_upload_leaderboard(combined)
|
| 293 |
+
|
| 294 |
+
|
| 295 |
+
def write_leaderboard(frame: pd.DataFrame) -> None:
|
| 296 |
+
"""Replace the leaderboard file wholesale (used by ``rebuild``).
|
| 297 |
+
|
| 298 |
+
Parameters
|
| 299 |
+
----------
|
| 300 |
+
frame : pd.DataFrame
|
| 301 |
+
The complete set of entries.
|
| 302 |
+
|
| 303 |
+
"""
|
| 304 |
+
_upload_leaderboard(frame)
|
| 305 |
+
|
| 306 |
+
|
| 307 |
+
def _upload_leaderboard(frame: pd.DataFrame) -> None:
|
| 308 |
+
"""Serialise and upload the leaderboard entries, invalidating the read cache."""
|
| 309 |
+
global _leaderboard_cache
|
| 310 |
+
with tempfile.NamedTemporaryFile("w", suffix=".csv", delete=False) as handle:
|
| 311 |
+
frame.to_csv(handle, index=False)
|
| 312 |
+
path = handle.name
|
| 313 |
+
api().upload_file(
|
| 314 |
+
path_or_fileobj=path,
|
| 315 |
+
path_in_repo=LEADERBOARD_PATH,
|
| 316 |
+
repo_id=PRIVATE_REPO,
|
| 317 |
+
repo_type="dataset",
|
| 318 |
+
commit_message=f"leaderboard: {len(frame)} entries",
|
| 319 |
+
)
|
| 320 |
+
Path(path).unlink(missing_ok=True)
|
| 321 |
+
_leaderboard_cache = None
|
| 322 |
+
logger.info("Wrote leaderboard with {} entries.", len(frame))
|
| 323 |
+
|
| 324 |
+
|
| 325 |
+
def all_scores() -> list[dict]:
|
| 326 |
+
"""Read every per-submission score file in the private repo.
|
| 327 |
+
|
| 328 |
+
Parameters
|
| 329 |
+
----------
|
| 330 |
+
None
|
| 331 |
+
|
| 332 |
+
Returns
|
| 333 |
+
-------
|
| 334 |
+
list[dict]
|
| 335 |
+
One dict per scored submission. Used by ``rebuild_leaderboard``; it is
|
| 336 |
+
one request per submission, so it is a maintenance path rather than
|
| 337 |
+
something a page load ever triggers.
|
| 338 |
+
|
| 339 |
+
"""
|
| 340 |
+
client = api()
|
| 341 |
+
files = client.list_repo_files(repo_id=PRIVATE_REPO, repo_type="dataset")
|
| 342 |
+
score_files = [f for f in files if f.startswith(f"{SCORES_PREFIX}/") and f.endswith(".json")]
|
| 343 |
+
entries = []
|
| 344 |
+
for path in score_files:
|
| 345 |
+
local = hf_hub_download(
|
| 346 |
+
repo_id=PRIVATE_REPO, filename=path, repo_type="dataset", token=HF_TOKEN
|
| 347 |
+
)
|
| 348 |
+
entries.append(json.loads(Path(local).read_text()))
|
| 349 |
+
logger.info("Read {} score file(s).", len(entries))
|
| 350 |
+
return entries
|
| 351 |
+
|
| 352 |
+
|
| 353 |
+
def last_submission_at(safe_username: str) -> datetime | None:
|
| 354 |
+
"""When this user last submitted, for the submission cooldown.
|
| 355 |
+
|
| 356 |
+
Read from the leaderboard file rather than by listing the repo, so a
|
| 357 |
+
rejected-but-uploaded bundle does not count and the check is one request.
|
| 358 |
+
|
| 359 |
+
Parameters
|
| 360 |
+
----------
|
| 361 |
+
safe_username : str
|
| 362 |
+
Path-safe Hugging Face username.
|
| 363 |
+
|
| 364 |
+
Returns
|
| 365 |
+
-------
|
| 366 |
+
datetime | None
|
| 367 |
+
UTC timestamp of the most recent scored submission, or None if there is
|
| 368 |
+
none.
|
| 369 |
+
|
| 370 |
+
"""
|
| 371 |
+
frame = read_leaderboard()
|
| 372 |
+
if frame.empty or "safe_username" not in frame.columns:
|
| 373 |
+
return None
|
| 374 |
+
mine = frame[frame["safe_username"].astype(str) == safe_username]
|
| 375 |
+
if mine.empty:
|
| 376 |
+
return None
|
| 377 |
+
stamps = pd.to_datetime(mine["submitted_at"], utc=True, errors="coerce").dropna()
|
| 378 |
+
if stamps.empty:
|
| 379 |
+
return None
|
| 380 |
+
return stamps.max().to_pydatetime().astimezone(UTC)
|
| 381 |
+
|
| 382 |
+
|
| 383 |
+
def now() -> datetime:
|
| 384 |
+
"""Return the current UTC time, as one place for the tests to patch.
|
| 385 |
+
|
| 386 |
+
Returns
|
| 387 |
+
-------
|
| 388 |
+
datetime
|
| 389 |
+
Timezone-aware UTC now.
|
| 390 |
+
|
| 391 |
+
"""
|
| 392 |
+
return datetime.now(UTC)
|
| 393 |
+
|
| 394 |
+
|
| 395 |
+
def load_test_manifest(benchmark: str, local_dir: Path | None = None) -> pd.DataFrame:
|
| 396 |
+
"""Load one benchmark's public test manifest.
|
| 397 |
+
|
| 398 |
+
The manifest is the unlabelled counterpart of the ground truth — the same
|
| 399 |
+
``datapoint_id`` values, the input columns, no labels. It is what lets a
|
| 400 |
+
participant validate a bundle locally (``plug-challenge validate``) without
|
| 401 |
+
the organisers' token, since it carries exactly the ids a submission must
|
| 402 |
+
cover.
|
| 403 |
+
|
| 404 |
+
Parameters
|
| 405 |
+
----------
|
| 406 |
+
benchmark : str
|
| 407 |
+
Benchmark name.
|
| 408 |
+
local_dir : Path | None
|
| 409 |
+
Read ``<local_dir>/<benchmark>/test_manifest.parquet`` instead of the
|
| 410 |
+
Hub, for offline use and for the data build.
|
| 411 |
+
|
| 412 |
+
Returns
|
| 413 |
+
-------
|
| 414 |
+
pd.DataFrame
|
| 415 |
+
The test manifest, with ``datapoint_id`` as a string column.
|
| 416 |
+
|
| 417 |
+
Raises
|
| 418 |
+
------
|
| 419 |
+
FileNotFoundError
|
| 420 |
+
If the manifest is neither on disk nor in ``PUBLIC_REPO``.
|
| 421 |
+
|
| 422 |
+
"""
|
| 423 |
+
path = f"{benchmark}/test_manifest.parquet"
|
| 424 |
+
if local_dir is not None:
|
| 425 |
+
candidate = local_dir / benchmark / "test_manifest.parquet"
|
| 426 |
+
if not candidate.exists():
|
| 427 |
+
raise FileNotFoundError(f"No test manifest at {candidate}")
|
| 428 |
+
frame = pd.read_parquet(candidate)
|
| 429 |
+
else:
|
| 430 |
+
try:
|
| 431 |
+
local = hf_hub_download(
|
| 432 |
+
repo_id=PUBLIC_REPO, filename=path, repo_type="dataset", token=HF_TOKEN
|
| 433 |
+
)
|
| 434 |
+
except (EntryNotFoundError, RepositoryNotFoundError) as exc:
|
| 435 |
+
raise FileNotFoundError(
|
| 436 |
+
f"No test manifest for {benchmark!r} at {PUBLIC_REPO}:{path}"
|
| 437 |
+
) from exc
|
| 438 |
+
frame = pd.read_parquet(local)
|
| 439 |
+
frame[ID_COLUMN] = frame[ID_COLUMN].astype(str)
|
| 440 |
+
return frame
|
| 441 |
+
|
| 442 |
+
|
| 443 |
+
def manifest_ids(local_dir: Path | None = None) -> dict[str, set[str]]:
|
| 444 |
+
"""Collect the test ``datapoint_id`` sets from the public manifests.
|
| 445 |
+
|
| 446 |
+
Parameters
|
| 447 |
+
----------
|
| 448 |
+
local_dir : Path | None
|
| 449 |
+
Read manifests from this directory instead of the Hub.
|
| 450 |
+
|
| 451 |
+
Returns
|
| 452 |
+
-------
|
| 453 |
+
dict[str, set[str]]
|
| 454 |
+
Benchmark name -> its test ids, skipping benchmarks with no manifest.
|
| 455 |
+
|
| 456 |
+
"""
|
| 457 |
+
ids: dict[str, set[str]] = {}
|
| 458 |
+
for spec in BENCHMARKS:
|
| 459 |
+
try:
|
| 460 |
+
ids[spec.name] = set(load_test_manifest(spec.name, local_dir=local_dir)[ID_COLUMN])
|
| 461 |
+
except FileNotFoundError:
|
| 462 |
+
logger.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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Submission bundle validation.
|
| 2 |
+
|
| 3 |
+
A PLUG submission is a single ``.zip`` carrying one file per benchmark. This
|
| 4 |
+
module is the one place that decides whether such a bundle is scorable, and it
|
| 5 |
+
runs in three places against the same rules: in the Space before a submission is
|
| 6 |
+
accepted, in ``plug_challenge.cli`` so participants can check a bundle locally
|
| 7 |
+
before uploading, and in the tests.
|
| 8 |
+
|
| 9 |
+
Every check produces a ``SubmissionError`` naming the benchmark it belongs to, so
|
| 10 |
+
the Space can show a participant every problem in their bundle at once instead of
|
| 11 |
+
one per upload attempt.
|
| 12 |
+
"""
|
| 13 |
+
|
| 14 |
+
import zipfile
|
| 15 |
+
from dataclasses import dataclass, field
|
| 16 |
+
from pathlib import Path
|
| 17 |
+
|
| 18 |
+
import numpy as np
|
| 19 |
+
import pandas as pd
|
| 20 |
+
from loguru import logger
|
| 21 |
+
|
| 22 |
+
from .benchmarks import BENCHMARK_NAMES, BENCHMARKS, ID_COLUMN, BenchmarkSpec
|
| 23 |
+
|
| 24 |
+
# Reject a prediction column whose standard deviation is below this, for the
|
| 25 |
+
# benchmarks scored by a rank statistic: a constant column makes Spearman and
|
| 26 |
+
# AUROC undefined, and near-constant columns with a dither of noise are the usual
|
| 27 |
+
# way that gets smuggled past an equality check. Fmax is exempt — see
|
| 28 |
+
# BenchmarkSpec.needs_varying_predictions.
|
| 29 |
+
MIN_PREDICTION_STD = 1e-9
|
| 30 |
+
|
| 31 |
+
# Entries a zip archive may carry that are not submission files. macOS's
|
| 32 |
+
# Archive Utility adds both.
|
| 33 |
+
_IGNORED_ZIP_PREFIXES = ("__MACOSX/", ".")
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
@dataclass(frozen=True)
|
| 37 |
+
class SubmissionError:
|
| 38 |
+
"""A single reason a bundle cannot be scored.
|
| 39 |
+
|
| 40 |
+
Attributes
|
| 41 |
+
----------
|
| 42 |
+
benchmark : str
|
| 43 |
+
Which benchmark the problem is in, or ``"bundle"`` for a problem with
|
| 44 |
+
the archive itself.
|
| 45 |
+
message : str
|
| 46 |
+
Participant-facing description, specific enough to act on without
|
| 47 |
+
needing the scorer's source.
|
| 48 |
+
|
| 49 |
+
"""
|
| 50 |
+
|
| 51 |
+
benchmark: str
|
| 52 |
+
message: str
|
| 53 |
+
|
| 54 |
+
def __str__(self) -> str:
|
| 55 |
+
"""Render as ``benchmark: message`` for display on the Space."""
|
| 56 |
+
return f"{self.benchmark}: {self.message}"
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
@dataclass
|
| 60 |
+
class ValidationResult:
|
| 61 |
+
"""The outcome of validating one bundle.
|
| 62 |
+
|
| 63 |
+
Attributes
|
| 64 |
+
----------
|
| 65 |
+
errors : list[SubmissionError]
|
| 66 |
+
Problems that make the bundle unscorable. Empty means it is scorable.
|
| 67 |
+
warnings : list[SubmissionError]
|
| 68 |
+
Problems worth telling the participant about that do not block scoring —
|
| 69 |
+
today, only a benchmark left out of a bundle when the challenge accepts
|
| 70 |
+
partial ones.
|
| 71 |
+
frames : dict[str, pd.DataFrame]
|
| 72 |
+
Per-benchmark parsed predictions, populated only for the benchmarks that
|
| 73 |
+
validated cleanly — so a caller can score a partial bundle when the
|
| 74 |
+
challenge allows it.
|
| 75 |
+
|
| 76 |
+
"""
|
| 77 |
+
|
| 78 |
+
errors: list[SubmissionError] = field(default_factory=list)
|
| 79 |
+
warnings: list[SubmissionError] = field(default_factory=list)
|
| 80 |
+
frames: dict[str, pd.DataFrame] = field(default_factory=dict)
|
| 81 |
+
|
| 82 |
+
@property
|
| 83 |
+
def ok(self) -> bool:
|
| 84 |
+
"""True when the bundle can be scored (warnings do not count)."""
|
| 85 |
+
return not self.errors
|
| 86 |
+
|
| 87 |
+
def add(self, benchmark: str, message: str) -> None:
|
| 88 |
+
"""Record a blocking problem."""
|
| 89 |
+
self.errors.append(SubmissionError(benchmark=benchmark, message=message))
|
| 90 |
+
|
| 91 |
+
def warn(self, benchmark: str, message: str) -> None:
|
| 92 |
+
"""Record a non-blocking problem."""
|
| 93 |
+
self.warnings.append(SubmissionError(benchmark=benchmark, message=message))
|
| 94 |
+
|
| 95 |
+
def report(self, limit: int = 12) -> str:
|
| 96 |
+
"""Format the errors as a participant-facing message.
|
| 97 |
+
|
| 98 |
+
Parameters
|
| 99 |
+
----------
|
| 100 |
+
limit : int
|
| 101 |
+
Maximum number of errors to list before summarising the remainder,
|
| 102 |
+
so a badly wrong bundle does not produce an unreadable wall of text.
|
| 103 |
+
|
| 104 |
+
Returns
|
| 105 |
+
-------
|
| 106 |
+
str
|
| 107 |
+
One bullet per error.
|
| 108 |
+
|
| 109 |
+
"""
|
| 110 |
+
problems = self.errors or self.warnings
|
| 111 |
+
if not problems:
|
| 112 |
+
return "Bundle is valid."
|
| 113 |
+
lines = [f"- {problem}" for problem in problems[:limit]]
|
| 114 |
+
if len(problems) > limit:
|
| 115 |
+
lines.append(f"- ...and {len(problems) - limit} more.")
|
| 116 |
+
return "\n".join(lines)
|
| 117 |
+
|
| 118 |
+
|
| 119 |
+
def read_table(path: Path) -> pd.DataFrame:
|
| 120 |
+
"""Read a submission file, accepting either CSV or Parquet.
|
| 121 |
+
|
| 122 |
+
Parameters
|
| 123 |
+
----------
|
| 124 |
+
path : Path
|
| 125 |
+
Path to a ``.csv`` or ``.parquet`` file.
|
| 126 |
+
|
| 127 |
+
Returns
|
| 128 |
+
-------
|
| 129 |
+
pd.DataFrame
|
| 130 |
+
The parsed table.
|
| 131 |
+
|
| 132 |
+
Raises
|
| 133 |
+
------
|
| 134 |
+
ValueError
|
| 135 |
+
If the suffix is neither ``.csv`` nor ``.parquet``.
|
| 136 |
+
|
| 137 |
+
"""
|
| 138 |
+
suffix = path.suffix.lower()
|
| 139 |
+
if suffix == ".parquet":
|
| 140 |
+
return pd.read_parquet(path)
|
| 141 |
+
if suffix == ".csv":
|
| 142 |
+
return pd.read_csv(path)
|
| 143 |
+
raise ValueError(f"Expected a .csv or .parquet file, got {path.name!r}")
|
| 144 |
+
|
| 145 |
+
|
| 146 |
+
def bundle_members(bundle_path: Path) -> dict[str, str]:
|
| 147 |
+
"""Map each benchmark name to its entry in the bundle.
|
| 148 |
+
|
| 149 |
+
Matching is on the file's basename with its extension dropped, so a bundle
|
| 150 |
+
zipped from a directory (``plug_submission/megascale.csv``) works as well as
|
| 151 |
+
one zipped from loose files, and either ``.csv`` or ``.parquet`` is accepted
|
| 152 |
+
per benchmark.
|
| 153 |
+
|
| 154 |
+
Parameters
|
| 155 |
+
----------
|
| 156 |
+
bundle_path : Path
|
| 157 |
+
The uploaded ``.zip``.
|
| 158 |
+
|
| 159 |
+
Returns
|
| 160 |
+
-------
|
| 161 |
+
dict[str, str]
|
| 162 |
+
Benchmark name -> zip entry name, for the benchmarks present.
|
| 163 |
+
|
| 164 |
+
"""
|
| 165 |
+
found: dict[str, str] = {}
|
| 166 |
+
with zipfile.ZipFile(bundle_path) as archive:
|
| 167 |
+
for entry in archive.namelist():
|
| 168 |
+
if entry.endswith("/") or any(
|
| 169 |
+
part.startswith(_IGNORED_ZIP_PREFIXES) for part in entry.split("/")
|
| 170 |
+
):
|
| 171 |
+
continue
|
| 172 |
+
stem = Path(entry).stem
|
| 173 |
+
suffix = Path(entry).suffix.lower()
|
| 174 |
+
if stem in BENCHMARK_NAMES and suffix in (".csv", ".parquet"):
|
| 175 |
+
# A bundle listing the same benchmark twice (e.g. both a .csv and a
|
| 176 |
+
# .parquet) is ambiguous rather than harmless — keep the first and
|
| 177 |
+
# let validate_bundle report the duplicate.
|
| 178 |
+
found.setdefault(stem, entry)
|
| 179 |
+
return found
|
| 180 |
+
|
| 181 |
+
|
| 182 |
+
def validate_bundle(
|
| 183 |
+
bundle_path: Path,
|
| 184 |
+
expected_ids: dict[str, set[str]],
|
| 185 |
+
require_complete: bool = True,
|
| 186 |
+
) -> ValidationResult:
|
| 187 |
+
"""Validate a submission bundle end to end.
|
| 188 |
+
|
| 189 |
+
Parameters
|
| 190 |
+
----------
|
| 191 |
+
bundle_path : Path
|
| 192 |
+
The uploaded ``.zip``.
|
| 193 |
+
expected_ids : dict[str, set[str]]
|
| 194 |
+
Benchmark name -> the set of ``datapoint_id`` values the test split
|
| 195 |
+
covers, taken from the ground truth. A benchmark missing from this map is
|
| 196 |
+
treated as not currently scorable and is skipped with an error.
|
| 197 |
+
require_complete : bool
|
| 198 |
+
When True (the challenge default), a bundle missing any benchmark is
|
| 199 |
+
rejected. When False, missing benchmarks are recorded as errors but the
|
| 200 |
+
benchmarks that are present still parse into ``frames``.
|
| 201 |
+
|
| 202 |
+
Returns
|
| 203 |
+
-------
|
| 204 |
+
ValidationResult
|
| 205 |
+
Errors found, and the parsed frames for the benchmarks that passed.
|
| 206 |
+
|
| 207 |
+
"""
|
| 208 |
+
result = ValidationResult()
|
| 209 |
+
|
| 210 |
+
if not bundle_path.exists():
|
| 211 |
+
result.add("bundle", f"File not found: {bundle_path}")
|
| 212 |
+
return result
|
| 213 |
+
if bundle_path.suffix.lower() != ".zip":
|
| 214 |
+
result.add(
|
| 215 |
+
"bundle",
|
| 216 |
+
f"Submissions must be a single .zip archive, got {bundle_path.suffix!r}.",
|
| 217 |
+
)
|
| 218 |
+
return result
|
| 219 |
+
try:
|
| 220 |
+
members = bundle_members(bundle_path)
|
| 221 |
+
except zipfile.BadZipFile as exc:
|
| 222 |
+
result.add("bundle", f"Could not read the zip archive — {exc}")
|
| 223 |
+
return result
|
| 224 |
+
|
| 225 |
+
missing = [name for name in BENCHMARK_NAMES if name not in members]
|
| 226 |
+
if missing:
|
| 227 |
+
message = (
|
| 228 |
+
f"Missing {len(missing)} of {len(BENCHMARK_NAMES)} benchmark files: "
|
| 229 |
+
f"{', '.join(missing)}. Expected one file per benchmark, named "
|
| 230 |
+
f"<benchmark>.csv or <benchmark>.parquet."
|
| 231 |
+
)
|
| 232 |
+
if require_complete:
|
| 233 |
+
result.add("bundle", message)
|
| 234 |
+
return result
|
| 235 |
+
# Partial bundles are allowed here, so an absent benchmark is something to
|
| 236 |
+
# report rather than a reason to refuse: the rest still scores, and the
|
| 237 |
+
# leaderboard's `benchmarks_scored` column shows what was left out.
|
| 238 |
+
result.warn("bundle", message)
|
| 239 |
+
|
| 240 |
+
with zipfile.ZipFile(bundle_path) as archive:
|
| 241 |
+
for spec in BENCHMARKS:
|
| 242 |
+
entry = members.get(spec.name)
|
| 243 |
+
if entry is None:
|
| 244 |
+
continue
|
| 245 |
+
if spec.name not in expected_ids:
|
| 246 |
+
result.add(
|
| 247 |
+
spec.name,
|
| 248 |
+
"This benchmark is not open for scoring yet — remove it from the "
|
| 249 |
+
"bundle or check the challenge status.",
|
| 250 |
+
)
|
| 251 |
+
continue
|
| 252 |
+
frame = _read_member(archive, entry, spec, result)
|
| 253 |
+
if frame is None:
|
| 254 |
+
continue
|
| 255 |
+
before = len(result.errors)
|
| 256 |
+
_validate_frame(frame, spec, expected_ids[spec.name], result)
|
| 257 |
+
if len(result.errors) == before:
|
| 258 |
+
result.frames[spec.name] = frame
|
| 259 |
+
|
| 260 |
+
logger.info(
|
| 261 |
+
"Validated bundle {}: {} benchmark(s) parsed, {} error(s), {} warning(s).",
|
| 262 |
+
bundle_path.name,
|
| 263 |
+
len(result.frames),
|
| 264 |
+
len(result.errors),
|
| 265 |
+
len(result.warnings),
|
| 266 |
+
)
|
| 267 |
+
return result
|
| 268 |
+
|
| 269 |
+
|
| 270 |
+
def _read_member(
|
| 271 |
+
archive: zipfile.ZipFile, entry: str, spec: BenchmarkSpec, result: ValidationResult
|
| 272 |
+
) -> pd.DataFrame | None:
|
| 273 |
+
"""Read one benchmark's file out of the bundle, recording a parse failure."""
|
| 274 |
+
try:
|
| 275 |
+
with archive.open(entry) as handle:
|
| 276 |
+
if entry.lower().endswith(".parquet"):
|
| 277 |
+
return pd.read_parquet(handle)
|
| 278 |
+
return pd.read_csv(handle)
|
| 279 |
+
except Exception as exc:
|
| 280 |
+
result.add(spec.name, f"Could not read {entry!r} — {exc}")
|
| 281 |
+
return None
|
| 282 |
+
|
| 283 |
+
|
| 284 |
+
def _validate_frame(
|
| 285 |
+
frame: pd.DataFrame,
|
| 286 |
+
spec: BenchmarkSpec,
|
| 287 |
+
expected: set[str],
|
| 288 |
+
result: ValidationResult,
|
| 289 |
+
) -> None:
|
| 290 |
+
"""Apply every schema and value check for one benchmark."""
|
| 291 |
+
absent = [column for column in spec.required_columns if column not in frame.columns]
|
| 292 |
+
if absent:
|
| 293 |
+
result.add(
|
| 294 |
+
spec.name,
|
| 295 |
+
f"Missing required column(s): {', '.join(absent)}. Expected "
|
| 296 |
+
f"{', '.join(spec.required_columns)} (column names are case-sensitive).",
|
| 297 |
+
)
|
| 298 |
+
return
|
| 299 |
+
|
| 300 |
+
if frame.empty:
|
| 301 |
+
result.add(spec.name, "File has no rows.")
|
| 302 |
+
return
|
| 303 |
+
|
| 304 |
+
ids = frame[ID_COLUMN].astype(str)
|
| 305 |
+
if spec.long_form:
|
| 306 |
+
_validate_long_form(frame, ids, spec, expected, result)
|
| 307 |
+
else:
|
| 308 |
+
_validate_row_per_datapoint(ids, spec, expected, result)
|
| 309 |
+
|
| 310 |
+
for column in spec.pred_columns:
|
| 311 |
+
_validate_predictions(frame[column], column, spec, result)
|
| 312 |
+
|
| 313 |
+
|
| 314 |
+
def _validate_row_per_datapoint(
|
| 315 |
+
ids: pd.Series, spec: BenchmarkSpec, expected: set[str], result: ValidationResult
|
| 316 |
+
) -> None:
|
| 317 |
+
"""Require exactly one row per test datapoint, no duplicates, nothing extra."""
|
| 318 |
+
duplicated = ids[ids.duplicated()].unique()
|
| 319 |
+
if duplicated.size:
|
| 320 |
+
result.add(
|
| 321 |
+
spec.name,
|
| 322 |
+
f"{duplicated.size} duplicated {ID_COLUMN} value(s), e.g. "
|
| 323 |
+
f"{', '.join(map(str, duplicated[:3]))}. Exactly one row per "
|
| 324 |
+
f"{spec.unit} is expected.",
|
| 325 |
+
)
|
| 326 |
+
submitted = set(ids)
|
| 327 |
+
if submitted == expected:
|
| 328 |
+
return
|
| 329 |
+
absent, unknown = expected - submitted, submitted - expected
|
| 330 |
+
if absent:
|
| 331 |
+
result.add(
|
| 332 |
+
spec.name,
|
| 333 |
+
f"{len(absent)} of {len(expected)} test {spec.unit}s have no prediction, "
|
| 334 |
+
f"e.g. {', '.join(sorted(absent)[:3])}.",
|
| 335 |
+
)
|
| 336 |
+
if unknown:
|
| 337 |
+
result.add(
|
| 338 |
+
spec.name,
|
| 339 |
+
f"{len(unknown)} {ID_COLUMN} value(s) are not in the test split, e.g. "
|
| 340 |
+
f"{', '.join(sorted(unknown)[:3])}. Submit predictions for the rows in "
|
| 341 |
+
f"this benchmark's test manifest and nothing else.",
|
| 342 |
+
)
|
| 343 |
+
|
| 344 |
+
|
| 345 |
+
def _validate_long_form(
|
| 346 |
+
frame: pd.DataFrame,
|
| 347 |
+
ids: pd.Series,
|
| 348 |
+
spec: BenchmarkSpec,
|
| 349 |
+
expected: set[str],
|
| 350 |
+
result: ValidationResult,
|
| 351 |
+
) -> None:
|
| 352 |
+
"""Validate a variable-length submission (cafa5): a set of (id, term) pairs.
|
| 353 |
+
|
| 354 |
+
Unlike a row-per-datapoint benchmark, declining to predict a target is
|
| 355 |
+
allowed here — that is what Fmax's coverage term measures — so a missing id
|
| 356 |
+
is not an error. Predicting a target outside the test split still is.
|
| 357 |
+
"""
|
| 358 |
+
unknown = set(ids) - expected
|
| 359 |
+
if unknown:
|
| 360 |
+
result.add(
|
| 361 |
+
spec.name,
|
| 362 |
+
f"{len(unknown)} {ID_COLUMN} value(s) are not in the test split, e.g. "
|
| 363 |
+
f"{', '.join(sorted(unknown)[:3])}.",
|
| 364 |
+
)
|
| 365 |
+
for column in spec.extra_columns:
|
| 366 |
+
blank = frame[column].isna() | (frame[column].astype(str).str.strip() == "")
|
| 367 |
+
if blank.any():
|
| 368 |
+
result.add(spec.name, f"{int(blank.sum())} row(s) have an empty {column!r}.")
|
| 369 |
+
for column, allowed in spec.allowed_values.items():
|
| 370 |
+
bad = ~frame[column].astype(str).str.strip().str.lower().isin(allowed)
|
| 371 |
+
if bad.any():
|
| 372 |
+
result.add(
|
| 373 |
+
spec.name,
|
| 374 |
+
f"{int(bad.sum())} row(s) have an unrecognised {column!r}; expected "
|
| 375 |
+
f"one of {', '.join(allowed)}.",
|
| 376 |
+
)
|
| 377 |
+
pair_columns = [ID_COLUMN, *spec.extra_columns]
|
| 378 |
+
duplicated = frame.duplicated(subset=pair_columns)
|
| 379 |
+
if duplicated.any():
|
| 380 |
+
result.add(
|
| 381 |
+
spec.name,
|
| 382 |
+
f"{int(duplicated.sum())} duplicated ({', '.join(pair_columns)}) pair(s). "
|
| 383 |
+
"Predict each term at most once per protein.",
|
| 384 |
+
)
|
| 385 |
+
covered = len(set(ids) & expected)
|
| 386 |
+
if covered == 0:
|
| 387 |
+
result.add(
|
| 388 |
+
spec.name,
|
| 389 |
+
f"No row refers to a test-split {spec.unit}; nothing could be scored.",
|
| 390 |
+
)
|
| 391 |
+
|
| 392 |
+
|
| 393 |
+
def _validate_predictions(
|
| 394 |
+
column: pd.Series, name: str, spec: BenchmarkSpec, result: ValidationResult
|
| 395 |
+
) -> None:
|
| 396 |
+
"""Check one prediction column is numeric, finite, in range, and not constant."""
|
| 397 |
+
values = pd.to_numeric(column, errors="coerce")
|
| 398 |
+
non_numeric = values.isna() & column.notna()
|
| 399 |
+
if non_numeric.any():
|
| 400 |
+
result.add(
|
| 401 |
+
spec.name,
|
| 402 |
+
f"Column {name!r} has {int(non_numeric.sum())} non-numeric value(s).",
|
| 403 |
+
)
|
| 404 |
+
return
|
| 405 |
+
if values.isna().any():
|
| 406 |
+
result.add(
|
| 407 |
+
spec.name,
|
| 408 |
+
f"Column {name!r} has {int(values.isna().sum())} missing value(s); every "
|
| 409 |
+
"prediction is required.",
|
| 410 |
+
)
|
| 411 |
+
return
|
| 412 |
+
finite = np.isfinite(values.to_numpy(dtype=float))
|
| 413 |
+
if not finite.all():
|
| 414 |
+
result.add(
|
| 415 |
+
spec.name,
|
| 416 |
+
f"Column {name!r} has {int((~finite).sum())} infinite value(s).",
|
| 417 |
+
)
|
| 418 |
+
return
|
| 419 |
+
if spec.score_range is not None:
|
| 420 |
+
low, high = spec.score_range
|
| 421 |
+
outside = (values < low) | (values > high)
|
| 422 |
+
if outside.any():
|
| 423 |
+
result.add(
|
| 424 |
+
spec.name,
|
| 425 |
+
f"Column {name!r} has {int(outside.sum())} value(s) outside "
|
| 426 |
+
f"[{low}, {high}].",
|
| 427 |
+
)
|
| 428 |
+
if spec.needs_varying_predictions and float(values.std()) < MIN_PREDICTION_STD:
|
| 429 |
+
result.add(
|
| 430 |
+
spec.name,
|
| 431 |
+
f"Column {name!r} is constant (or all but constant). This benchmark's "
|
| 432 |
+
"metrics are rank statistics, so a constant column cannot be scored — "
|
| 433 |
+
"please submit real model outputs.",
|
| 434 |
+
)
|
pyproject.toml
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[build-system]
|
| 2 |
+
requires = ["setuptools>=68"]
|
| 3 |
+
build-backend = "setuptools.build_meta"
|
| 4 |
+
|
| 5 |
+
[project]
|
| 6 |
+
name = "plug-challenge"
|
| 7 |
+
version = "0.1.0"
|
| 8 |
+
description = "Scoring library and submission tooling for the PLUG challenge"
|
| 9 |
+
readme = "README.md"
|
| 10 |
+
requires-python = ">=3.11"
|
| 11 |
+
license = { text = "Apache-2.0" }
|
| 12 |
+
dependencies = [
|
| 13 |
+
"numpy>=1.26",
|
| 14 |
+
"pandas>=2.1",
|
| 15 |
+
"pyarrow>=15",
|
| 16 |
+
"scipy>=1.11",
|
| 17 |
+
"scikit-learn>=1.4",
|
| 18 |
+
"loguru>=0.7",
|
| 19 |
+
"huggingface-hub>=0.30",
|
| 20 |
+
]
|
| 21 |
+
|
| 22 |
+
[project.optional-dependencies]
|
| 23 |
+
# The Gradio app itself; not needed to validate or score a bundle locally.
|
| 24 |
+
space = ["gradio==5.50.0", "gradio-leaderboard==0.0.14", "pydantic>=2.9", "requests>=2.32"]
|
| 25 |
+
dev = ["pytest>=8", "ruff>=0.6", "mypy>=1.11", "pandas-stubs", "types-requests"]
|
| 26 |
+
|
| 27 |
+
[project.scripts]
|
| 28 |
+
plug-challenge = "plug_challenge.cli:main"
|
| 29 |
+
|
| 30 |
+
[tool.setuptools]
|
| 31 |
+
# Only the scoring library is packaged; the Space's own modules (app.py,
|
| 32 |
+
# config.py, ...) live at the repo root because this repo *is* the Space.
|
| 33 |
+
packages = ["plug_challenge"]
|
| 34 |
+
|
| 35 |
+
[tool.ruff]
|
| 36 |
+
line-length = 100
|
| 37 |
+
target-version = "py311"
|
| 38 |
+
|
| 39 |
+
[tool.ruff.lint]
|
| 40 |
+
select = ["E", "F", "I", "UP", "B", "D"]
|
| 41 |
+
ignore = ["D203", "D213", "D406", "D407"]
|
| 42 |
+
|
| 43 |
+
[tool.ruff.lint.per-file-ignores]
|
| 44 |
+
"tests/*" = ["D"]
|
| 45 |
+
"scripts/*" = ["D"]
|
| 46 |
+
|
| 47 |
+
[tool.ruff.lint.pydocstyle]
|
| 48 |
+
convention = "numpy"
|
| 49 |
+
|
| 50 |
+
[tool.mypy]
|
| 51 |
+
python_version = "3.12"
|
| 52 |
+
ignore_missing_imports = true
|
| 53 |
+
warn_unused_ignores = true
|
| 54 |
+
|
| 55 |
+
[tool.pytest.ini_options]
|
| 56 |
+
testpaths = ["tests"]
|
requirements.txt
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Pinned to the versions this Space was tested against: the full test suite, the
|
| 2 |
+
# app graph in all three phases, and a real eleven-benchmark scoring run.
|
| 3 |
+
# Bump deliberately, and re-run `pytest tests/` plus the smoke test in
|
| 4 |
+
# docs/SETUP.md afterwards.
|
| 5 |
+
gradio==5.50.0
|
| 6 |
+
gradio-leaderboard==0.0.14
|
| 7 |
+
loguru==0.7.3
|
| 8 |
+
pandas==2.3.3
|
| 9 |
+
pyarrow==25.0.1
|
| 10 |
+
numpy==2.5.3
|
| 11 |
+
scipy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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python
|
| 2 |
+
"""Build the challenge's public data and private labels from a local `plug` checkout.
|
| 3 |
+
|
| 4 |
+
Run this from a checkout of https://github.com/PrismScienceOrg/plug with its
|
| 5 |
+
benchmark data downloaded and its environment active (it needs `torch`, which is
|
| 6 |
+
why it is a script here rather than part of the Space's dependencies)::
|
| 7 |
+
|
| 8 |
+
PLUG_REPO=~/plug python scripts/build_challenge_data.py # all eleven
|
| 9 |
+
PLUG_REPO=~/plug python scripts/build_challenge_data.py megascale # or a few
|
| 10 |
+
|
| 11 |
+
For each benchmark it writes, under ``--out`` (default ``.challenge-data/``)::
|
| 12 |
+
|
| 13 |
+
public/<benchmark>/entities.parquet entity -> sequence + split, all splits
|
| 14 |
+
public/<benchmark>/sequences.fasta the same sequences as fasta
|
| 15 |
+
public/<benchmark>/train.parquet labelled train datapoints
|
| 16 |
+
public/<benchmark>/val.parquet labelled val datapoints
|
| 17 |
+
public/<benchmark>/test_manifest.parquet test datapoints, labels removed
|
| 18 |
+
private/ground_truth/<benchmark>.parquet test datapoints, labels kept
|
| 19 |
+
|
| 20 |
+
and refreshes the small committed entity list at ``data/<benchmark>/plug_entities.csv``.
|
| 21 |
+
|
| 22 |
+
Only ``private/`` may ever reach the private repo, and it must never be committed
|
| 23 |
+
to this Space's git history — ``.gitignore`` covers the output directory.
|
| 24 |
+
|
| 25 |
+
The `datapoint_id`
|
| 26 |
+
-----------------
|
| 27 |
+
Every row in every file carries a ``datapoint_id``: a truncated SHA-1 over the
|
| 28 |
+
benchmark name and the fields that identify the row, plus an occurrence counter
|
| 29 |
+
so that genuinely repeated measurements stay distinct. It is deterministic, so
|
| 30 |
+
re-running this script reproduces the same ids and an old submission still joins
|
| 31 |
+
against a rebuilt ground truth; and it is content-derived rather than positional,
|
| 32 |
+
so the ids do not shift when a benchmark's row order changes.
|
| 33 |
+
"""
|
| 34 |
+
|
| 35 |
+
import argparse
|
| 36 |
+
import hashlib
|
| 37 |
+
import os
|
| 38 |
+
import sys
|
| 39 |
+
from collections import Counter
|
| 40 |
+
from pathlib import Path
|
| 41 |
+
|
| 42 |
+
import pandas as pd
|
| 43 |
+
|
| 44 |
+
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
| 45 |
+
|
| 46 |
+
from plug_challenge.benchmarks import ( # noqa: E402
|
| 47 |
+
BENCHMARK_NAMES,
|
| 48 |
+
GO_ASPECTS,
|
| 49 |
+
ID_COLUMN,
|
| 50 |
+
SHS27K_MODES,
|
| 51 |
+
get,
|
| 52 |
+
)
|
| 53 |
+
|
| 54 |
+
SPLITS = ("train", "val", "test")
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
def seq_id(sequence: str) -> str:
|
| 58 |
+
"""Stable short id for a protein sequence (the key plug-baselines caches on).
|
| 59 |
+
|
| 60 |
+
Parameters
|
| 61 |
+
----------
|
| 62 |
+
sequence : str
|
| 63 |
+
The amino-acid sequence.
|
| 64 |
+
|
| 65 |
+
Returns
|
| 66 |
+
-------
|
| 67 |
+
str
|
| 68 |
+
First 12 hex characters of the sequence's SHA-1.
|
| 69 |
+
|
| 70 |
+
"""
|
| 71 |
+
return hashlib.sha1(sequence.encode()).hexdigest()[:12]
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
def datapoint_ids(frame: pd.DataFrame, benchmark: str, fields: list[str]) -> pd.Series:
|
| 75 |
+
"""Derive a deterministic ``datapoint_id`` per row.
|
| 76 |
+
|
| 77 |
+
Parameters
|
| 78 |
+
----------
|
| 79 |
+
frame : pd.DataFrame
|
| 80 |
+
The datapoint rows.
|
| 81 |
+
benchmark : str
|
| 82 |
+
Benchmark name, so ids never collide across benchmarks.
|
| 83 |
+
fields : list[str]
|
| 84 |
+
Columns that identify a row.
|
| 85 |
+
|
| 86 |
+
Returns
|
| 87 |
+
-------
|
| 88 |
+
pd.Series
|
| 89 |
+
One id per row. Rows agreeing on every field get distinct ids via an
|
| 90 |
+
occurrence counter, so a benchmark with repeated measurements of the same
|
| 91 |
+
(target, ligand) pair still has one id per measurement.
|
| 92 |
+
|
| 93 |
+
"""
|
| 94 |
+
seen: Counter[str] = Counter()
|
| 95 |
+
ids = []
|
| 96 |
+
for _, row in frame[fields].astype(str).iterrows():
|
| 97 |
+
base = "|".join([benchmark, *row.tolist()])
|
| 98 |
+
occurrence = seen[base]
|
| 99 |
+
seen[base] += 1
|
| 100 |
+
ids.append(hashlib.sha1(f"{base}|{occurrence}".encode()).hexdigest()[:16])
|
| 101 |
+
return pd.Series(ids, index=frame.index, dtype="string")
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
def _residue_rows(items: list[dict], entity_field: str, label_field: str, extra: list[str]):
|
| 105 |
+
"""Explode per-protein rows into one row per residue, for the per-residue benchmarks."""
|
| 106 |
+
for item in items:
|
| 107 |
+
sequence = item["sequence"]
|
| 108 |
+
sites = set(item.get(label_field) or [])
|
| 109 |
+
for position in range(1, len(sequence) + 1):
|
| 110 |
+
yield {
|
| 111 |
+
entity_field: item[entity_field],
|
| 112 |
+
"position": position,
|
| 113 |
+
"is_allosteric_site": int(position in sites),
|
| 114 |
+
"split": item["split"],
|
| 115 |
+
**{field: item.get(field, "") for field in extra},
|
| 116 |
+
}
|
| 117 |
+
|
| 118 |
+
|
| 119 |
+
def _rmsf_rows(items: list[dict]):
|
| 120 |
+
"""Explode ATLAS rows into one row per residue."""
|
| 121 |
+
for item in items:
|
| 122 |
+
for position, value in enumerate(item["rmsf"], start=1):
|
| 123 |
+
yield {
|
| 124 |
+
"pdb_chain": item["pdb_chain"],
|
| 125 |
+
"position": position,
|
| 126 |
+
"rmsf": float(value),
|
| 127 |
+
"split": item["split"],
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
def _go_rows(items: list[dict]):
|
| 132 |
+
"""Explode CAFA5 rows into one row per (protein, branch, term) annotation."""
|
| 133 |
+
for item in items:
|
| 134 |
+
for aspect in GO_ASPECTS:
|
| 135 |
+
for term in item.get(f"go_{aspect}") or []:
|
| 136 |
+
yield {
|
| 137 |
+
"protein_id": item["protein_id"],
|
| 138 |
+
"aspect": aspect,
|
| 139 |
+
"term": term,
|
| 140 |
+
"split": item["split"],
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
|
| 144 |
+
def extract(name: str, items: list[dict]) -> tuple[pd.DataFrame, pd.DataFrame]:
|
| 145 |
+
"""Turn one benchmark's plug rows into challenge datapoints and entities.
|
| 146 |
+
|
| 147 |
+
Parameters
|
| 148 |
+
----------
|
| 149 |
+
name : str
|
| 150 |
+
Benchmark name.
|
| 151 |
+
items : list[dict]
|
| 152 |
+
Every row of the benchmark, each already carrying its ``split``.
|
| 153 |
+
|
| 154 |
+
Returns
|
| 155 |
+
-------
|
| 156 |
+
tuple[pd.DataFrame, pd.DataFrame]
|
| 157 |
+
The datapoint frame (with ``datapoint_id`` and ``split``) and the entity
|
| 158 |
+
frame (entity, sequence, split, plus any entity-level extras). For
|
| 159 |
+
cafa5 the datapoint frame is the long-form annotation table; its test
|
| 160 |
+
manifest is derived from the entity frame instead.
|
| 161 |
+
|
| 162 |
+
"""
|
| 163 |
+
spec = get(name)
|
| 164 |
+
|
| 165 |
+
if name in ("megascale", "fireprot"):
|
| 166 |
+
data = pd.DataFrame(
|
| 167 |
+
[
|
| 168 |
+
{"pdb": i["pdb"], "mutation": i["mutation"], "ddg": i["ddg"], "split": i["split"]}
|
| 169 |
+
for i in items
|
| 170 |
+
]
|
| 171 |
+
)
|
| 172 |
+
entities = _entities_from(items, "pdb", "sequence")
|
| 173 |
+
id_fields = ["pdb", "mutation"]
|
| 174 |
+
|
| 175 |
+
elif name == "dms":
|
| 176 |
+
data = pd.DataFrame(
|
| 177 |
+
[
|
| 178 |
+
{
|
| 179 |
+
"dms_id": i["dms_id"],
|
| 180 |
+
"uniprot": i["uniprot"],
|
| 181 |
+
"assay": i["assay"],
|
| 182 |
+
"mutation": i["mutation"],
|
| 183 |
+
"score": i["score"],
|
| 184 |
+
"split": i["split"],
|
| 185 |
+
}
|
| 186 |
+
for i in items
|
| 187 |
+
]
|
| 188 |
+
)
|
| 189 |
+
entities = _entities_from(items, "dms_id", "sequence", extras=["uniprot", "assay"])
|
| 190 |
+
id_fields = ["dms_id", "mutation"]
|
| 191 |
+
|
| 192 |
+
elif name == "cafa5":
|
| 193 |
+
data = pd.DataFrame(list(_go_rows(items)))
|
| 194 |
+
entities = _entities_from(items, "protein_id", "sequence", extras=["organism"])
|
| 195 |
+
id_fields = ["protein_id"]
|
| 196 |
+
|
| 197 |
+
elif name in ("allobench", "passerrank"):
|
| 198 |
+
entity_field = "target_id" if name == "allobench" else "uniprot"
|
| 199 |
+
extra = ["uniprot", "pdb"] if name == "allobench" else ["pdb"]
|
| 200 |
+
data = pd.DataFrame(
|
| 201 |
+
list(_residue_rows(items, entity_field, "allosteric_site", extra))
|
| 202 |
+
)
|
| 203 |
+
entity_extras = ["gene", "organism", "pdb"] + (["uniprot"] if name == "allobench" else [])
|
| 204 |
+
entities = _entities_from(items, entity_field, "sequence", extras=entity_extras)
|
| 205 |
+
id_fields = [entity_field, "position"]
|
| 206 |
+
|
| 207 |
+
elif name in ("ppi", "shs27k"):
|
| 208 |
+
rows = []
|
| 209 |
+
for item in items:
|
| 210 |
+
row = {"id_a": item["id_a"], "id_b": item["id_b"], "split": item["split"]}
|
| 211 |
+
if name == "ppi":
|
| 212 |
+
row["label"] = int(item["label"])
|
| 213 |
+
else:
|
| 214 |
+
carried = set(item.get("types") or [])
|
| 215 |
+
row.update({mode: int(mode in carried) for mode in SHS27K_MODES})
|
| 216 |
+
rows.append(row)
|
| 217 |
+
data = pd.DataFrame(rows)
|
| 218 |
+
entities = _pair_entities(items)
|
| 219 |
+
id_fields = ["id_a", "id_b"]
|
| 220 |
+
|
| 221 |
+
elif name == "lp-pdbbind":
|
| 222 |
+
data = pd.DataFrame(
|
| 223 |
+
[
|
| 224 |
+
{"pdb": i["pdb"], "smiles": i["smiles"], "value": i["value"], "split": i["split"]}
|
| 225 |
+
for i in items
|
| 226 |
+
]
|
| 227 |
+
)
|
| 228 |
+
entities = _entities_from(items, "pdb", "sequence")
|
| 229 |
+
id_fields = ["pdb", "smiles"]
|
| 230 |
+
|
| 231 |
+
elif name == "bindingdb":
|
| 232 |
+
data = pd.DataFrame(
|
| 233 |
+
[
|
| 234 |
+
{
|
| 235 |
+
"target_key": seq_id(i["sequence"]),
|
| 236 |
+
"uniprot": i["uniprot"],
|
| 237 |
+
"target_name": i["target_name"],
|
| 238 |
+
"smiles": i["smiles"],
|
| 239 |
+
"measure": i["measure"],
|
| 240 |
+
"value": i["value"],
|
| 241 |
+
"split": i["split"],
|
| 242 |
+
}
|
| 243 |
+
for i in items
|
| 244 |
+
]
|
| 245 |
+
)
|
| 246 |
+
entities = pd.DataFrame(
|
| 247 |
+
[
|
| 248 |
+
{
|
| 249 |
+
"entity": seq_id(i["sequence"]),
|
| 250 |
+
"sequence": i["sequence"],
|
| 251 |
+
"split": i["split"],
|
| 252 |
+
"uniprot": i["uniprot"],
|
| 253 |
+
"target_name": i["target_name"],
|
| 254 |
+
}
|
| 255 |
+
for i in items
|
| 256 |
+
]
|
| 257 |
+
).drop_duplicates(subset=["entity"])
|
| 258 |
+
id_fields = ["target_key", "smiles", "measure"]
|
| 259 |
+
|
| 260 |
+
elif name == "atlas":
|
| 261 |
+
data = pd.DataFrame(list(_rmsf_rows(items)))
|
| 262 |
+
entities = _entities_from(items, "pdb_chain", "sequence")
|
| 263 |
+
id_fields = ["pdb_chain", "position"]
|
| 264 |
+
|
| 265 |
+
else: # pragma: no cover - guarded by BENCHMARK_NAMES
|
| 266 |
+
raise ValueError(f"No extractor for benchmark {name!r}")
|
| 267 |
+
|
| 268 |
+
data.insert(0, ID_COLUMN, datapoint_ids(data, name, id_fields))
|
| 269 |
+
# A long-form benchmark's manifest is built from its entities rather than from
|
| 270 |
+
# this frame (cafa5: one row per protein, not per annotation), so it is checked
|
| 271 |
+
# in build() instead.
|
| 272 |
+
if not spec.long_form:
|
| 273 |
+
_check_manifest_columns(name, spec, data)
|
| 274 |
+
return data, entities
|
| 275 |
+
|
| 276 |
+
|
| 277 |
+
def _check_manifest_columns(name: str, spec, frame: pd.DataFrame) -> None:
|
| 278 |
+
"""Fail loudly when an extract does not carry what the spec promises participants."""
|
| 279 |
+
missing = [c for c in spec.manifest_columns if c not in frame.columns]
|
| 280 |
+
if missing:
|
| 281 |
+
raise ValueError(f"{name}: manifest columns absent from the extract: {missing}")
|
| 282 |
+
|
| 283 |
+
|
| 284 |
+
def _entities_from(
|
| 285 |
+
items: list[dict], entity_field: str, sequence_field: str, extras: list[str] | None = None
|
| 286 |
+
) -> pd.DataFrame:
|
| 287 |
+
"""Build the entity -> sequence table for a single-protein benchmark."""
|
| 288 |
+
extras = extras or []
|
| 289 |
+
rows = [
|
| 290 |
+
{
|
| 291 |
+
"entity": item[entity_field],
|
| 292 |
+
"sequence": item[sequence_field],
|
| 293 |
+
"split": item["split"],
|
| 294 |
+
**{field: item.get(field, "") for field in extras},
|
| 295 |
+
}
|
| 296 |
+
for item in items
|
| 297 |
+
]
|
| 298 |
+
return pd.DataFrame(rows).drop_duplicates(subset=["entity"])
|
| 299 |
+
|
| 300 |
+
|
| 301 |
+
def _pair_entities(items: list[dict]) -> pd.DataFrame:
|
| 302 |
+
"""Build the entity -> sequence table for a pair benchmark (both partners)."""
|
| 303 |
+
rows = []
|
| 304 |
+
for item in items:
|
| 305 |
+
for side in ("a", "b"):
|
| 306 |
+
rows.append(
|
| 307 |
+
{
|
| 308 |
+
"entity": item[f"id_{side}"],
|
| 309 |
+
"sequence": item[f"sequence_{side}"],
|
| 310 |
+
"split": item["split"],
|
| 311 |
+
}
|
| 312 |
+
)
|
| 313 |
+
return pd.DataFrame(rows).drop_duplicates(subset=["entity"])
|
| 314 |
+
|
| 315 |
+
|
| 316 |
+
def write_fasta(path: Path, entities: pd.DataFrame) -> None:
|
| 317 |
+
"""Write an entity -> sequence table as a fasta file."""
|
| 318 |
+
with path.open("w") as handle:
|
| 319 |
+
for _, row in entities.iterrows():
|
| 320 |
+
handle.write(f">{row['entity']}\n{row['sequence']}\n")
|
| 321 |
+
|
| 322 |
+
|
| 323 |
+
def build(name: str, out: Path, repo_root: Path) -> dict[str, int]:
|
| 324 |
+
"""Build every artefact for one benchmark.
|
| 325 |
+
|
| 326 |
+
Parameters
|
| 327 |
+
----------
|
| 328 |
+
name : str
|
| 329 |
+
Benchmark name.
|
| 330 |
+
out : Path
|
| 331 |
+
Output directory; ``public/`` and ``private/`` are created beneath it.
|
| 332 |
+
repo_root : Path
|
| 333 |
+
This repository's root, for the committed entity list.
|
| 334 |
+
|
| 335 |
+
Returns
|
| 336 |
+
-------
|
| 337 |
+
dict[str, int]
|
| 338 |
+
Row counts per artefact, for the summary table.
|
| 339 |
+
|
| 340 |
+
"""
|
| 341 |
+
from plug.benchmarks import REGISTRY # imported here so --help works without torch
|
| 342 |
+
|
| 343 |
+
spec = get(name)
|
| 344 |
+
benchmark = REGISTRY[name](how="homology", split="all")
|
| 345 |
+
items = list(benchmark.items)
|
| 346 |
+
print(f"[{name}] loaded {len(items)} plug rows")
|
| 347 |
+
|
| 348 |
+
data, entities = extract(name, items)
|
| 349 |
+
public = out / "public" / name
|
| 350 |
+
private = out / "private" / "ground_truth"
|
| 351 |
+
public.mkdir(parents=True, exist_ok=True)
|
| 352 |
+
private.mkdir(parents=True, exist_ok=True)
|
| 353 |
+
|
| 354 |
+
entities.to_parquet(public / "entities.parquet", index=False)
|
| 355 |
+
write_fasta(public / "sequences.fasta", entities)
|
| 356 |
+
|
| 357 |
+
counts = {"entities": len(entities)}
|
| 358 |
+
label_columns = list(spec.truth_columns) or ["aspect", "term"]
|
| 359 |
+
|
| 360 |
+
for split in ("train", "val"):
|
| 361 |
+
subset = data[data["split"] == split].drop(columns=["split"])
|
| 362 |
+
subset.to_parquet(public / f"{split}.parquet", index=False)
|
| 363 |
+
counts[split] = len(subset)
|
| 364 |
+
|
| 365 |
+
test = data[data["split"] == "test"].drop(columns=["split"])
|
| 366 |
+
if spec.long_form:
|
| 367 |
+
# cafa5: the manifest is one row per test protein (what you predict for),
|
| 368 |
+
# while the ground truth is the long-form annotation table.
|
| 369 |
+
test_entities = entities[entities["split"] == "test"]
|
| 370 |
+
manifest = pd.DataFrame(
|
| 371 |
+
{
|
| 372 |
+
"protein_id": test_entities["entity"].to_numpy(),
|
| 373 |
+
"organism": test_entities.get("organism", pd.Series(dtype=str)).to_numpy(),
|
| 374 |
+
}
|
| 375 |
+
)
|
| 376 |
+
manifest.insert(0, ID_COLUMN, datapoint_ids(manifest, name, ["protein_id"]))
|
| 377 |
+
_check_manifest_columns(name, spec, manifest)
|
| 378 |
+
manifest.to_parquet(public / "test_manifest.parquet", index=False)
|
| 379 |
+
counts["test_manifest"] = len(manifest)
|
| 380 |
+
# Re-derive the annotation ids from protein_id so they match the manifest's.
|
| 381 |
+
ground_truth = test.drop(columns=[ID_COLUMN]).copy()
|
| 382 |
+
id_of = dict(zip(manifest["protein_id"], manifest[ID_COLUMN], strict=True))
|
| 383 |
+
ground_truth.insert(
|
| 384 |
+
0, ID_COLUMN, ground_truth["protein_id"].map(id_of).astype("string")
|
| 385 |
+
)
|
| 386 |
+
ground_truth = ground_truth[ground_truth[ID_COLUMN].notna()]
|
| 387 |
+
else:
|
| 388 |
+
manifest = test.drop(columns=label_columns, errors="ignore")
|
| 389 |
+
manifest.to_parquet(public / "test_manifest.parquet", index=False)
|
| 390 |
+
counts["test_manifest"] = len(manifest)
|
| 391 |
+
ground_truth = test
|
| 392 |
+
|
| 393 |
+
ground_truth.to_parquet(private / f"{name}.parquet", index=False)
|
| 394 |
+
counts["ground_truth"] = len(ground_truth)
|
| 395 |
+
|
| 396 |
+
copy_entity_list(name, repo_root)
|
| 397 |
+
|
| 398 |
+
print(
|
| 399 |
+
f"[{name}] entities {counts['entities']} train {counts['train']} "
|
| 400 |
+
f"val {counts['val']} test {counts['test_manifest']} "
|
| 401 |
+
f"ground truth {counts['ground_truth']}"
|
| 402 |
+
)
|
| 403 |
+
return counts
|
| 404 |
+
|
| 405 |
+
|
| 406 |
+
def copy_entity_list(name: str, repo_root: Path) -> None:
|
| 407 |
+
"""Copy plug's split file verbatim to ``data/<benchmark>/plug_entities.csv``.
|
| 408 |
+
|
| 409 |
+
A verbatim copy rather than a re-derivation, and for a specific reason: plug's
|
| 410 |
+
split file lists every entity the **solver placed**, while the entity table
|
| 411 |
+
built above lists only entities that still have a surviving datapoint. The two
|
| 412 |
+
differ wherever a datapoint can straddle — a PPI pair whose partners landed in
|
| 413 |
+
different splits is dropped, but both partners were still assigned. The
|
| 414 |
+
committed list is the record of the split itself, so it must be the solver's
|
| 415 |
+
answer, not a downstream view of it. The per-benchmark ``entities.parquet`` in
|
| 416 |
+
the public data repo is where the downstream view belongs.
|
| 417 |
+
|
| 418 |
+
The source path carries plug's thresholds in its filename, so it is resolved
|
| 419 |
+
through plug's own helper rather than hardcoded here — a split rebuilt at
|
| 420 |
+
different thresholds is then copied from the right file automatically.
|
| 421 |
+
|
| 422 |
+
Parameters
|
| 423 |
+
----------
|
| 424 |
+
name : str
|
| 425 |
+
Benchmark name.
|
| 426 |
+
repo_root : Path
|
| 427 |
+
This repository's root.
|
| 428 |
+
|
| 429 |
+
"""
|
| 430 |
+
from plug import splitting
|
| 431 |
+
from plug.benchmarks import REGISTRY
|
| 432 |
+
|
| 433 |
+
# split_file() -> graphs.tag() reads the class's `views`, so it needs the
|
| 434 |
+
# Benchmark subclass; passing the bare name raises.
|
| 435 |
+
source = splitting.split_file(REGISTRY[name])
|
| 436 |
+
if not source.exists():
|
| 437 |
+
print(f"[{name}] no plug split file at {source} — entity list not updated")
|
| 438 |
+
return
|
| 439 |
+
destination = repo_root / "data" / name
|
| 440 |
+
destination.mkdir(parents=True, exist_ok=True)
|
| 441 |
+
target = destination / "plug_entities.csv"
|
| 442 |
+
target.write_bytes(source.read_bytes())
|
| 443 |
+
print(f"[{name}] entity list <- {source.name}")
|
| 444 |
+
|
| 445 |
+
|
| 446 |
+
def main(argv: list[str] | None = None) -> int:
|
| 447 |
+
"""Build the challenge data for the requested benchmarks.
|
| 448 |
+
|
| 449 |
+
Parameters
|
| 450 |
+
----------
|
| 451 |
+
argv : list[str] | None
|
| 452 |
+
Argument list; ``None`` reads ``sys.argv``.
|
| 453 |
+
|
| 454 |
+
Returns
|
| 455 |
+
-------
|
| 456 |
+
int
|
| 457 |
+
Process exit status.
|
| 458 |
+
|
| 459 |
+
"""
|
| 460 |
+
parser = argparse.ArgumentParser(description=__doc__)
|
| 461 |
+
parser.add_argument(
|
| 462 |
+
"benchmarks",
|
| 463 |
+
nargs="*",
|
| 464 |
+
default=list(BENCHMARK_NAMES),
|
| 465 |
+
help=f"Benchmarks to build (default: all of {', '.join(BENCHMARK_NAMES)})",
|
| 466 |
+
)
|
| 467 |
+
parser.add_argument(
|
| 468 |
+
"--out",
|
| 469 |
+
type=Path,
|
| 470 |
+
default=Path(".challenge-data"),
|
| 471 |
+
help="Output directory (default: .challenge-data, which is gitignored)",
|
| 472 |
+
)
|
| 473 |
+
parser.add_argument(
|
| 474 |
+
"--plug-repo",
|
| 475 |
+
type=Path,
|
| 476 |
+
default=Path(os.environ.get("PLUG_REPO", Path.home() / "plug")),
|
| 477 |
+
help="Path to the plug checkout, added to sys.path (env: PLUG_REPO)",
|
| 478 |
+
)
|
| 479 |
+
args = parser.parse_args(argv)
|
| 480 |
+
|
| 481 |
+
src = args.plug_repo / "src"
|
| 482 |
+
if src.exists():
|
| 483 |
+
sys.path.insert(0, str(src))
|
| 484 |
+
|
| 485 |
+
repo_root = Path(__file__).resolve().parent.parent
|
| 486 |
+
summary = {}
|
| 487 |
+
for name in args.benchmarks:
|
| 488 |
+
if name not in BENCHMARK_NAMES:
|
| 489 |
+
print(f"skipping unknown benchmark {name!r}")
|
| 490 |
+
continue
|
| 491 |
+
try:
|
| 492 |
+
summary[name] = build(name, args.out, repo_root)
|
| 493 |
+
except Exception as exc: # keep going: one benchmark's missing data is not fatal
|
| 494 |
+
print(f"[{name}] FAILED: {type(exc).__name__}: {exc}")
|
| 495 |
+
|
| 496 |
+
print("\n== summary ==")
|
| 497 |
+
for name, counts in summary.items():
|
| 498 |
+
print(f"{name:12s} {counts}")
|
| 499 |
+
print(
|
| 500 |
+
f"\nPublic data: {args.out / 'public'}\nPrivate labels: {args.out / 'private'}\n"
|
| 501 |
+
"Next: upload each to its dataset repo — see docs/SETUP.md."
|
| 502 |
+
)
|
| 503 |
+
return 0 if summary else 1
|
| 504 |
+
|
| 505 |
+
|
| 506 |
+
if __name__ == "__main__":
|
| 507 |
+
sys.exit(main())
|
style.css
DELETED
|
@@ -1,28 +0,0 @@
|
|
| 1 |
-
body {
|
| 2 |
-
padding: 2rem;
|
| 3 |
-
font-family: -apple-system, BlinkMacSystemFont, "Arial", sans-serif;
|
| 4 |
-
}
|
| 5 |
-
|
| 6 |
-
h1 {
|
| 7 |
-
font-size: 16px;
|
| 8 |
-
margin-top: 0;
|
| 9 |
-
}
|
| 10 |
-
|
| 11 |
-
p {
|
| 12 |
-
color: rgb(107, 114, 128);
|
| 13 |
-
font-size: 15px;
|
| 14 |
-
margin-bottom: 10px;
|
| 15 |
-
margin-top: 5px;
|
| 16 |
-
}
|
| 17 |
-
|
| 18 |
-
.card {
|
| 19 |
-
max-width: 620px;
|
| 20 |
-
margin: 0 auto;
|
| 21 |
-
padding: 16px;
|
| 22 |
-
border: 1px solid lightgray;
|
| 23 |
-
border-radius: 16px;
|
| 24 |
-
}
|
| 25 |
-
|
| 26 |
-
.card p:last-child {
|
| 27 |
-
margin-bottom: 0;
|
| 28 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""The Submit tab: validate, score and record one submission bundle.
|
| 2 |
+
|
| 3 |
+
Because PLUG is not blinded, everything happens inside the request — the bundle
|
| 4 |
+
is validated, scored against the held-back labels, stored, and added to the
|
| 5 |
+
leaderboard before the participant's status box updates. There is no queue and
|
| 6 |
+
nothing to wait for, so the response can show the participant their own
|
| 7 |
+
{n} metrics and their PLUG Score immediately.
|
| 8 |
+
|
| 9 |
+
The order of operations matters. The bundle is validated *before* anything is
|
| 10 |
+
uploaded, so a malformed submission costs the participant nothing and does not
|
| 11 |
+
start their cooldown; the bundle and metadata are stored before the leaderboard
|
| 12 |
+
is touched, so a failure part-way through leaves a recoverable record rather
|
| 13 |
+
than a leaderboard row with no submission behind it.
|
| 14 |
+
"""
|
| 15 |
+
|
| 16 |
+
import re
|
| 17 |
+
from datetime import datetime, timedelta
|
| 18 |
+
from pathlib import Path
|
| 19 |
+
|
| 20 |
+
import gradio as gr
|
| 21 |
+
import pandas as pd
|
| 22 |
+
from loguru import logger
|
| 23 |
+
|
| 24 |
+
from config import (
|
| 25 |
+
BENCHMARK_COUNT,
|
| 26 |
+
BOOTSTRAP_SAMPLES,
|
| 27 |
+
BUNDLE_TREE_MD,
|
| 28 |
+
CURRENT_PHASE,
|
| 29 |
+
DATASET_DOWNLOAD_LINK,
|
| 30 |
+
HOURS_BETWEEN_SUBMISSIONS,
|
| 31 |
+
REQUIRE_COMPLETE_BUNDLE,
|
| 32 |
+
SUBMISSION_SCHEMAS_MD,
|
| 33 |
+
TUTORIAL_LINK,
|
| 34 |
+
)
|
| 35 |
+
from models import Submission
|
| 36 |
+
from plug_challenge import BENCHMARKS, aggregate, scoring, store
|
| 37 |
+
from plug_challenge.validation import validate_bundle
|
| 38 |
+
from utils import (
|
| 39 |
+
BANNED_USERNAMES,
|
| 40 |
+
safeify_username,
|
| 41 |
+
validate_hf_username,
|
| 42 |
+
validate_model_details,
|
| 43 |
+
)
|
| 44 |
+
|
| 45 |
+
EMAIL_RE = re.compile(r"^[^@\s]+@[^@\s]+\.[^@\s]+$")
|
| 46 |
+
|
| 47 |
+
_INTRO_MD = f"""New to the challenge? The [PLUG baselines]({TUTORIAL_LINK}) walk through
|
| 48 |
+
loading each benchmark and producing predictions, and the training/test data is on the
|
| 49 |
+
[challenge dataset page]({DATASET_DOWNLOAD_LINK}).
|
| 50 |
+
|
| 51 |
+
A submission is **one `.zip`** containing one file per benchmark
|
| 52 |
+
({BENCHMARK_COUNT} files{", all required" if REQUIRE_COMPLETE_BUNDLE else ""}):
|
| 53 |
+
|
| 54 |
+
{BUNDLE_TREE_MD}
|
| 55 |
+
|
| 56 |
+
Build the skeleton and check it before uploading:
|
| 57 |
+
|
| 58 |
+
```bash
|
| 59 |
+
pip install "plug-challenge @ git+https://huggingface.co/spaces/PrismScienceOrg/PLUG-challenge"
|
| 60 |
+
plug-challenge template ./my_submission # writes every file with the right ids
|
| 61 |
+
# ...fill in the prediction columns...
|
| 62 |
+
cd my_submission && zip ../plug_submission.zip *.csv && cd ..
|
| 63 |
+
plug-challenge validate plug_submission.zip # the same checks this Space runs
|
| 64 |
+
```
|
| 65 |
+
|
| 66 |
+
<details>
|
| 67 |
+
<summary><b>Per-file column reference</b></summary>
|
| 68 |
+
|
| 69 |
+
{SUBMISSION_SCHEMAS_MD}
|
| 70 |
+
|
| 71 |
+
</details>
|
| 72 |
+
"""
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
def render_submission_tab(phase: int) -> None:
|
| 76 |
+
"""Render the Submit tab for the current challenge phase.
|
| 77 |
+
|
| 78 |
+
Parameters
|
| 79 |
+
----------
|
| 80 |
+
phase : int
|
| 81 |
+
``config.CURRENT_PHASE``: 0 pre-challenge, 1 open, 2 closed.
|
| 82 |
+
|
| 83 |
+
"""
|
| 84 |
+
if phase == 0:
|
| 85 |
+
gr.Markdown(
|
| 86 |
+
"# Submission portal (coming soon)\n\n"
|
| 87 |
+
"The portal opens when the challenge begins. Please check back then."
|
| 88 |
+
)
|
| 89 |
+
return
|
| 90 |
+
if phase >= 2:
|
| 91 |
+
gr.Markdown(
|
| 92 |
+
"# Submission portal (closed)\n\n"
|
| 93 |
+
"Submissions are closed — thank you for taking part. The final standings are "
|
| 94 |
+
"on the **Leaderboard** tab."
|
| 95 |
+
)
|
| 96 |
+
return
|
| 97 |
+
|
| 98 |
+
gr.Markdown("# Submit your predictions")
|
| 99 |
+
gr.Markdown(_INTRO_MD)
|
| 100 |
+
|
| 101 |
+
with gr.Row():
|
| 102 |
+
with gr.Column(scale=1):
|
| 103 |
+
gr.Markdown("### Leaderboard identity")
|
| 104 |
+
username_input = gr.Textbox(
|
| 105 |
+
label="Hugging Face username *",
|
| 106 |
+
placeholder="your-hf-username",
|
| 107 |
+
info="Required. Used to track submissions and to rate-limit them.",
|
| 108 |
+
)
|
| 109 |
+
user_alias = gr.Textbox(
|
| 110 |
+
label="Alias (display name for the leaderboard; anonymous by default)",
|
| 111 |
+
placeholder="Leakage-Free Learners",
|
| 112 |
+
)
|
| 113 |
+
anon_checkbox = gr.Checkbox(
|
| 114 |
+
label="Submit anonymously (show the alias instead of my username)",
|
| 115 |
+
value=True,
|
| 116 |
+
)
|
| 117 |
+
proprietary_checkbox = gr.Checkbox(
|
| 118 |
+
label="I used proprietary (not publicly available) training data",
|
| 119 |
+
value=False,
|
| 120 |
+
info="Displayed publicly on the leaderboard.",
|
| 121 |
+
)
|
| 122 |
+
open_code_checkbox = gr.Checkbox(
|
| 123 |
+
label="My code is open-source and publicly available",
|
| 124 |
+
value=False,
|
| 125 |
+
info="Link it as your method report below.",
|
| 126 |
+
)
|
| 127 |
+
|
| 128 |
+
with gr.Column(scale=1):
|
| 129 |
+
gr.Markdown("### Contact & publication *(optional, private)*")
|
| 130 |
+
participant_name = gr.Textbox(label="Full name", placeholder="Jane Smith")
|
| 131 |
+
discord_username = gr.Textbox(label="Discord / contact handle")
|
| 132 |
+
email = gr.Textbox(label="Email", placeholder="jane@example.com")
|
| 133 |
+
affiliation = gr.Textbox(label="Affiliation", placeholder="University / company")
|
| 134 |
+
model_tag = gr.Textbox(
|
| 135 |
+
label="Method report link",
|
| 136 |
+
placeholder="https://...",
|
| 137 |
+
info="Shown on the leaderboard. Required if you ticked the open-source "
|
| 138 |
+
"box. Must start with 'https://' and be reachable.",
|
| 139 |
+
)
|
| 140 |
+
|
| 141 |
+
with gr.Column(scale=1):
|
| 142 |
+
gr.Markdown("### Bundle")
|
| 143 |
+
file_input = gr.File(label="plug_submission.zip *", file_types=[".zip"])
|
| 144 |
+
gr.Markdown(
|
| 145 |
+
f"One submission per account every **{HOURS_BETWEEN_SUBMISSIONS} hours**. "
|
| 146 |
+
"Only your latest submission is ranked."
|
| 147 |
+
)
|
| 148 |
+
submit_btn = gr.Button("Validate, score and submit", variant="primary", size="lg")
|
| 149 |
+
|
| 150 |
+
submit_msg = gr.Markdown(visible=False)
|
| 151 |
+
|
| 152 |
+
submit_btn.click(
|
| 153 |
+
fn=submit_bundle,
|
| 154 |
+
inputs=[
|
| 155 |
+
username_input,
|
| 156 |
+
user_alias,
|
| 157 |
+
anon_checkbox,
|
| 158 |
+
participant_name,
|
| 159 |
+
discord_username,
|
| 160 |
+
email,
|
| 161 |
+
affiliation,
|
| 162 |
+
model_tag,
|
| 163 |
+
proprietary_checkbox,
|
| 164 |
+
open_code_checkbox,
|
| 165 |
+
file_input,
|
| 166 |
+
],
|
| 167 |
+
outputs=[submit_msg],
|
| 168 |
+
)
|
| 169 |
+
|
| 170 |
+
|
| 171 |
+
def _error(message: str) -> dict:
|
| 172 |
+
"""Format a failure for the status box."""
|
| 173 |
+
return gr.update(value=f"### ❌ Submission not accepted\n\n{message}", visible=True)
|
| 174 |
+
|
| 175 |
+
|
| 176 |
+
def _format_cooldown(last_submission: datetime) -> str:
|
| 177 |
+
"""Explain how long is left before this account may submit again."""
|
| 178 |
+
next_allowed = last_submission + timedelta(hours=HOURS_BETWEEN_SUBMISSIONS)
|
| 179 |
+
remaining = max(0, int((next_allowed - store.now()).total_seconds()))
|
| 180 |
+
hours, rest = divmod(remaining, 3600)
|
| 181 |
+
minutes, seconds = divmod(rest, 60)
|
| 182 |
+
return (
|
| 183 |
+
f"You submitted on {last_submission.strftime('%Y-%m-%d %H:%M UTC')}. "
|
| 184 |
+
f"Please wait **{hours:02d}:{minutes:02d}:{seconds:02d}** before submitting again."
|
| 185 |
+
)
|
| 186 |
+
|
| 187 |
+
|
| 188 |
+
def _score_table_md(scores: dict[str, dict[str, float]]) -> str:
|
| 189 |
+
"""Render one submission's own scores as a markdown table."""
|
| 190 |
+
rows = ["| Benchmark | Metric | Score |", "| :--- | :--- | ---: |"]
|
| 191 |
+
for spec in BENCHMARKS:
|
| 192 |
+
if spec.name not in scores:
|
| 193 |
+
rows.append(f"| {spec.label} | {spec.primary.label} | *not scored* |")
|
| 194 |
+
continue
|
| 195 |
+
value = scores[spec.name].get(f"{spec.primary.key}_mean")
|
| 196 |
+
shown = "—" if value is None or pd.isna(value) else f"{value:.4f}"
|
| 197 |
+
rows.append(f"| {spec.label} | {spec.primary.label} | {shown} |")
|
| 198 |
+
return "\n".join(rows)
|
| 199 |
+
|
| 200 |
+
|
| 201 |
+
def submit_bundle(
|
| 202 |
+
username: str,
|
| 203 |
+
user_alias: str,
|
| 204 |
+
anonymous: bool,
|
| 205 |
+
participant_name: str,
|
| 206 |
+
discord_username: str,
|
| 207 |
+
email: str,
|
| 208 |
+
affiliation: str,
|
| 209 |
+
model_tag: str,
|
| 210 |
+
used_proprietary_data: bool,
|
| 211 |
+
open_source_code: bool,
|
| 212 |
+
file_input: str | None,
|
| 213 |
+
) -> dict:
|
| 214 |
+
"""Handle one submission from the Submit tab.
|
| 215 |
+
|
| 216 |
+
Parameters
|
| 217 |
+
----------
|
| 218 |
+
username : str
|
| 219 |
+
Hugging Face username. Checked against Hugging Face to confirm the
|
| 220 |
+
account exists — a typo check, not an identity proof.
|
| 221 |
+
user_alias : str
|
| 222 |
+
Display alias, required when submitting anonymously.
|
| 223 |
+
anonymous : bool
|
| 224 |
+
Show the alias instead of the username on the leaderboard.
|
| 225 |
+
participant_name : str
|
| 226 |
+
Real name (private).
|
| 227 |
+
discord_username : str
|
| 228 |
+
Contact handle (private).
|
| 229 |
+
email : str
|
| 230 |
+
Contact email (private).
|
| 231 |
+
affiliation : str
|
| 232 |
+
Institutional affiliation (private).
|
| 233 |
+
model_tag : str
|
| 234 |
+
Method report link; validated for reachability when
|
| 235 |
+
``open_source_code`` is set.
|
| 236 |
+
used_proprietary_data : bool
|
| 237 |
+
Whether non-public training data was used.
|
| 238 |
+
open_source_code : bool
|
| 239 |
+
Whether the method's code is public.
|
| 240 |
+
file_input : str | None
|
| 241 |
+
Path to the uploaded bundle.
|
| 242 |
+
|
| 243 |
+
Returns
|
| 244 |
+
-------
|
| 245 |
+
dict
|
| 246 |
+
A ``gr.update`` carrying the outcome: either the rejection reasons, or
|
| 247 |
+
the submission's own per-benchmark scores and PLUG Score.
|
| 248 |
+
|
| 249 |
+
"""
|
| 250 |
+
if CURRENT_PHASE != 1:
|
| 251 |
+
return _error("The submission portal is not open.")
|
| 252 |
+
|
| 253 |
+
handle = (username or "").strip()
|
| 254 |
+
if not handle:
|
| 255 |
+
return _error("A Hugging Face username is required.")
|
| 256 |
+
if not validate_hf_username(handle):
|
| 257 |
+
logger.warning("Unknown Hugging Face username: {!r}", handle)
|
| 258 |
+
return _error(f"Hugging Face account `{handle}` could not be found — check for typos.")
|
| 259 |
+
banned_reason = BANNED_USERNAMES.get(handle.lower())
|
| 260 |
+
if banned_reason:
|
| 261 |
+
logger.warning("Blocked submission from banned username {!r}", handle)
|
| 262 |
+
return _error(
|
| 263 |
+
f"Account `{handle}` is blocked. Reason: {banned_reason}. "
|
| 264 |
+
"Contact the organisers if you believe this is a mistake."
|
| 265 |
+
)
|
| 266 |
+
if anonymous and not (user_alias or "").strip():
|
| 267 |
+
return _error(
|
| 268 |
+
"An alias is required when submitting anonymously — either provide one or "
|
| 269 |
+
"untick *Submit anonymously*."
|
| 270 |
+
)
|
| 271 |
+
if email and email.strip() and not EMAIL_RE.match(email.strip()):
|
| 272 |
+
return _error("That does not look like a valid email address.")
|
| 273 |
+
|
| 274 |
+
if open_source_code:
|
| 275 |
+
model_status = validate_model_details(model_tag)
|
| 276 |
+
if model_status in ("Invalid link", "Not submitted"):
|
| 277 |
+
return _error(
|
| 278 |
+
"Could not open the method report link. Check the URL (it must start "
|
| 279 |
+
"with `https://`), or untick the open-source box."
|
| 280 |
+
)
|
| 281 |
+
else:
|
| 282 |
+
model_status = (model_tag or "").strip() or "Not submitted"
|
| 283 |
+
|
| 284 |
+
if file_input is None:
|
| 285 |
+
return _error("Please upload your submission bundle.")
|
| 286 |
+
bundle_path = Path(file_input)
|
| 287 |
+
|
| 288 |
+
if not store.configured():
|
| 289 |
+
logger.error("HF_TOKEN is not set on the Space — cannot accept submissions.")
|
| 290 |
+
return _error(
|
| 291 |
+
"Submission storage is not configured on this Space. Please report this to "
|
| 292 |
+
"the organisers."
|
| 293 |
+
)
|
| 294 |
+
|
| 295 |
+
safe_username = safeify_username(handle)
|
| 296 |
+
last_submission = store.last_submission_at(safe_username)
|
| 297 |
+
if (
|
| 298 |
+
last_submission is not None
|
| 299 |
+
and (store.now() - last_submission).total_seconds() < HOURS_BETWEEN_SUBMISSIONS * 3600
|
| 300 |
+
):
|
| 301 |
+
return _error(_format_cooldown(last_submission))
|
| 302 |
+
|
| 303 |
+
# --- validate before anything is stored ---
|
| 304 |
+
truth = store.available_ground_truth()
|
| 305 |
+
if not truth:
|
| 306 |
+
return _error(
|
| 307 |
+
"No ground truth is staged for this challenge yet, so nothing can be scored. "
|
| 308 |
+
"Please report this to the organisers."
|
| 309 |
+
)
|
| 310 |
+
result = validate_bundle(
|
| 311 |
+
bundle_path,
|
| 312 |
+
expected_ids=store.expected_ids(truth),
|
| 313 |
+
require_complete=REQUIRE_COMPLETE_BUNDLE,
|
| 314 |
+
)
|
| 315 |
+
if not result.ok:
|
| 316 |
+
return _error(
|
| 317 |
+
"Your bundle did not pass validation. Nothing was stored and your "
|
| 318 |
+
f"submission cooldown has not started.\n\n{result.report()}\n\n"
|
| 319 |
+
"Run `plug-challenge validate` locally to iterate without uploading."
|
| 320 |
+
)
|
| 321 |
+
|
| 322 |
+
# --- score ---
|
| 323 |
+
try:
|
| 324 |
+
scores = scoring.score_bundle(
|
| 325 |
+
result.frames, truth, BENCHMARKS, bootstrap_samples=BOOTSTRAP_SAMPLES
|
| 326 |
+
)
|
| 327 |
+
except Exception as exc:
|
| 328 |
+
logger.exception("Scoring failed for {}: {}", handle, exc)
|
| 329 |
+
return _error(
|
| 330 |
+
"Your bundle validated but scoring failed unexpectedly. Please report this "
|
| 331 |
+
"to the organisers — nothing was stored."
|
| 332 |
+
)
|
| 333 |
+
|
| 334 |
+
submission = Submission(
|
| 335 |
+
username=handle,
|
| 336 |
+
user_alias=(user_alias or "").strip(),
|
| 337 |
+
anonymous=anonymous,
|
| 338 |
+
participant_name=(participant_name or "").strip(),
|
| 339 |
+
discord_username=(discord_username or "").strip(),
|
| 340 |
+
email=(email or "").strip(),
|
| 341 |
+
affiliation=(affiliation or "").strip(),
|
| 342 |
+
model_report_link=model_status,
|
| 343 |
+
used_proprietary_data=used_proprietary_data,
|
| 344 |
+
open_source_code=open_source_code,
|
| 345 |
+
filename=bundle_path.name,
|
| 346 |
+
)
|
| 347 |
+
|
| 348 |
+
# --- store: bundle and metadata first, then the derived leaderboard row ---
|
| 349 |
+
try:
|
| 350 |
+
submission.bundle_path = store.upload_submission(
|
| 351 |
+
safe_username=submission.safe_username,
|
| 352 |
+
submission_id=submission.submission_id,
|
| 353 |
+
bundle_path=bundle_path,
|
| 354 |
+
metadata=submission.model_dump(),
|
| 355 |
+
)
|
| 356 |
+
entry = {
|
| 357 |
+
**submission.public_fields(),
|
| 358 |
+
"plug_score": aggregate.plug_score(scores),
|
| 359 |
+
**aggregate.flatten(scores),
|
| 360 |
+
}
|
| 361 |
+
store.save_scores(submission.safe_username, submission.submission_id, entry)
|
| 362 |
+
store.append_leaderboard_entry(entry)
|
| 363 |
+
except Exception as exc:
|
| 364 |
+
logger.exception("Storing submission {} failed: {}", submission.submission_id, exc)
|
| 365 |
+
return _error(
|
| 366 |
+
"Your bundle scored, but storing it failed, so it is not on the leaderboard. "
|
| 367 |
+
f"Please report this to the organisers with submission id "
|
| 368 |
+
f"`{submission.submission_id}`."
|
| 369 |
+
)
|
| 370 |
+
|
| 371 |
+
logger.info(
|
| 372 |
+
"Accepted submission {} from {} — PLUG Score {:.4f}",
|
| 373 |
+
submission.submission_id,
|
| 374 |
+
submission.display_name,
|
| 375 |
+
entry["plug_score"],
|
| 376 |
+
)
|
| 377 |
+
caveat = (
|
| 378 |
+
f"\n\n**Note:** {result.report()}\n" if result.warnings else ""
|
| 379 |
+
)
|
| 380 |
+
return gr.update(
|
| 381 |
+
value=(
|
| 382 |
+
f"### ✅ Submission accepted{caveat}\n\n"
|
| 383 |
+
f"Recorded for **{submission.display_name}** — it will appear on the "
|
| 384 |
+
f"leaderboard within a minute.\n\n"
|
| 385 |
+
f"**PLUG Score: {entry['plug_score']:.4f}**\n\n"
|
| 386 |
+
f"{_score_table_md(scores)}\n\n"
|
| 387 |
+
f"Submission id `{submission.submission_id}`. You may submit again in "
|
| 388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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Synthetic fixtures for the PLUG challenge tests.
|
| 2 |
+
|
| 3 |
+
Everything here is generated from a fixed seed — no real benchmark data, no real
|
| 4 |
+
labels — so the tests run anywhere and the fixtures can be regenerated freely.
|
| 5 |
+
The point is to exercise every *shape* of benchmark: one row per mutation, one
|
| 6 |
+
row per residue, one row per pair, seven columns per pair, and cafa5's long form.
|
| 7 |
+
"""
|
| 8 |
+
|
| 9 |
+
import zipfile
|
| 10 |
+
from pathlib import Path
|
| 11 |
+
|
| 12 |
+
import numpy as np
|
| 13 |
+
import pandas as pd
|
| 14 |
+
import pytest
|
| 15 |
+
|
| 16 |
+
from plug_challenge.benchmarks import BENCHMARKS, GO_ASPECTS, ID_COLUMN
|
| 17 |
+
|
| 18 |
+
N_DATAPOINTS = 40
|
| 19 |
+
N_GROUPS = 4
|
| 20 |
+
SEED = 0
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def _ids(benchmark: str, n: int) -> list[str]:
|
| 24 |
+
"""Deterministic fake datapoint ids."""
|
| 25 |
+
return [f"{benchmark}-{i:04d}" for i in range(n)]
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
def _groups(n: int) -> list[str]:
|
| 29 |
+
"""Round-robin group labels, so every grouped metric has several groups."""
|
| 30 |
+
return [f"g{i % N_GROUPS}" for i in range(n)]
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
def make_ground_truth(rng: np.random.Generator) -> dict[str, pd.DataFrame]:
|
| 34 |
+
"""Build a synthetic ground truth for all eleven benchmarks.
|
| 35 |
+
|
| 36 |
+
Parameters
|
| 37 |
+
----------
|
| 38 |
+
rng : np.random.Generator
|
| 39 |
+
Seeded generator.
|
| 40 |
+
|
| 41 |
+
Returns
|
| 42 |
+
-------
|
| 43 |
+
dict[str, pd.DataFrame]
|
| 44 |
+
Benchmark name -> ground truth frame with the columns the scorer needs.
|
| 45 |
+
|
| 46 |
+
"""
|
| 47 |
+
truth: dict[str, pd.DataFrame] = {}
|
| 48 |
+
for spec in BENCHMARKS:
|
| 49 |
+
ids = _ids(spec.name, N_DATAPOINTS)
|
| 50 |
+
if spec.long_form:
|
| 51 |
+
rows = []
|
| 52 |
+
for datapoint_id in ids:
|
| 53 |
+
for aspect in GO_ASPECTS:
|
| 54 |
+
for term in range(3):
|
| 55 |
+
rows.append(
|
| 56 |
+
{
|
| 57 |
+
ID_COLUMN: datapoint_id,
|
| 58 |
+
"protein_id": datapoint_id.replace(spec.name, "P"),
|
| 59 |
+
"aspect": aspect,
|
| 60 |
+
"term": f"GO:{aspect}{term:05d}",
|
| 61 |
+
}
|
| 62 |
+
)
|
| 63 |
+
truth[spec.name] = pd.DataFrame(rows)
|
| 64 |
+
continue
|
| 65 |
+
|
| 66 |
+
frame = pd.DataFrame({ID_COLUMN: ids})
|
| 67 |
+
for column in spec.manifest_columns:
|
| 68 |
+
if column == "position":
|
| 69 |
+
frame[column] = np.arange(1, N_DATAPOINTS + 1)
|
| 70 |
+
else:
|
| 71 |
+
frame[column] = _groups(N_DATAPOINTS)
|
| 72 |
+
# Grouped metrics read their own column; make sure it exists and varies.
|
| 73 |
+
for metric in spec.metrics:
|
| 74 |
+
if metric.grouped_by:
|
| 75 |
+
frame[metric.grouped_by] = _groups(N_DATAPOINTS)
|
| 76 |
+
for column in spec.truth_columns:
|
| 77 |
+
if spec.task in ("binary", "multilabel"):
|
| 78 |
+
frame[column] = rng.integers(0, 2, size=N_DATAPOINTS)
|
| 79 |
+
else:
|
| 80 |
+
frame[column] = rng.normal(size=N_DATAPOINTS)
|
| 81 |
+
truth[spec.name] = frame
|
| 82 |
+
return truth
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
def make_predictions(
|
| 86 |
+
truth: dict[str, pd.DataFrame], rng: np.random.Generator, noise: float = 0.5
|
| 87 |
+
) -> dict[str, pd.DataFrame]:
|
| 88 |
+
"""Build predictions correlated with a ground truth.
|
| 89 |
+
|
| 90 |
+
Parameters
|
| 91 |
+
----------
|
| 92 |
+
truth : dict[str, pd.DataFrame]
|
| 93 |
+
The ground truth to predict.
|
| 94 |
+
rng : np.random.Generator
|
| 95 |
+
Seeded generator.
|
| 96 |
+
noise : float
|
| 97 |
+
Standard deviation of the noise added to the signal. 0 gives a perfect
|
| 98 |
+
submission; a large value gives a near-random one.
|
| 99 |
+
|
| 100 |
+
Returns
|
| 101 |
+
-------
|
| 102 |
+
dict[str, pd.DataFrame]
|
| 103 |
+
Benchmark name -> a valid submission frame.
|
| 104 |
+
|
| 105 |
+
"""
|
| 106 |
+
frames: dict[str, pd.DataFrame] = {}
|
| 107 |
+
for spec in BENCHMARKS:
|
| 108 |
+
gt = truth[spec.name]
|
| 109 |
+
if spec.long_form:
|
| 110 |
+
# Predict every true annotation plus one false positive per protein.
|
| 111 |
+
rows = []
|
| 112 |
+
for datapoint_id, group in gt.groupby(ID_COLUMN):
|
| 113 |
+
for _, row in group.iterrows():
|
| 114 |
+
rows.append(
|
| 115 |
+
{
|
| 116 |
+
ID_COLUMN: datapoint_id,
|
| 117 |
+
"aspect": row["aspect"],
|
| 118 |
+
"term": row["term"],
|
| 119 |
+
"score": float(rng.uniform(0.6, 1.0)),
|
| 120 |
+
}
|
| 121 |
+
)
|
| 122 |
+
rows.append(
|
| 123 |
+
{
|
| 124 |
+
ID_COLUMN: datapoint_id,
|
| 125 |
+
"aspect": "bp",
|
| 126 |
+
"term": "GO:decoy",
|
| 127 |
+
"score": float(rng.uniform(0.0, 0.3)),
|
| 128 |
+
}
|
| 129 |
+
)
|
| 130 |
+
frames[spec.name] = pd.DataFrame(rows)
|
| 131 |
+
continue
|
| 132 |
+
|
| 133 |
+
frame = pd.DataFrame({ID_COLUMN: gt[ID_COLUMN]})
|
| 134 |
+
for truth_column, pred_column in zip(
|
| 135 |
+
spec.truth_columns, spec.pred_columns, strict=True
|
| 136 |
+
):
|
| 137 |
+
signal = gt[truth_column].to_numpy(dtype=float)
|
| 138 |
+
values = signal + rng.normal(scale=noise, size=signal.size)
|
| 139 |
+
if spec.score_range is not None:
|
| 140 |
+
low, high = spec.score_range
|
| 141 |
+
values = np.clip(values, low, high)
|
| 142 |
+
frame[pred_column] = values
|
| 143 |
+
frames[spec.name] = frame
|
| 144 |
+
return frames
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
def write_bundle(frames: dict[str, pd.DataFrame], path: Path) -> Path:
|
| 148 |
+
"""Zip per-benchmark frames into a submission bundle.
|
| 149 |
+
|
| 150 |
+
Parameters
|
| 151 |
+
----------
|
| 152 |
+
frames : dict[str, pd.DataFrame]
|
| 153 |
+
Benchmark name -> submission frame.
|
| 154 |
+
path : Path
|
| 155 |
+
Destination ``.zip``.
|
| 156 |
+
|
| 157 |
+
Returns
|
| 158 |
+
-------
|
| 159 |
+
Path
|
| 160 |
+
``path``, for chaining.
|
| 161 |
+
|
| 162 |
+
"""
|
| 163 |
+
with zipfile.ZipFile(path, "w") as archive:
|
| 164 |
+
for name, frame in frames.items():
|
| 165 |
+
archive.writestr(f"{name}.csv", frame.to_csv(index=False))
|
| 166 |
+
return path
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
@pytest.fixture
|
| 170 |
+
def rng() -> np.random.Generator:
|
| 171 |
+
"""A seeded generator, so every test run sees the same data."""
|
| 172 |
+
return np.random.default_rng(SEED)
|
| 173 |
+
|
| 174 |
+
|
| 175 |
+
@pytest.fixture
|
| 176 |
+
def truth(rng: np.random.Generator) -> dict[str, pd.DataFrame]:
|
| 177 |
+
"""Synthetic ground truth for all eleven benchmarks."""
|
| 178 |
+
return make_ground_truth(rng)
|
| 179 |
+
|
| 180 |
+
|
| 181 |
+
@pytest.fixture
|
| 182 |
+
def expected_ids(truth: dict[str, pd.DataFrame]) -> dict[str, set[str]]:
|
| 183 |
+
"""The test id sets a submission must cover."""
|
| 184 |
+
return {name: set(frame[ID_COLUMN].astype(str)) for name, frame in truth.items()}
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
@pytest.fixture
|
| 188 |
+
def predictions(truth: dict[str, pd.DataFrame]) -> dict[str, pd.DataFrame]:
|
| 189 |
+
"""A valid, informative submission for the synthetic ground truth."""
|
| 190 |
+
return make_predictions(truth, np.random.default_rng(SEED + 1))
|
| 191 |
+
|
| 192 |
+
|
| 193 |
+
@pytest.fixture
|
| 194 |
+
def bundle(predictions: dict[str, pd.DataFrame], tmp_path: Path) -> Path:
|
| 195 |
+
"""A valid submission bundle on disk."""
|
| 196 |
+
return write_bundle(predictions, tmp_path / "plug_submission.zip")
|
tests/test_aggregate.py
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Tests for the PLUG Score and the leaderboard build."""
|
| 2 |
+
|
| 3 |
+
import numpy as np
|
| 4 |
+
import pytest
|
| 5 |
+
|
| 6 |
+
from plug_challenge import aggregate, scoring
|
| 7 |
+
from plug_challenge.benchmarks import BENCHMARKS, get
|
| 8 |
+
|
| 9 |
+
from .conftest import make_predictions
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
def test_normalise_puts_chance_at_a_half():
|
| 13 |
+
assert aggregate.normalise(0.0, (-1.0, 1.0)) == pytest.approx(0.5) # Spearman 0
|
| 14 |
+
assert aggregate.normalise(0.5, (0.0, 1.0)) == pytest.approx(0.5) # AUROC 0.5
|
| 15 |
+
assert aggregate.normalise(1.0, (-1.0, 1.0)) == pytest.approx(1.0)
|
| 16 |
+
assert aggregate.normalise(-1.0, (-1.0, 1.0)) == pytest.approx(0.0)
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
def test_normalise_clips_and_passes_nan_through():
|
| 20 |
+
assert aggregate.normalise(5.0, (0.0, 1.0)) == pytest.approx(1.0)
|
| 21 |
+
assert np.isnan(aggregate.normalise(float("nan"), (0.0, 1.0)))
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def test_plug_score_of_a_perfect_submission_is_one(truth):
|
| 25 |
+
perfect = make_predictions(truth, np.random.default_rng(0), noise=0.0)
|
| 26 |
+
scores = scoring.score_bundle(perfect, truth, BENCHMARKS)
|
| 27 |
+
assert aggregate.plug_score(scores) == pytest.approx(1.0)
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
def test_plug_score_ignores_absent_benchmarks(predictions, truth):
|
| 31 |
+
full = scoring.score_bundle(predictions, truth, BENCHMARKS)
|
| 32 |
+
partial = {name: value for name, value in full.items() if name != "atlas"}
|
| 33 |
+
# Dropping a benchmark changes the mean but never makes it undefined, and the
|
| 34 |
+
# count of what was covered is reported separately on the leaderboard.
|
| 35 |
+
assert np.isfinite(aggregate.plug_score(partial))
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
def test_plug_score_is_undefined_with_nothing_to_score():
|
| 39 |
+
assert np.isnan(aggregate.plug_score({}))
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
def test_flatten_and_column_agree_on_naming(predictions, truth):
|
| 43 |
+
scores = scoring.score_bundle(predictions, truth, BENCHMARKS)
|
| 44 |
+
flat = aggregate.flatten(scores)
|
| 45 |
+
for spec in BENCHMARKS:
|
| 46 |
+
assert aggregate.column(spec.name, spec.primary) in flat
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
def _entry(username: str, submitted_at: str, plug_score: float, **metrics) -> dict:
|
| 50 |
+
return {
|
| 51 |
+
"username": username,
|
| 52 |
+
"submitted_at": submitted_at,
|
| 53 |
+
"plug_score": plug_score,
|
| 54 |
+
"used_proprietary_data": False,
|
| 55 |
+
"open_source_code": True,
|
| 56 |
+
"model_report_link": "https://example.org",
|
| 57 |
+
**metrics,
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
def test_leaderboard_is_ranked_by_plug_score():
|
| 62 |
+
spearman = aggregate.column("megascale", get("megascale").primary)
|
| 63 |
+
board = aggregate.build_leaderboard(
|
| 64 |
+
[
|
| 65 |
+
_entry("b", "2026-01-01T00:00:00Z", 0.4, **{spearman: 0.1}),
|
| 66 |
+
_entry("a", "2026-01-01T00:00:00Z", 0.9, **{spearman: 0.8}),
|
| 67 |
+
_entry("c", "2026-01-01T00:00:00Z", 0.6, **{spearman: 0.5}),
|
| 68 |
+
]
|
| 69 |
+
)
|
| 70 |
+
assert list(board["username"]) == ["a", "c", "b"]
|
| 71 |
+
assert list(board["rank"]) == [1, 2, 3]
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
def test_only_the_latest_submission_per_user_is_ranked():
|
| 75 |
+
board = aggregate.build_leaderboard(
|
| 76 |
+
[
|
| 77 |
+
_entry("a", "2026-01-01T00:00:00Z", 0.9),
|
| 78 |
+
_entry("a", "2026-02-01T00:00:00Z", 0.3),
|
| 79 |
+
]
|
| 80 |
+
)
|
| 81 |
+
assert len(board) == 1
|
| 82 |
+
assert board.loc[0, "plug_score"] == pytest.approx(0.3)
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
def test_per_benchmark_rank_and_mean_rank_are_added():
|
| 86 |
+
mega = aggregate.column("megascale", get("megascale").primary)
|
| 87 |
+
ppi = aggregate.column("ppi", get("ppi").primary)
|
| 88 |
+
board = aggregate.build_leaderboard(
|
| 89 |
+
[
|
| 90 |
+
_entry("a", "2026-01-01T00:00:00Z", 0.7, **{mega: 0.9, ppi: 0.5}),
|
| 91 |
+
_entry("b", "2026-01-01T00:00:00Z", 0.6, **{mega: 0.2, ppi: 0.9}),
|
| 92 |
+
]
|
| 93 |
+
)
|
| 94 |
+
by_user = board.set_index("username")
|
| 95 |
+
assert by_user.loc["a", "megascale__rank"] == 1
|
| 96 |
+
assert by_user.loc["b", "ppi__rank"] == 1
|
| 97 |
+
# Each is first on one benchmark and second on the other.
|
| 98 |
+
assert by_user.loc["a", "mean_rank"] == pytest.approx(1.5)
|
| 99 |
+
assert by_user.loc["b", "mean_rank"] == pytest.approx(1.5)
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
def test_benchmarks_scored_counts_only_finite_metrics():
|
| 103 |
+
mega = aggregate.column("megascale", get("megascale").primary)
|
| 104 |
+
ppi = aggregate.column("ppi", get("ppi").primary)
|
| 105 |
+
board = aggregate.build_leaderboard(
|
| 106 |
+
[
|
| 107 |
+
_entry("a", "2026-01-01T00:00:00Z", 0.7, **{mega: 0.9, ppi: 0.5}),
|
| 108 |
+
_entry("b", "2026-01-01T00:00:00Z", 0.6, **{mega: 0.2, ppi: float("nan")}),
|
| 109 |
+
]
|
| 110 |
+
)
|
| 111 |
+
by_user = board.set_index("username")
|
| 112 |
+
assert by_user.loc["a", "benchmarks_scored"] == 2
|
| 113 |
+
assert by_user.loc["b", "benchmarks_scored"] == 1
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
def test_empty_leaderboard_has_the_expected_columns():
|
| 117 |
+
board = aggregate.build_leaderboard([])
|
| 118 |
+
assert board.empty
|
| 119 |
+
assert "plug_score" in board.columns
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
def test_a_full_submission_round_trips_into_a_leaderboard_row(predictions, truth):
|
| 123 |
+
"""The end-to-end shape: score a bundle, flatten it, rank it."""
|
| 124 |
+
scores = scoring.score_bundle(predictions, truth, BENCHMARKS)
|
| 125 |
+
entry = {
|
| 126 |
+
"username": "someone",
|
| 127 |
+
"submitted_at": "2026-05-01T12:00:00Z",
|
| 128 |
+
"plug_score": aggregate.plug_score(scores),
|
| 129 |
+
"used_proprietary_data": False,
|
| 130 |
+
"open_source_code": False,
|
| 131 |
+
"model_report_link": "Not submitted",
|
| 132 |
+
**aggregate.flatten(scores),
|
| 133 |
+
}
|
| 134 |
+
board = aggregate.build_leaderboard([entry])
|
| 135 |
+
assert len(board) == 1
|
| 136 |
+
assert board.loc[0, "benchmarks_scored"] == len(BENCHMARKS)
|
| 137 |
+
assert 0.0 <= board.loc[0, "plug_score"] <= 1.0
|
| 138 |
+
for spec in BENCHMARKS:
|
| 139 |
+
assert f"{spec.name}__rank" in board.columns
|
tests/test_leaderboard_views.py
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Tests for the Space's leaderboard views.
|
| 2 |
+
|
| 3 |
+
These cover the last hop — stored entries to the table a visitor sees — by
|
| 4 |
+
patching the store's read so nothing touches the Hub.
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
import numpy as np
|
| 8 |
+
import pandas as pd
|
| 9 |
+
import pytest
|
| 10 |
+
|
| 11 |
+
import leaderboards
|
| 12 |
+
from plug_challenge import aggregate, scoring, store
|
| 13 |
+
from plug_challenge.benchmarks import BENCHMARKS, get
|
| 14 |
+
|
| 15 |
+
from .conftest import make_predictions
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
@pytest.fixture
|
| 19 |
+
def stored_entries(truth):
|
| 20 |
+
"""Two scored submissions, as they would be stored: strong and weak."""
|
| 21 |
+
entries = []
|
| 22 |
+
for username, noise, when in (
|
| 23 |
+
("strong-lab", 0.1, "2026-05-01T09:00:00Z"),
|
| 24 |
+
("weak-lab", 6.0, "2026-05-02T09:00:00Z"),
|
| 25 |
+
):
|
| 26 |
+
scores = scoring.score_bundle(
|
| 27 |
+
make_predictions(truth, np.random.default_rng(2), noise=noise), truth, BENCHMARKS
|
| 28 |
+
)
|
| 29 |
+
entries.append(
|
| 30 |
+
{
|
| 31 |
+
"submission_id": f"id-{username}",
|
| 32 |
+
"submitted_at": when,
|
| 33 |
+
"username": username,
|
| 34 |
+
"safe_username": username,
|
| 35 |
+
"anonymous": False,
|
| 36 |
+
"model_report_link": "https://example.org/report",
|
| 37 |
+
"used_proprietary_data": username == "weak-lab",
|
| 38 |
+
"open_source_code": True,
|
| 39 |
+
"plug_score": aggregate.plug_score(scores),
|
| 40 |
+
**aggregate.flatten(scores),
|
| 41 |
+
}
|
| 42 |
+
)
|
| 43 |
+
return pd.DataFrame(entries)
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
@pytest.fixture(autouse=True)
|
| 47 |
+
def _patch_store(monkeypatch, stored_entries):
|
| 48 |
+
monkeypatch.setattr(store, "read_leaderboard", lambda use_cache=True: stored_entries.copy())
|
| 49 |
+
monkeypatch.setattr(
|
| 50 |
+
leaderboards.store, "read_leaderboard", lambda use_cache=True: stored_entries.copy()
|
| 51 |
+
)
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
def test_overall_board_lists_every_benchmark_and_ranks_correctly():
|
| 55 |
+
board = leaderboards.load_overall()
|
| 56 |
+
assert list(board["Rank"]) == [1, 2]
|
| 57 |
+
assert "strong-lab" in board.loc[0, "Entrant"]
|
| 58 |
+
for spec in BENCHMARKS:
|
| 59 |
+
assert spec.label in board.columns
|
| 60 |
+
assert board.loc[0, "Benchmarks"] == len(BENCHMARKS)
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
def test_overall_board_renders_links_and_flags():
|
| 64 |
+
board = leaderboards.load_overall()
|
| 65 |
+
assert board.loc[0, "Entrant"].startswith("<a ")
|
| 66 |
+
assert board.loc[0, "Method Report"].startswith("<a ")
|
| 67 |
+
assert set(board["Proprietary Data"]) <= {"Yes", "No"}
|
| 68 |
+
assert board.loc[0, "Proprietary Data"] == "No"
|
| 69 |
+
assert board.loc[1, "Proprietary Data"] == "Yes"
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
def test_private_columns_never_reach_a_board():
|
| 73 |
+
for frame in [leaderboards.load_overall(), leaderboards.load_benchmark(get("ppi"))]:
|
| 74 |
+
private = ("safe_username", "anonymous", "submission_id", "email", "participant_name")
|
| 75 |
+
for hidden in private:
|
| 76 |
+
assert hidden not in frame.columns
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
def test_download_view_is_plain_text_with_full_precision():
|
| 80 |
+
board = leaderboards.load_overall(for_download=True)
|
| 81 |
+
assert "<a " not in board.loc[0, "Entrant"]
|
| 82 |
+
assert board.loc[0, "Method Report"] == "https://example.org/report"
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
def test_benchmark_board_shows_that_benchmarks_metrics():
|
| 86 |
+
spec = get("dms")
|
| 87 |
+
board = leaderboards.load_benchmark(spec)
|
| 88 |
+
for metric in spec.metrics:
|
| 89 |
+
assert metric.label in board.columns
|
| 90 |
+
assert list(board["Rank"]) == [1, 2]
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
def test_benchmark_board_reranks_by_its_own_metric():
|
| 94 |
+
spec = get("megascale")
|
| 95 |
+
board = leaderboards.load_benchmark(spec)
|
| 96 |
+
values = board[spec.primary.label].to_numpy(dtype=float)
|
| 97 |
+
assert values[0] >= values[1]
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
def test_benchmark_board_download_includes_the_bootstrap_spread():
|
| 101 |
+
spec = get("megascale")
|
| 102 |
+
board = leaderboards.load_benchmark(spec, for_download=True)
|
| 103 |
+
assert f"{spec.primary.label} std" in board.columns
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
def test_benchmark_board_drops_entrants_with_no_score(stored_entries, monkeypatch):
|
| 107 |
+
spec = get("atlas")
|
| 108 |
+
without = stored_entries.copy()
|
| 109 |
+
without.loc[1, aggregate.column(spec.name, spec.primary)] = np.nan
|
| 110 |
+
monkeypatch.setattr(leaderboards.store, "read_leaderboard", lambda use_cache=True: without)
|
| 111 |
+
board = leaderboards.load_benchmark(spec)
|
| 112 |
+
assert len(board) == 1
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
def test_boards_are_empty_not_broken_before_the_first_submission(monkeypatch):
|
| 116 |
+
monkeypatch.setattr(
|
| 117 |
+
leaderboards.store, "read_leaderboard", lambda use_cache=True: pd.DataFrame()
|
| 118 |
+
)
|
| 119 |
+
overall = leaderboards.load_overall()
|
| 120 |
+
assert overall.empty
|
| 121 |
+
assert "PLUG Score" in overall.columns
|
| 122 |
+
for spec in BENCHMARKS:
|
| 123 |
+
board = leaderboards.load_benchmark(spec)
|
| 124 |
+
assert board.empty
|
| 125 |
+
assert spec.primary.label in board.columns
|
tests/test_metrics.py
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Tests for the bare metric functions."""
|
| 2 |
+
|
| 3 |
+
import numpy as np
|
| 4 |
+
import pytest
|
| 5 |
+
|
| 6 |
+
from plug_challenge import metrics
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
def test_spearman_perfect_and_inverted():
|
| 10 |
+
y = np.arange(20.0)
|
| 11 |
+
assert metrics.spearman(y, y) == pytest.approx(1.0)
|
| 12 |
+
assert metrics.spearman(y, -y) == pytest.approx(-1.0)
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def test_spearman_undefined_on_constant_input():
|
| 16 |
+
y = np.arange(10.0)
|
| 17 |
+
assert not np.isfinite(metrics.spearman(y, np.ones(10)))
|
| 18 |
+
assert not np.isfinite(metrics.spearman(y[:1], y[:1]))
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def test_spearman_ignores_nan_pairs():
|
| 22 |
+
y = np.array([1.0, 2.0, 3.0, np.nan])
|
| 23 |
+
p = np.array([1.0, 2.0, 3.0, 99.0])
|
| 24 |
+
assert metrics.spearman(y, p) == pytest.approx(1.0)
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
def test_auroc_and_single_class():
|
| 28 |
+
y = np.array([0, 0, 1, 1])
|
| 29 |
+
assert metrics.auroc(y, np.array([0.1, 0.2, 0.8, 0.9])) == pytest.approx(1.0)
|
| 30 |
+
assert not np.isfinite(metrics.auroc(np.ones(4), np.array([0.1, 0.2, 0.8, 0.9])))
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
def test_macro_auroc_skips_single_class_columns():
|
| 34 |
+
y = np.array([[0, 1], [1, 1], [0, 1], [1, 1]])
|
| 35 |
+
scores = np.array([[0.1, 0.5], [0.9, 0.5], [0.2, 0.5], [0.8, 0.5]])
|
| 36 |
+
# Column 0 is perfectly ranked; column 1 is all-positive and skipped.
|
| 37 |
+
assert metrics.macro_auroc(y, scores) == pytest.approx(1.0)
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
def test_grouped_spearman_averages_groups_not_rows():
|
| 41 |
+
# Group "a" is perfectly ranked, group "b" is perfectly inverted; each group
|
| 42 |
+
# counts once, so the mean is 0 despite "b" having more rows.
|
| 43 |
+
y = np.array([1.0, 2.0, 3.0, 1.0, 2.0, 3.0, 4.0])
|
| 44 |
+
p = np.array([1.0, 2.0, 3.0, 4.0, 3.0, 2.0, 1.0])
|
| 45 |
+
groups = np.array(["a", "a", "a", "b", "b", "b", "b"])
|
| 46 |
+
assert metrics.grouped_spearman(y, p, groups) == pytest.approx(0.0)
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
def test_grouped_auroc_skips_single_class_groups():
|
| 50 |
+
y = np.array([0, 1, 1, 1])
|
| 51 |
+
p = np.array([0.1, 0.9, 0.5, 0.5])
|
| 52 |
+
groups = np.array(["a", "a", "b", "b"])
|
| 53 |
+
assert metrics.grouped_auroc(y, p, groups) == pytest.approx(1.0)
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
def test_fmax_perfect_prediction():
|
| 57 |
+
y = np.array([[1, 1, 0], [0, 1, 1]], dtype=bool)
|
| 58 |
+
scores = np.where(y, 1.0, 0.0)
|
| 59 |
+
assert metrics.fmax(y, scores)["fmax"] == pytest.approx(1.0)
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
def test_fmax_drops_unannotated_targets():
|
| 63 |
+
y = np.array([[1, 0], [0, 0]], dtype=bool)
|
| 64 |
+
scores = np.array([[1.0, 0.0], [1.0, 1.0]])
|
| 65 |
+
result = metrics.fmax(y, scores)
|
| 66 |
+
assert result["targets"] == 1
|
| 67 |
+
assert result["fmax"] == pytest.approx(1.0)
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
def test_fmax_long_matches_dense_fmax():
|
| 71 |
+
"""The production long-form scorer must agree with the dense port."""
|
| 72 |
+
rng = np.random.default_rng(7)
|
| 73 |
+
n_targets, n_terms = 12, 9
|
| 74 |
+
y = rng.random((n_targets, n_terms)) < 0.3
|
| 75 |
+
scores = np.round(rng.random((n_targets, n_terms)), 2)
|
| 76 |
+
|
| 77 |
+
dense = metrics.fmax(y, scores)
|
| 78 |
+
|
| 79 |
+
target_index, flat_scores, is_true = [], [], []
|
| 80 |
+
for target in range(n_targets):
|
| 81 |
+
for term in range(n_terms):
|
| 82 |
+
target_index.append(target)
|
| 83 |
+
flat_scores.append(scores[target, term])
|
| 84 |
+
is_true.append(y[target, term])
|
| 85 |
+
long = metrics.fmax_long(
|
| 86 |
+
target_index=np.array(target_index),
|
| 87 |
+
scores=np.array(flat_scores),
|
| 88 |
+
is_true=np.array(is_true),
|
| 89 |
+
true_per_target=y.sum(axis=1),
|
| 90 |
+
)
|
| 91 |
+
assert long["fmax"] == pytest.approx(dense["fmax"])
|
| 92 |
+
assert long["targets"] == dense["targets"]
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
def test_fmax_long_only_counts_predicted_rows():
|
| 96 |
+
"""A term left out of the submission costs recall but not precision."""
|
| 97 |
+
# Two targets, two annotations each; only the first annotation is predicted.
|
| 98 |
+
long = metrics.fmax_long(
|
| 99 |
+
target_index=np.array([0, 1]),
|
| 100 |
+
scores=np.array([1.0, 1.0]),
|
| 101 |
+
is_true=np.array([True, True]),
|
| 102 |
+
true_per_target=np.array([2.0, 2.0]),
|
| 103 |
+
)
|
| 104 |
+
assert long["precision"] == pytest.approx(1.0)
|
| 105 |
+
assert long["recall"] == pytest.approx(0.5)
|
| 106 |
+
assert long["fmax"] == pytest.approx(2 / 3)
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
def test_bootstrap_zero_samples_is_the_point_estimate():
|
| 110 |
+
values = np.arange(10.0)
|
| 111 |
+
mean, std = metrics.bootstrap(lambda rows: float(values[rows].mean()), 0, len(values))
|
| 112 |
+
assert mean == pytest.approx(values.mean())
|
| 113 |
+
assert std == 0.0
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
def test_bootstrap_is_reproducible_and_spread_is_positive():
|
| 117 |
+
values = np.arange(50.0)
|
| 118 |
+
|
| 119 |
+
def metric(rows):
|
| 120 |
+
return float(values[rows].mean())
|
| 121 |
+
|
| 122 |
+
first = metrics.bootstrap(metric, 50, len(values), seed=3)
|
| 123 |
+
second = metrics.bootstrap(metric, 50, len(values), seed=3)
|
| 124 |
+
assert first == second
|
| 125 |
+
assert first[1] > 0
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
def test_bootstrap_resamples_whole_groups():
|
| 129 |
+
"""With one group, every group-resample is the same data, so spread is zero."""
|
| 130 |
+
values = np.arange(20.0)
|
| 131 |
+
groups = np.zeros(20)
|
| 132 |
+
_, std = metrics.bootstrap(
|
| 133 |
+
lambda rows: float(values[rows].mean()), 25, len(values), groups=groups
|
| 134 |
+
)
|
| 135 |
+
assert std == pytest.approx(0.0)
|
tests/test_real_data.py
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Integration tests against the real challenge data.
|
| 2 |
+
|
| 3 |
+
Skipped unless `scripts/build_challenge_data.py` has been run, so CI and a fresh
|
| 4 |
+
checkout stay synthetic-only. Run these after building the data and before
|
| 5 |
+
opening the challenge — they are the check that the manifests, the ground truth
|
| 6 |
+
and the scorer actually agree on real benchmarks, which no synthetic fixture can
|
| 7 |
+
tell you.
|
| 8 |
+
|
| 9 |
+
PLUG_REPO=~/plug python scripts/build_challenge_data.py
|
| 10 |
+
pytest tests/test_real_data.py -v
|
| 11 |
+
"""
|
| 12 |
+
|
| 13 |
+
from pathlib import Path
|
| 14 |
+
|
| 15 |
+
import numpy as np
|
| 16 |
+
import pandas as pd
|
| 17 |
+
import pytest
|
| 18 |
+
|
| 19 |
+
from plug_challenge import aggregate, scoring
|
| 20 |
+
from plug_challenge.benchmarks import BENCHMARKS, ID_COLUMN
|
| 21 |
+
from plug_challenge.validation import validate_bundle
|
| 22 |
+
|
| 23 |
+
DATA = Path(".challenge-data")
|
| 24 |
+
PUBLIC = DATA / "public"
|
| 25 |
+
GROUND_TRUTH = DATA / "private" / "ground_truth"
|
| 26 |
+
|
| 27 |
+
pytestmark = pytest.mark.skipif(
|
| 28 |
+
not GROUND_TRUTH.exists(),
|
| 29 |
+
reason="run scripts/build_challenge_data.py first",
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
@pytest.fixture(scope="module")
|
| 34 |
+
def real_truth() -> dict[str, pd.DataFrame]:
|
| 35 |
+
"""Every benchmark's real test ground truth that has been built."""
|
| 36 |
+
truth = {}
|
| 37 |
+
for spec in BENCHMARKS:
|
| 38 |
+
path = GROUND_TRUTH / f"{spec.name}.parquet"
|
| 39 |
+
if path.exists():
|
| 40 |
+
frame = pd.read_parquet(path)
|
| 41 |
+
frame[ID_COLUMN] = frame[ID_COLUMN].astype(str)
|
| 42 |
+
truth[spec.name] = frame
|
| 43 |
+
return truth
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
@pytest.fixture(scope="module")
|
| 47 |
+
def real_manifests() -> dict[str, pd.DataFrame]:
|
| 48 |
+
"""Every benchmark's real public test manifest that has been built."""
|
| 49 |
+
manifests = {}
|
| 50 |
+
for spec in BENCHMARKS:
|
| 51 |
+
path = PUBLIC / spec.name / "test_manifest.parquet"
|
| 52 |
+
if path.exists():
|
| 53 |
+
frame = pd.read_parquet(path)
|
| 54 |
+
frame[ID_COLUMN] = frame[ID_COLUMN].astype(str)
|
| 55 |
+
manifests[spec.name] = frame
|
| 56 |
+
return manifests
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
def test_all_eleven_benchmarks_were_built(real_truth, real_manifests):
|
| 60 |
+
missing = sorted({spec.name for spec in BENCHMARKS} - set(real_truth))
|
| 61 |
+
assert not missing, f"missing ground truth: {missing}"
|
| 62 |
+
assert len(real_manifests) == len(BENCHMARKS)
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
def test_manifest_ids_match_the_ground_truth(real_truth, real_manifests):
|
| 66 |
+
"""The join key a participant echoes back must be exactly what is scored."""
|
| 67 |
+
for spec in BENCHMARKS:
|
| 68 |
+
manifest_ids = set(real_manifests[spec.name][ID_COLUMN])
|
| 69 |
+
truth_ids = set(real_truth[spec.name][ID_COLUMN])
|
| 70 |
+
if spec.long_form:
|
| 71 |
+
# cafa5's ground truth is one row per annotation over a subset of the
|
| 72 |
+
# manifest's proteins (an unannotated protein has no rows).
|
| 73 |
+
assert truth_ids <= manifest_ids, spec.name
|
| 74 |
+
else:
|
| 75 |
+
assert manifest_ids == truth_ids, spec.name
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
def test_manifests_carry_no_labels(real_manifests):
|
| 79 |
+
"""A public manifest leaking a label column would give the answer away."""
|
| 80 |
+
for spec in BENCHMARKS:
|
| 81 |
+
columns = set(real_manifests[spec.name].columns)
|
| 82 |
+
leaked = columns & set(spec.truth_columns)
|
| 83 |
+
assert not leaked, f"{spec.name} manifest leaks {leaked}"
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
def test_manifests_have_the_columns_the_space_promises(real_manifests):
|
| 87 |
+
for spec in BENCHMARKS:
|
| 88 |
+
columns = set(real_manifests[spec.name].columns)
|
| 89 |
+
assert {ID_COLUMN, *spec.manifest_columns} <= columns, spec.name
|
| 90 |
+
|
| 91 |
+
|
| 92 |
+
def test_datapoint_ids_are_unique(real_manifests):
|
| 93 |
+
for spec in BENCHMARKS:
|
| 94 |
+
ids = real_manifests[spec.name][ID_COLUMN]
|
| 95 |
+
assert ids.is_unique, f"{spec.name} has duplicate {ID_COLUMN} values"
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
def test_datapoint_ids_are_unique_across_benchmarks(real_manifests):
|
| 99 |
+
"""Ids are namespaced by benchmark, so a row can never be joined to the wrong one."""
|
| 100 |
+
seen: dict[str, str] = {}
|
| 101 |
+
for spec in BENCHMARKS:
|
| 102 |
+
for datapoint_id in real_manifests[spec.name][ID_COLUMN]:
|
| 103 |
+
assert datapoint_id not in seen, (
|
| 104 |
+
f"{datapoint_id} in both {seen.get(datapoint_id)} and {spec.name}"
|
| 105 |
+
)
|
| 106 |
+
seen[datapoint_id] = spec.name
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
def test_ground_truth_carries_every_grouping_column(real_truth):
|
| 110 |
+
"""A grouped metric silently degrades to ungrouped if its column is absent."""
|
| 111 |
+
for spec in BENCHMARKS:
|
| 112 |
+
columns = set(real_truth[spec.name].columns)
|
| 113 |
+
for metric in spec.metrics:
|
| 114 |
+
if metric.grouped_by:
|
| 115 |
+
assert metric.grouped_by in columns, f"{spec.name}: {metric.grouped_by}"
|
| 116 |
+
|
| 117 |
+
|
| 118 |
+
def _perfect_bundle(real_truth, tmp_path: Path) -> Path:
|
| 119 |
+
"""A submission that simply echoes the ground truth back."""
|
| 120 |
+
import zipfile
|
| 121 |
+
|
| 122 |
+
with zipfile.ZipFile(tmp_path / "perfect.zip", "w") as archive:
|
| 123 |
+
for spec in BENCHMARKS:
|
| 124 |
+
gt = real_truth[spec.name]
|
| 125 |
+
if spec.long_form:
|
| 126 |
+
frame = gt[[ID_COLUMN, "aspect", "term"]].copy()
|
| 127 |
+
frame["score"] = 1.0
|
| 128 |
+
else:
|
| 129 |
+
frame = pd.DataFrame({ID_COLUMN: gt[ID_COLUMN]})
|
| 130 |
+
for truth_column, pred_column in zip(
|
| 131 |
+
spec.truth_columns, spec.pred_columns, strict=True
|
| 132 |
+
):
|
| 133 |
+
values = gt[truth_column].to_numpy(dtype=float)
|
| 134 |
+
# A constant truth column would be rejected as a constant
|
| 135 |
+
# prediction, so nudge one row to keep the bundle valid.
|
| 136 |
+
if np.std(values) == 0 and values.size > 1:
|
| 137 |
+
values = values.copy()
|
| 138 |
+
values[0] += 1.0
|
| 139 |
+
frame[pred_column] = values
|
| 140 |
+
archive.writestr(spec.filename, frame.to_csv(index=False))
|
| 141 |
+
return tmp_path / "perfect.zip"
|
| 142 |
+
|
| 143 |
+
|
| 144 |
+
def test_a_perfect_submission_validates_and_scores_one(real_truth, real_manifests, tmp_path):
|
| 145 |
+
"""The end-to-end contract: echoing the labels back scores a PLUG Score of 1."""
|
| 146 |
+
bundle = _perfect_bundle(real_truth, tmp_path)
|
| 147 |
+
expected = {name: set(frame[ID_COLUMN]) for name, frame in real_manifests.items()}
|
| 148 |
+
result = validate_bundle(bundle, expected)
|
| 149 |
+
assert result.ok, result.report()
|
| 150 |
+
|
| 151 |
+
scores = scoring.score_bundle(result.frames, real_truth, BENCHMARKS)
|
| 152 |
+
for spec in BENCHMARKS:
|
| 153 |
+
value = scores[spec.name][f"{spec.primary.key}_mean"]
|
| 154 |
+
assert value == pytest.approx(1.0), f"{spec.name} scored {value}"
|
| 155 |
+
assert aggregate.plug_score(scores) == pytest.approx(1.0)
|
| 156 |
+
|
| 157 |
+
|
| 158 |
+
def test_a_random_submission_scores_near_chance(real_truth, real_manifests, tmp_path):
|
| 159 |
+
"""A no-information submission should land near 0.5, not near 0 or 1."""
|
| 160 |
+
import zipfile
|
| 161 |
+
|
| 162 |
+
rng = np.random.default_rng(0)
|
| 163 |
+
bundle = tmp_path / "random.zip"
|
| 164 |
+
with zipfile.ZipFile(bundle, "w") as archive:
|
| 165 |
+
for spec in BENCHMARKS:
|
| 166 |
+
manifest = real_manifests[spec.name]
|
| 167 |
+
if spec.long_form:
|
| 168 |
+
# Predict one arbitrary term per protein at random confidence.
|
| 169 |
+
frame = pd.DataFrame(
|
| 170 |
+
{
|
| 171 |
+
ID_COLUMN: manifest[ID_COLUMN],
|
| 172 |
+
"aspect": "bp",
|
| 173 |
+
"term": "GO:0008150",
|
| 174 |
+
"score": rng.uniform(size=len(manifest)),
|
| 175 |
+
}
|
| 176 |
+
)
|
| 177 |
+
else:
|
| 178 |
+
frame = pd.DataFrame({ID_COLUMN: manifest[ID_COLUMN]})
|
| 179 |
+
for pred_column in spec.pred_columns:
|
| 180 |
+
frame[pred_column] = rng.normal(size=len(manifest))
|
| 181 |
+
archive.writestr(spec.filename, frame.to_csv(index=False))
|
| 182 |
+
|
| 183 |
+
expected = {name: set(frame[ID_COLUMN]) for name, frame in real_manifests.items()}
|
| 184 |
+
result = validate_bundle(bundle, expected)
|
| 185 |
+
assert result.ok, result.report()
|
| 186 |
+
|
| 187 |
+
scores = scoring.score_bundle(result.frames, real_truth, BENCHMARKS)
|
| 188 |
+
# cafa5 is excluded from the band check: a single-term submission's Fmax is set
|
| 189 |
+
# by that term's prevalence, not by chance ranking.
|
| 190 |
+
for spec in BENCHMARKS:
|
| 191 |
+
if spec.name == "cafa5":
|
| 192 |
+
continue
|
| 193 |
+
value = scores[spec.name][f"{spec.primary.key}_mean"]
|
| 194 |
+
normalised = aggregate.normalise(value, spec.primary.scale)
|
| 195 |
+
assert 0.35 < normalised < 0.65, f"{spec.name} normalised to {normalised}"
|
tests/test_scoring.py
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Tests for turning a validated bundle into metric values."""
|
| 2 |
+
|
| 3 |
+
import numpy as np
|
| 4 |
+
import pandas as pd
|
| 5 |
+
import pytest
|
| 6 |
+
|
| 7 |
+
from plug_challenge import scoring
|
| 8 |
+
from plug_challenge.benchmarks import BENCHMARK_NAMES, BENCHMARKS, ID_COLUMN, get
|
| 9 |
+
|
| 10 |
+
from .conftest import make_predictions
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def test_every_benchmark_scores_and_reports_its_metrics(predictions, truth):
|
| 14 |
+
scores = scoring.score_bundle(predictions, truth, BENCHMARKS)
|
| 15 |
+
assert set(scores) == set(BENCHMARK_NAMES)
|
| 16 |
+
for spec in BENCHMARKS:
|
| 17 |
+
for metric in spec.metrics:
|
| 18 |
+
assert f"{metric.key}_mean" in scores[spec.name]
|
| 19 |
+
assert f"{metric.key}_std" in scores[spec.name]
|
| 20 |
+
assert scores[spec.name]["n"] > 0
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def test_perfect_predictions_reach_the_metric_ceiling(truth):
|
| 24 |
+
perfect = make_predictions(truth, np.random.default_rng(0), noise=0.0)
|
| 25 |
+
scores = scoring.score_bundle(perfect, truth, BENCHMARKS)
|
| 26 |
+
for spec in BENCHMARKS:
|
| 27 |
+
value = scores[spec.name][f"{spec.primary.key}_mean"]
|
| 28 |
+
assert value == pytest.approx(1.0), f"{spec.name} scored {value}"
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def test_noisier_predictions_score_worse(truth):
|
| 32 |
+
good = scoring.score_bundle(
|
| 33 |
+
make_predictions(truth, np.random.default_rng(1), noise=0.1), truth, BENCHMARKS
|
| 34 |
+
)
|
| 35 |
+
bad = scoring.score_bundle(
|
| 36 |
+
make_predictions(truth, np.random.default_rng(1), noise=8.0), truth, BENCHMARKS
|
| 37 |
+
)
|
| 38 |
+
key = f"{get('megascale').primary.key}_mean"
|
| 39 |
+
assert good["megascale"][key] > bad["megascale"][key]
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
def test_inverted_predictions_score_below_chance(truth):
|
| 43 |
+
spec = get("ppi")
|
| 44 |
+
inverted = pd.DataFrame(
|
| 45 |
+
{
|
| 46 |
+
ID_COLUMN: truth["ppi"][ID_COLUMN],
|
| 47 |
+
"pred": 1.0 - truth["ppi"]["label"].to_numpy(dtype=float),
|
| 48 |
+
}
|
| 49 |
+
)
|
| 50 |
+
scores = scoring.score_benchmark(spec, inverted, truth["ppi"])
|
| 51 |
+
assert scores["auroc_mean"] == pytest.approx(0.0)
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
def test_benchmarks_are_scored_independently(predictions, truth):
|
| 55 |
+
"""Corrupting one benchmark must not move any other benchmark's number."""
|
| 56 |
+
baseline = scoring.score_bundle(predictions, truth, BENCHMARKS)
|
| 57 |
+
predictions["dms"]["pred"] = -predictions["dms"]["pred"]
|
| 58 |
+
after = scoring.score_bundle(predictions, truth, BENCHMARKS)
|
| 59 |
+
assert after["dms"] != baseline["dms"]
|
| 60 |
+
for name in BENCHMARK_NAMES:
|
| 61 |
+
if name != "dms":
|
| 62 |
+
assert after[name] == baseline[name]
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
def test_missing_ground_truth_skips_the_benchmark(predictions, truth):
|
| 66 |
+
del truth["atlas"]
|
| 67 |
+
scores = scoring.score_bundle(predictions, truth, BENCHMARKS)
|
| 68 |
+
assert "atlas" not in scores
|
| 69 |
+
assert len(scores) == len(BENCHMARK_NAMES) - 1
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
def test_bootstrap_adds_spread_without_moving_the_estimate(predictions, truth):
|
| 73 |
+
spec = get("megascale")
|
| 74 |
+
point = scoring.score_benchmark(spec, predictions["megascale"], truth["megascale"])
|
| 75 |
+
resampled = scoring.score_benchmark(
|
| 76 |
+
spec, predictions["megascale"], truth["megascale"], bootstrap_samples=100, seed=0
|
| 77 |
+
)
|
| 78 |
+
assert point["spearman_std"] == 0.0
|
| 79 |
+
assert resampled["spearman_std"] > 0
|
| 80 |
+
# The resampled mean is a different estimator, but it should land nearby.
|
| 81 |
+
assert resampled["spearman_mean"] == pytest.approx(point["spearman_mean"], abs=0.15)
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
def test_cafa5_macro_is_the_mean_of_its_branches(predictions, truth):
|
| 85 |
+
scores = scoring.score_benchmark(get("cafa5"), predictions["cafa5"], truth["cafa5"])
|
| 86 |
+
branches = [scores[f"fmax_{aspect}_mean"] for aspect in ("bp", "mf", "cc")]
|
| 87 |
+
assert scores["fmax_mean"] == pytest.approx(float(np.mean(branches)))
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
def test_cafa5_scores_false_positives_against_precision(truth):
|
| 91 |
+
"""A submission that predicts every term at full confidence should not score 1."""
|
| 92 |
+
gt = truth["cafa5"]
|
| 93 |
+
confident_everything = pd.DataFrame(
|
| 94 |
+
{
|
| 95 |
+
ID_COLUMN: list(gt[ID_COLUMN]) * 2,
|
| 96 |
+
"aspect": list(gt["aspect"]) * 2,
|
| 97 |
+
"term": list(gt["term"]) + [f"{t}-decoy" for t in gt["term"]],
|
| 98 |
+
"score": 1.0,
|
| 99 |
+
}
|
| 100 |
+
)
|
| 101 |
+
scores = scoring.score_benchmark(get("cafa5"), confident_everything, gt)
|
| 102 |
+
assert 0.0 < scores["fmax_mean"] < 1.0
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
def test_shs27k_macro_auroc_skips_modes_with_one_class(truth):
|
| 106 |
+
spec = get("shs27k")
|
| 107 |
+
gt = truth["shs27k"].copy()
|
| 108 |
+
gt[spec.truth_columns[0]] = 1 # this mode now has no negatives
|
| 109 |
+
perfect = pd.DataFrame({ID_COLUMN: gt[ID_COLUMN]})
|
| 110 |
+
for truth_column, pred_column in zip(spec.truth_columns, spec.pred_columns, strict=True):
|
| 111 |
+
perfect[pred_column] = gt[truth_column].to_numpy(dtype=float)
|
| 112 |
+
scores = scoring.score_benchmark(spec, perfect, gt)
|
| 113 |
+
assert scores["macro_auroc_mean"] == pytest.approx(1.0)
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
def test_extra_prediction_rows_would_break_the_join(truth):
|
| 117 |
+
"""The one-to-one merge is a guard: a duplicated id must raise, not be averaged."""
|
| 118 |
+
spec = get("megascale")
|
| 119 |
+
frame = pd.DataFrame(
|
| 120 |
+
{ID_COLUMN: truth["megascale"][ID_COLUMN], "pred": 1.0}
|
| 121 |
+
)
|
| 122 |
+
doubled = pd.concat([frame, frame.head(1)], ignore_index=True)
|
| 123 |
+
with pytest.raises(pd.errors.MergeError):
|
| 124 |
+
scoring.score_benchmark(spec, doubled, truth["megascale"])
|
| 125 |
+
|
| 126 |
+
|
| 127 |
+
def test_cafa5_reports_per_branch_target_counts(predictions, truth):
|
| 128 |
+
scores = scoring.score_benchmark(get("cafa5"), predictions["cafa5"], truth["cafa5"])
|
| 129 |
+
# The synthetic fixture annotates every protein in every branch.
|
| 130 |
+
n_proteins = truth["cafa5"][ID_COLUMN].nunique()
|
| 131 |
+
assert scores["n"] == n_proteins
|
| 132 |
+
for aspect in ("bp", "mf", "cc"):
|
| 133 |
+
assert scores[f"fmax_{aspect}_n"] == n_proteins
|
| 134 |
+
|
| 135 |
+
|
| 136 |
+
def test_cafa5_n_counts_annotated_targets_only(truth):
|
| 137 |
+
"""A protein with no annotations in any branch is not a scorable target."""
|
| 138 |
+
gt = truth["cafa5"]
|
| 139 |
+
annotated = gt[gt[ID_COLUMN] != gt[ID_COLUMN].iloc[0]]
|
| 140 |
+
predictions = annotated[[ID_COLUMN, "aspect", "term"]].copy()
|
| 141 |
+
predictions["score"] = 1.0
|
| 142 |
+
scores = scoring.score_benchmark(get("cafa5"), predictions, annotated)
|
| 143 |
+
assert scores["n"] == gt[ID_COLUMN].nunique() - 1
|
| 144 |
+
assert scores["fmax_mean"] == pytest.approx(1.0)
|
tests/test_submission_flow.py
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""End-to-end tests for the Submit tab's handler.
|
| 2 |
+
|
| 3 |
+
The Hub and Hugging Face's profile pages are patched out; everything else —
|
| 4 |
+
validation, scoring, the cooldown, the ordering of stores — is the real code
|
| 5 |
+
path a participant hits.
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
from datetime import timedelta
|
| 9 |
+
from pathlib import Path
|
| 10 |
+
|
| 11 |
+
import pandas as pd
|
| 12 |
+
import pytest
|
| 13 |
+
|
| 14 |
+
import submission as submit_module
|
| 15 |
+
from plug_challenge.benchmarks import BENCHMARKS
|
| 16 |
+
|
| 17 |
+
from .conftest import write_bundle
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
class FakeStore:
|
| 21 |
+
"""Records what a submission would have written, instead of writing it."""
|
| 22 |
+
|
| 23 |
+
def __init__(self, truth):
|
| 24 |
+
self.truth = truth
|
| 25 |
+
self.bundles: list[str] = []
|
| 26 |
+
self.scores: list[dict] = []
|
| 27 |
+
self.entries: list[dict] = []
|
| 28 |
+
self.last_submission = None
|
| 29 |
+
self.fail_on_upload = False
|
| 30 |
+
|
| 31 |
+
def configured(self):
|
| 32 |
+
return True
|
| 33 |
+
|
| 34 |
+
def available_ground_truth(self):
|
| 35 |
+
return self.truth
|
| 36 |
+
|
| 37 |
+
def expected_ids(self, truth):
|
| 38 |
+
from plug_challenge.benchmarks import ID_COLUMN
|
| 39 |
+
|
| 40 |
+
return {name: set(frame[ID_COLUMN].astype(str)) for name, frame in truth.items()}
|
| 41 |
+
|
| 42 |
+
def upload_submission(self, safe_username, submission_id, bundle_path, metadata):
|
| 43 |
+
if self.fail_on_upload:
|
| 44 |
+
raise RuntimeError("hub is down")
|
| 45 |
+
self.bundles.append(submission_id)
|
| 46 |
+
return f"submissions/{safe_username}/{submission_id}/bundle.zip"
|
| 47 |
+
|
| 48 |
+
def save_scores(self, safe_username, submission_id, scores):
|
| 49 |
+
self.scores.append(scores)
|
| 50 |
+
|
| 51 |
+
def append_leaderboard_entry(self, entry):
|
| 52 |
+
self.entries.append(entry)
|
| 53 |
+
|
| 54 |
+
def last_submission_at(self, safe_username):
|
| 55 |
+
return self.last_submission
|
| 56 |
+
|
| 57 |
+
def now(self):
|
| 58 |
+
return pd.Timestamp("2026-05-01T12:00:00Z").to_pydatetime()
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
@pytest.fixture
|
| 62 |
+
def fake_store(monkeypatch, truth):
|
| 63 |
+
store = FakeStore(truth)
|
| 64 |
+
monkeypatch.setattr(submit_module, "store", store)
|
| 65 |
+
monkeypatch.setattr(submit_module, "validate_hf_username", lambda username: True)
|
| 66 |
+
monkeypatch.setattr(submit_module, "validate_model_details", lambda tag: str(tag or "").strip())
|
| 67 |
+
monkeypatch.setattr(submit_module, "CURRENT_PHASE", 1)
|
| 68 |
+
return store
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
def _submit(bundle: Path | None, **overrides):
|
| 72 |
+
kwargs = {
|
| 73 |
+
"username": "someone",
|
| 74 |
+
"user_alias": "Team Alias",
|
| 75 |
+
"anonymous": False,
|
| 76 |
+
"participant_name": "Jane Smith",
|
| 77 |
+
"discord_username": "jane",
|
| 78 |
+
"email": "jane@example.com",
|
| 79 |
+
"affiliation": "Somewhere",
|
| 80 |
+
"model_tag": "https://example.org/report",
|
| 81 |
+
"used_proprietary_data": False,
|
| 82 |
+
"open_source_code": False,
|
| 83 |
+
"file_input": None if bundle is None else str(bundle),
|
| 84 |
+
}
|
| 85 |
+
kwargs.update(overrides)
|
| 86 |
+
return submit_module.submit_bundle(**kwargs)
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
def _text(update: dict) -> str:
|
| 90 |
+
return update["value"]
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
def test_a_valid_bundle_is_stored_and_scored(fake_store, bundle):
|
| 94 |
+
result = _text(_submit(bundle))
|
| 95 |
+
assert "Submission accepted" in result
|
| 96 |
+
assert "PLUG Score" in result
|
| 97 |
+
assert len(fake_store.bundles) == 1
|
| 98 |
+
assert len(fake_store.entries) == 1
|
| 99 |
+
entry = fake_store.entries[0]
|
| 100 |
+
assert 0.0 <= entry["plug_score"] <= 1.0
|
| 101 |
+
for spec in BENCHMARKS:
|
| 102 |
+
assert f"{spec.name}__{spec.primary.key}_mean" in entry
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
def test_the_response_shows_every_benchmark(fake_store, bundle):
|
| 106 |
+
result = _text(_submit(bundle))
|
| 107 |
+
for spec in BENCHMARKS:
|
| 108 |
+
assert spec.label in result
|
| 109 |
+
|
| 110 |
+
|
| 111 |
+
def test_an_invalid_bundle_stores_nothing_and_starts_no_cooldown(fake_store, predictions, tmp_path):
|
| 112 |
+
predictions["megascale"]["pred"] = 1.0 # constant column
|
| 113 |
+
result = _text(_submit(write_bundle(predictions, tmp_path / "bad.zip")))
|
| 114 |
+
assert "not accepted" in result
|
| 115 |
+
assert "constant" in result
|
| 116 |
+
assert "cooldown has not started" in result
|
| 117 |
+
assert fake_store.bundles == []
|
| 118 |
+
assert fake_store.entries == []
|
| 119 |
+
|
| 120 |
+
|
| 121 |
+
def test_the_cooldown_blocks_a_quick_resubmission(fake_store, bundle):
|
| 122 |
+
fake_store.last_submission = fake_store.now() - timedelta(hours=1)
|
| 123 |
+
result = _text(_submit(bundle))
|
| 124 |
+
assert "Please wait" in result
|
| 125 |
+
assert fake_store.bundles == []
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
def test_the_cooldown_expires(fake_store, bundle):
|
| 129 |
+
fake_store.last_submission = fake_store.now() - timedelta(hours=48)
|
| 130 |
+
assert "accepted" in _text(_submit(bundle))
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
def test_anonymous_submission_requires_an_alias(fake_store, bundle):
|
| 134 |
+
result = _text(_submit(bundle, anonymous=True, user_alias=" "))
|
| 135 |
+
assert "alias is required" in result
|
| 136 |
+
assert fake_store.bundles == []
|
| 137 |
+
|
| 138 |
+
|
| 139 |
+
def test_anonymous_submission_records_the_alias_not_the_username(fake_store, bundle):
|
| 140 |
+
_submit(bundle, anonymous=True, user_alias="Team Alias")
|
| 141 |
+
entry = fake_store.entries[0]
|
| 142 |
+
assert entry["username"] == "Team Alias"
|
| 143 |
+
# The real account is still kept as the (non-displayed) dedup/cooldown key.
|
| 144 |
+
assert entry["safe_username"] == "someone"
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
def test_a_missing_file_is_rejected(fake_store):
|
| 148 |
+
assert "upload your submission bundle" in _text(_submit(None))
|
| 149 |
+
|
| 150 |
+
|
| 151 |
+
def test_an_unknown_username_is_rejected(fake_store, bundle, monkeypatch):
|
| 152 |
+
monkeypatch.setattr(submit_module, "validate_hf_username", lambda username: False)
|
| 153 |
+
result = _text(_submit(bundle))
|
| 154 |
+
assert "could not be found" in result
|
| 155 |
+
assert fake_store.bundles == []
|
| 156 |
+
|
| 157 |
+
|
| 158 |
+
def test_a_banned_username_is_rejected(fake_store, bundle, monkeypatch):
|
| 159 |
+
monkeypatch.setattr(submit_module, "BANNED_USERNAMES", {"someone": "Multiple accounts"})
|
| 160 |
+
result = _text(_submit(bundle))
|
| 161 |
+
assert "blocked" in result
|
| 162 |
+
assert "Multiple accounts" in result
|
| 163 |
+
|
| 164 |
+
|
| 165 |
+
def test_a_bad_email_is_rejected(fake_store, bundle):
|
| 166 |
+
assert "valid email" in _text(_submit(bundle, email="not-an-email"))
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
def test_open_source_requires_a_reachable_report_link(fake_store, bundle, monkeypatch):
|
| 170 |
+
monkeypatch.setattr(submit_module, "validate_model_details", lambda tag: "Invalid link")
|
| 171 |
+
result = _text(_submit(bundle, open_source_code=True))
|
| 172 |
+
assert "method report link" in result
|
| 173 |
+
assert fake_store.bundles == []
|
| 174 |
+
|
| 175 |
+
|
| 176 |
+
def test_submissions_are_refused_outside_the_open_phase(fake_store, bundle, monkeypatch):
|
| 177 |
+
monkeypatch.setattr(submit_module, "CURRENT_PHASE", 2)
|
| 178 |
+
assert "not open" in _text(_submit(bundle))
|
| 179 |
+
|
| 180 |
+
|
| 181 |
+
def test_a_storage_failure_is_reported_with_the_submission_id(fake_store, bundle):
|
| 182 |
+
fake_store.fail_on_upload = True
|
| 183 |
+
result = _text(_submit(bundle))
|
| 184 |
+
assert "storing it failed" in result
|
| 185 |
+
assert fake_store.entries == []
|
| 186 |
+
|
| 187 |
+
|
| 188 |
+
def test_a_missing_ground_truth_blocks_submissions(fake_store, bundle):
|
| 189 |
+
fake_store.truth = {}
|
| 190 |
+
assert "No ground truth" in _text(_submit(bundle))
|
tests/test_validation.py
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Tests for submission bundle validation."""
|
| 2 |
+
|
| 3 |
+
import zipfile
|
| 4 |
+
from pathlib import Path
|
| 5 |
+
|
| 6 |
+
import pandas as pd
|
| 7 |
+
|
| 8 |
+
from plug_challenge.benchmarks import BENCHMARK_NAMES, ID_COLUMN, get
|
| 9 |
+
from plug_challenge.validation import bundle_members, validate_bundle
|
| 10 |
+
|
| 11 |
+
from .conftest import write_bundle
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
def _errors_for(result, benchmark: str) -> list[str]:
|
| 15 |
+
return [e.message for e in result.errors if e.benchmark == benchmark]
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
def test_valid_bundle_passes(bundle: Path, expected_ids):
|
| 19 |
+
result = validate_bundle(bundle, expected_ids)
|
| 20 |
+
assert result.ok, result.report()
|
| 21 |
+
assert set(result.frames) == set(BENCHMARK_NAMES)
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def test_bundle_must_be_a_zip(tmp_path: Path, expected_ids):
|
| 25 |
+
loose = tmp_path / "megascale.csv"
|
| 26 |
+
loose.write_text("a,b\n1,2\n")
|
| 27 |
+
result = validate_bundle(loose, expected_ids)
|
| 28 |
+
assert not result.ok
|
| 29 |
+
assert "single .zip" in result.report()
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def test_missing_file_is_rejected(predictions, tmp_path: Path, expected_ids):
|
| 33 |
+
del predictions["megascale"]
|
| 34 |
+
result = validate_bundle(write_bundle(predictions, tmp_path / "b.zip"), expected_ids)
|
| 35 |
+
assert not result.ok
|
| 36 |
+
assert "megascale" in result.report()
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
def test_partial_bundle_allowed_when_not_required(predictions, tmp_path: Path, expected_ids):
|
| 40 |
+
del predictions["megascale"]
|
| 41 |
+
result = validate_bundle(
|
| 42 |
+
write_bundle(predictions, tmp_path / "b.zip"), expected_ids, require_complete=False
|
| 43 |
+
)
|
| 44 |
+
# Scorable: the absent benchmark is a warning, not a blocking error...
|
| 45 |
+
assert result.ok
|
| 46 |
+
assert [w.benchmark for w in result.warnings] == ["bundle"]
|
| 47 |
+
assert "megascale" in result.report()
|
| 48 |
+
# ...and every other benchmark still parsed.
|
| 49 |
+
assert "megascale" not in result.frames
|
| 50 |
+
assert len(result.frames) == len(BENCHMARK_NAMES) - 1
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
def test_partial_bundle_still_rejects_a_real_error(predictions, tmp_path: Path, expected_ids):
|
| 54 |
+
"""--allow-partial forgives an absent benchmark, never a malformed one."""
|
| 55 |
+
del predictions["megascale"]
|
| 56 |
+
predictions["atlas"]["pred"] = 1.0 # constant column
|
| 57 |
+
result = validate_bundle(
|
| 58 |
+
write_bundle(predictions, tmp_path / "b.zip"), expected_ids, require_complete=False
|
| 59 |
+
)
|
| 60 |
+
assert not result.ok
|
| 61 |
+
assert any("constant" in e.message for e in result.errors)
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
def test_directory_prefixed_and_macos_entries_are_handled(predictions, tmp_path: Path):
|
| 65 |
+
path = tmp_path / "nested.zip"
|
| 66 |
+
with zipfile.ZipFile(path, "w") as archive:
|
| 67 |
+
archive.writestr("__MACOSX/._megascale.csv", "junk")
|
| 68 |
+
for name, frame in predictions.items():
|
| 69 |
+
archive.writestr(f"plug_submission/{name}.csv", frame.to_csv(index=False))
|
| 70 |
+
assert set(bundle_members(path)) == set(BENCHMARK_NAMES)
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
def test_parquet_files_are_accepted(predictions, tmp_path: Path, expected_ids):
|
| 74 |
+
path = tmp_path / "parquet.zip"
|
| 75 |
+
with zipfile.ZipFile(path, "w") as archive:
|
| 76 |
+
for name, frame in predictions.items():
|
| 77 |
+
member = tmp_path / f"{name}.parquet"
|
| 78 |
+
frame.to_parquet(member, index=False)
|
| 79 |
+
archive.write(member, arcname=f"{name}.parquet")
|
| 80 |
+
result = validate_bundle(path, expected_ids)
|
| 81 |
+
assert result.ok, result.report()
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
def test_missing_column_is_reported(predictions, tmp_path: Path, expected_ids):
|
| 85 |
+
predictions["megascale"] = predictions["megascale"].drop(columns=["pred"])
|
| 86 |
+
result = validate_bundle(write_bundle(predictions, tmp_path / "b.zip"), expected_ids)
|
| 87 |
+
assert any("Missing required column" in m for m in _errors_for(result, "megascale"))
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
def test_missing_and_unknown_ids_are_reported(predictions, tmp_path: Path, expected_ids):
|
| 91 |
+
frame = predictions["ppi"].copy()
|
| 92 |
+
frame.loc[0, ID_COLUMN] = "not-a-real-id"
|
| 93 |
+
predictions["ppi"] = frame
|
| 94 |
+
result = validate_bundle(write_bundle(predictions, tmp_path / "b.zip"), expected_ids)
|
| 95 |
+
messages = " ".join(_errors_for(result, "ppi"))
|
| 96 |
+
assert "no prediction" in messages
|
| 97 |
+
assert "not in the test split" in messages
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
def test_duplicate_ids_are_reported(predictions, tmp_path: Path, expected_ids):
|
| 101 |
+
frame = predictions["fireprot"]
|
| 102 |
+
predictions["fireprot"] = pd.concat([frame, frame.head(1)], ignore_index=True)
|
| 103 |
+
result = validate_bundle(write_bundle(predictions, tmp_path / "b.zip"), expected_ids)
|
| 104 |
+
assert any("duplicated" in m for m in _errors_for(result, "fireprot"))
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
def test_constant_prediction_column_is_rejected(predictions, tmp_path: Path, expected_ids):
|
| 108 |
+
predictions["atlas"]["pred"] = 1.0
|
| 109 |
+
result = validate_bundle(write_bundle(predictions, tmp_path / "b.zip"), expected_ids)
|
| 110 |
+
assert any("constant" in m for m in _errors_for(result, "atlas"))
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
def test_nan_prediction_is_rejected(predictions, tmp_path: Path, expected_ids):
|
| 114 |
+
predictions["dms"].loc[0, "pred"] = float("nan")
|
| 115 |
+
result = validate_bundle(write_bundle(predictions, tmp_path / "b.zip"), expected_ids)
|
| 116 |
+
assert any("missing value" in m for m in _errors_for(result, "dms"))
|
| 117 |
+
|
| 118 |
+
|
| 119 |
+
def test_infinite_prediction_is_rejected(predictions, tmp_path: Path, expected_ids):
|
| 120 |
+
predictions["lp-pdbbind"].loc[0, "pred"] = float("inf")
|
| 121 |
+
result = validate_bundle(write_bundle(predictions, tmp_path / "b.zip"), expected_ids)
|
| 122 |
+
assert any("infinite" in m for m in _errors_for(result, "lp-pdbbind"))
|
| 123 |
+
|
| 124 |
+
|
| 125 |
+
def test_non_numeric_prediction_is_rejected(predictions, tmp_path: Path, expected_ids):
|
| 126 |
+
predictions["megascale"]["pred"] = predictions["megascale"]["pred"].astype(str) + "x"
|
| 127 |
+
result = validate_bundle(write_bundle(predictions, tmp_path / "b.zip"), expected_ids)
|
| 128 |
+
assert any("non-numeric" in m for m in _errors_for(result, "megascale"))
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
def test_out_of_range_score_is_rejected(predictions, tmp_path: Path, expected_ids):
|
| 132 |
+
predictions["cafa5"].loc[0, "score"] = 1.5
|
| 133 |
+
result = validate_bundle(write_bundle(predictions, tmp_path / "b.zip"), expected_ids)
|
| 134 |
+
assert any("outside [0.0, 1.0]" in m for m in _errors_for(result, "cafa5"))
|
| 135 |
+
|
| 136 |
+
|
| 137 |
+
def test_unknown_go_aspect_is_rejected(predictions, tmp_path: Path, expected_ids):
|
| 138 |
+
predictions["cafa5"].loc[0, "aspect"] = "molecular_function"
|
| 139 |
+
result = validate_bundle(write_bundle(predictions, tmp_path / "b.zip"), expected_ids)
|
| 140 |
+
assert any("unrecognised 'aspect'" in m for m in _errors_for(result, "cafa5"))
|
| 141 |
+
|
| 142 |
+
|
| 143 |
+
def test_duplicate_go_term_is_rejected(predictions, tmp_path: Path, expected_ids):
|
| 144 |
+
frame = predictions["cafa5"]
|
| 145 |
+
predictions["cafa5"] = pd.concat([frame, frame.head(1)], ignore_index=True)
|
| 146 |
+
result = validate_bundle(write_bundle(predictions, tmp_path / "b.zip"), expected_ids)
|
| 147 |
+
assert any("duplicated" in m for m in _errors_for(result, "cafa5"))
|
| 148 |
+
|
| 149 |
+
|
| 150 |
+
def test_long_form_allows_missing_targets(predictions, tmp_path: Path, expected_ids):
|
| 151 |
+
"""Declining to annotate a protein is legal for cafa5 and costs only recall."""
|
| 152 |
+
dropped = predictions["cafa5"][ID_COLUMN].unique()[0]
|
| 153 |
+
predictions["cafa5"] = predictions["cafa5"][predictions["cafa5"][ID_COLUMN] != dropped]
|
| 154 |
+
result = validate_bundle(write_bundle(predictions, tmp_path / "b.zip"), expected_ids)
|
| 155 |
+
assert result.ok, result.report()
|
| 156 |
+
|
| 157 |
+
|
| 158 |
+
def test_shs27k_needs_all_seven_mode_columns(predictions, tmp_path: Path, expected_ids):
|
| 159 |
+
spec = get("shs27k")
|
| 160 |
+
predictions["shs27k"] = predictions["shs27k"].drop(columns=[spec.pred_columns[3]])
|
| 161 |
+
result = validate_bundle(write_bundle(predictions, tmp_path / "b.zip"), expected_ids)
|
| 162 |
+
assert any(spec.pred_columns[3] in m for m in _errors_for(result, "shs27k"))
|
| 163 |
+
|
| 164 |
+
|
| 165 |
+
def test_benchmark_without_ground_truth_is_not_scored(predictions, tmp_path: Path, expected_ids):
|
| 166 |
+
del expected_ids["atlas"]
|
| 167 |
+
result = validate_bundle(write_bundle(predictions, tmp_path / "b.zip"), expected_ids)
|
| 168 |
+
assert any("not open for scoring" in m for m in _errors_for(result, "atlas"))
|
| 169 |
+
|
| 170 |
+
|
| 171 |
+
def test_constant_confidence_is_allowed_for_cafa5(predictions, tmp_path: Path, expected_ids):
|
| 172 |
+
"""Fmax sweeps a threshold rather than ranking, so "confident in all of these"
|
| 173 |
+
is a legitimate CAFA submission — unlike a constant column on a rank metric.
|
| 174 |
+
"""
|
| 175 |
+
predictions["cafa5"]["score"] = 1.0
|
| 176 |
+
result = validate_bundle(write_bundle(predictions, tmp_path / "b.zip"), expected_ids)
|
| 177 |
+
assert result.ok, result.report()
|
| 178 |
+
|
| 179 |
+
|
| 180 |
+
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
|
utils.py
ADDED
|
@@ -0,0 +1,274 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Utilities for the PLUG challenge Space.
|
| 2 |
+
|
| 3 |
+
Username and link checking, ported from the OpenADMET blind-challenge template
|
| 4 |
+
(including its SSRF guard on user-supplied URLs) with the S3 layer removed —
|
| 5 |
+
storage lives in ``plug_challenge.store``.
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
import ipaddress
|
| 9 |
+
import re
|
| 10 |
+
import socket
|
| 11 |
+
import time
|
| 12 |
+
from urllib.parse import urljoin, urlparse
|
| 13 |
+
|
| 14 |
+
import requests
|
| 15 |
+
from loguru import logger
|
| 16 |
+
|
| 17 |
+
_MAX_REDIRECTS = 5
|
| 18 |
+
|
| 19 |
+
BANNED_USERNAMES: dict[str, str] = { # normalised (lowercase) username: reason
|
| 20 |
+
# Add entries here to block submissions from a Hugging Face account, e.g.:
|
| 21 |
+
# "some-username": "Suspected of using multiple HF accounts",
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def safeify_username(username: str) -> str:
|
| 26 |
+
"""Sanitise a Hugging Face username for use in repo paths.
|
| 27 |
+
|
| 28 |
+
Organisation usernames use the form ``org/user``, which would create
|
| 29 |
+
unintended path nesting. Lowercased so that casing variants — which all
|
| 30 |
+
resolve to the same account — map to the same prefix; otherwise the
|
| 31 |
+
submission cooldown could be bypassed by alternating case.
|
| 32 |
+
|
| 33 |
+
Parameters
|
| 34 |
+
----------
|
| 35 |
+
username : str
|
| 36 |
+
The raw username as typed.
|
| 37 |
+
|
| 38 |
+
Returns
|
| 39 |
+
-------
|
| 40 |
+
str
|
| 41 |
+
Lowercased, with ``/`` and spaces replaced by underscores.
|
| 42 |
+
|
| 43 |
+
"""
|
| 44 |
+
return str(username).strip().lower().replace("/", "_").replace(" ", "_")
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def _is_safe_public_url(url: str) -> bool:
|
| 48 |
+
"""Reject URLs whose host resolves to a private/loopback/link-local address.
|
| 49 |
+
|
| 50 |
+
Guards ``check_page_exists`` against SSRF: without this, a user-supplied URL
|
| 51 |
+
(the "Method Report Link" field) could point the server at internal
|
| 52 |
+
infrastructure and have it report reachability back.
|
| 53 |
+
|
| 54 |
+
Parameters
|
| 55 |
+
----------
|
| 56 |
+
url : str
|
| 57 |
+
The URL to check.
|
| 58 |
+
|
| 59 |
+
Returns
|
| 60 |
+
-------
|
| 61 |
+
bool
|
| 62 |
+
True if every address the host resolves to is public.
|
| 63 |
+
|
| 64 |
+
"""
|
| 65 |
+
hostname = urlparse(url).hostname
|
| 66 |
+
if not hostname:
|
| 67 |
+
return False
|
| 68 |
+
try:
|
| 69 |
+
infos = socket.getaddrinfo(hostname, None)
|
| 70 |
+
except socket.gaierror:
|
| 71 |
+
return False
|
| 72 |
+
for info in infos:
|
| 73 |
+
ip = ipaddress.ip_address(info[4][0])
|
| 74 |
+
if (
|
| 75 |
+
ip.is_private
|
| 76 |
+
or ip.is_loopback
|
| 77 |
+
or ip.is_link_local
|
| 78 |
+
or ip.is_reserved
|
| 79 |
+
or ip.is_multicast
|
| 80 |
+
or ip.is_unspecified
|
| 81 |
+
):
|
| 82 |
+
return False
|
| 83 |
+
return True
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
def check_page_exists(
|
| 87 |
+
url: str,
|
| 88 |
+
delay: float = 0.2,
|
| 89 |
+
max_retries: int = 3,
|
| 90 |
+
current_retries: int = 0,
|
| 91 |
+
restrict_to_public: bool = True,
|
| 92 |
+
) -> bool:
|
| 93 |
+
"""Check whether a page exists, retrying on rate limits.
|
| 94 |
+
|
| 95 |
+
Redirects are followed manually rather than via ``requests``' built-in
|
| 96 |
+
``allow_redirects`` so each hop is checked against ``_is_safe_public_url``
|
| 97 |
+
before it is requested, closing off SSRF via a redirect to an internal
|
| 98 |
+
address.
|
| 99 |
+
|
| 100 |
+
Parameters
|
| 101 |
+
----------
|
| 102 |
+
url : str
|
| 103 |
+
The URL to check.
|
| 104 |
+
delay : float
|
| 105 |
+
Seconds to sleep after every request.
|
| 106 |
+
max_retries : int
|
| 107 |
+
Maximum retries on HTTP 429.
|
| 108 |
+
current_retries : int
|
| 109 |
+
Internal retry counter.
|
| 110 |
+
restrict_to_public : bool
|
| 111 |
+
Reject hosts resolving to private addresses. Only meaningful when the
|
| 112 |
+
host is user-controlled; disable for a hardcoded trusted domain, since
|
| 113 |
+
some platforms resolve their own domain internally (split-horizon DNS)
|
| 114 |
+
and this check would then reject it.
|
| 115 |
+
|
| 116 |
+
Returns
|
| 117 |
+
-------
|
| 118 |
+
bool
|
| 119 |
+
True when the URL returns HTTP 200.
|
| 120 |
+
|
| 121 |
+
"""
|
| 122 |
+
safe_url = str(url).strip()
|
| 123 |
+
if not safe_url.startswith(("http://", "https://")):
|
| 124 |
+
safe_url = f"https://{safe_url}"
|
| 125 |
+
|
| 126 |
+
try:
|
| 127 |
+
response = None
|
| 128 |
+
for _ in range(_MAX_REDIRECTS + 1):
|
| 129 |
+
if restrict_to_public and not _is_safe_public_url(safe_url):
|
| 130 |
+
logger.warning("Refusing to fetch non-public URL: {}", safe_url)
|
| 131 |
+
return False
|
| 132 |
+
response = requests.get(safe_url, timeout=5, allow_redirects=False)
|
| 133 |
+
if (
|
| 134 |
+
response.status_code in (301, 302, 303, 307, 308)
|
| 135 |
+
and "Location" in response.headers
|
| 136 |
+
):
|
| 137 |
+
safe_url = urljoin(safe_url, response.headers["Location"])
|
| 138 |
+
continue
|
| 139 |
+
break
|
| 140 |
+
else:
|
| 141 |
+
logger.warning("Too many redirects for {}", url)
|
| 142 |
+
return False
|
| 143 |
+
|
| 144 |
+
if response.status_code == 429:
|
| 145 |
+
if current_retries < max_retries:
|
| 146 |
+
wait = 5 * (2**current_retries)
|
| 147 |
+
logger.warning(
|
| 148 |
+
"Rate limited on {} (attempt {}/{}), waiting {}s.",
|
| 149 |
+
safe_url,
|
| 150 |
+
current_retries + 1,
|
| 151 |
+
max_retries,
|
| 152 |
+
wait,
|
| 153 |
+
)
|
| 154 |
+
time.sleep(wait)
|
| 155 |
+
return check_page_exists(
|
| 156 |
+
safe_url,
|
| 157 |
+
delay=delay,
|
| 158 |
+
max_retries=max_retries,
|
| 159 |
+
current_retries=current_retries + 1,
|
| 160 |
+
restrict_to_public=restrict_to_public,
|
| 161 |
+
)
|
| 162 |
+
logger.error("Max retries reached for rate limit on {}.", safe_url)
|
| 163 |
+
return False
|
| 164 |
+
|
| 165 |
+
return response.status_code == 200
|
| 166 |
+
|
| 167 |
+
except requests.exceptions.RequestException as exc:
|
| 168 |
+
logger.error("Error checking URL {}: {}", safe_url, exc)
|
| 169 |
+
return False
|
| 170 |
+
|
| 171 |
+
finally:
|
| 172 |
+
time.sleep(delay)
|
| 173 |
+
|
| 174 |
+
|
| 175 |
+
def validate_hf_username(username: str) -> bool:
|
| 176 |
+
"""Confirm a Hugging Face account exists by fetching its profile page.
|
| 177 |
+
|
| 178 |
+
This is a typo check, not an identity proof — nothing here verifies that the
|
| 179 |
+
submitter owns the account.
|
| 180 |
+
|
| 181 |
+
Parameters
|
| 182 |
+
----------
|
| 183 |
+
username : str
|
| 184 |
+
A username, or a full ``https://huggingface.co/<user>`` URL.
|
| 185 |
+
|
| 186 |
+
Returns
|
| 187 |
+
-------
|
| 188 |
+
bool
|
| 189 |
+
True when the profile page loads.
|
| 190 |
+
|
| 191 |
+
"""
|
| 192 |
+
# restrict_to_public=False: the target is always the literal huggingface.co
|
| 193 |
+
# domain, never an attacker-supplied host, and HF can resolve its own domain
|
| 194 |
+
# to an internal address from inside its infrastructure.
|
| 195 |
+
candidate = str(username).strip()
|
| 196 |
+
if re.match(r"^https?://huggingface\.co/([^/]+)/?$", candidate):
|
| 197 |
+
return check_page_exists(
|
| 198 |
+
candidate, delay=1, max_retries=10, restrict_to_public=False
|
| 199 |
+
)
|
| 200 |
+
return check_page_exists(
|
| 201 |
+
f"https://huggingface.co/{candidate}",
|
| 202 |
+
delay=1,
|
| 203 |
+
max_retries=10,
|
| 204 |
+
restrict_to_public=False,
|
| 205 |
+
)
|
| 206 |
+
|
| 207 |
+
|
| 208 |
+
def validate_model_details(tag: str | None) -> str:
|
| 209 |
+
"""Validate a method report link.
|
| 210 |
+
|
| 211 |
+
Parameters
|
| 212 |
+
----------
|
| 213 |
+
tag : str | None
|
| 214 |
+
The URL as typed, or empty.
|
| 215 |
+
|
| 216 |
+
Returns
|
| 217 |
+
-------
|
| 218 |
+
str
|
| 219 |
+
The URL when it is a reachable ``https://`` page, ``"Not submitted"``
|
| 220 |
+
when blank, or ``"Invalid link"`` otherwise.
|
| 221 |
+
|
| 222 |
+
"""
|
| 223 |
+
if tag is None or str(tag).strip() == "":
|
| 224 |
+
return "Not submitted"
|
| 225 |
+
safe_tag = str(tag).strip()
|
| 226 |
+
if not safe_tag.startswith("https://"):
|
| 227 |
+
return "Invalid link"
|
| 228 |
+
return safe_tag if check_page_exists(safe_tag, delay=2) else "Invalid link"
|
| 229 |
+
|
| 230 |
+
|
| 231 |
+
def make_user_clickable(name: str) -> str:
|
| 232 |
+
"""Link a leaderboard username to its Hugging Face profile.
|
| 233 |
+
|
| 234 |
+
Parameters
|
| 235 |
+
----------
|
| 236 |
+
name : str
|
| 237 |
+
Username or alias as displayed.
|
| 238 |
+
|
| 239 |
+
Returns
|
| 240 |
+
-------
|
| 241 |
+
str
|
| 242 |
+
An HTML anchor.
|
| 243 |
+
|
| 244 |
+
"""
|
| 245 |
+
link = f"https://huggingface.co/{name}" if not str(name).startswith("https://") else str(name)
|
| 246 |
+
return (
|
| 247 |
+
f'<a target="_blank" href="{link}" style="color: var(--link-text-color); '
|
| 248 |
+
f'text-decoration: underline; text-decoration-style: dotted;">{name}</a>'
|
| 249 |
+
)
|
| 250 |
+
|
| 251 |
+
|
| 252 |
+
def make_tag_clickable(tag: str) -> str:
|
| 253 |
+
"""Render a method report link as a leaderboard cell.
|
| 254 |
+
|
| 255 |
+
Parameters
|
| 256 |
+
----------
|
| 257 |
+
tag : str
|
| 258 |
+
The stored link, possibly empty or a placeholder.
|
| 259 |
+
|
| 260 |
+
Returns
|
| 261 |
+
-------
|
| 262 |
+
str
|
| 263 |
+
An HTML anchor, or a plain placeholder string.
|
| 264 |
+
|
| 265 |
+
"""
|
| 266 |
+
text = "" if tag is None else str(tag).strip()
|
| 267 |
+
if text in ("", "nan", "Not submitted"):
|
| 268 |
+
return "Not submitted"
|
| 269 |
+
if not text.startswith(("http://", "https://")):
|
| 270 |
+
return "Invalid link"
|
| 271 |
+
return (
|
| 272 |
+
f'<a target="_blank" href="{text}" style="color: var(--link-text-color); '
|
| 273 |
+
f'text-decoration: underline; text-decoration-style: dotted;">link</a>'
|
| 274 |
+
)
|