No description
  • Python 99.6%
  • Shell 0.4%
Find a file
2026-11-26 17:35:21 +01:00
concept_space/v1.0.0 Publish current benchmark and source-only model implementations 2026-11-26 17:35:21 +01:00
examples Publish current benchmark and source-only model implementations 2026-11-26 17:35:21 +01:00
implementations Publish current benchmark and source-only model implementations 2026-11-26 17:35:21 +01:00
level4 Publish current benchmark and source-only model implementations 2026-11-26 17:35:21 +01:00
levels Publish current benchmark and source-only model implementations 2026-11-26 17:35:21 +01:00
.gitignore Publish current benchmark and source-only model implementations 2026-11-26 17:35:21 +01:00
LICENSE.md Publish current benchmark and source-only model implementations 2026-11-26 17:35:21 +01:00
metadata.template.json Publish current benchmark and source-only model implementations 2026-11-26 17:35:21 +01:00
README.md Publish current benchmark and source-only model implementations 2026-11-26 17:35:21 +01:00
requirements.txt Publish current benchmark and source-only model implementations 2026-11-26 17:35:21 +01:00
validate.py Publish current benchmark and source-only model implementations 2026-11-26 17:35:21 +01:00

EHRMENEIA

Model-independent evaluation of longitudinal EHR foundation models. Run your model locally, export the tables below, and use EHRMENEIA to validate inputs, compute metrics and create a ZIP for the benchmark website https://ehrmeneia.upc.edu/. Data and checkpoints stay local.

Level Evaluation
1 Next-event prediction: Top-5/Top-10, macro-AUROC and Average Precision (AP).
2 Future-window event prediction: macro-AUROC, AP and Brier score.
3 Five-year trajectory fidelity: survival, disease incidence and transition JSD.
4 Few-shot prediction from frozen representations: AUROC and AP by task and K.

1. Install

Use Python 3.11 or later. Run commands from the repository root:

python -m venv .venv
. .venv/bin/activate
python -m pip install -r requirements.txt

2. Export your model's inputs

Create a directory such as submission/. Export actual Parquet tables with columns stored as columns, not dataframe indices. Run the levels your model supports. Convert native outputs to canonical concept IDs.

File Required columns Levels
cases.parquet case_id, index_age, followup_days, death_day 1–3
observed_events.parquet case_id, event_order, elapsed_days, concept_id 1–3
context_history.parquet case_id, concept_ids, n_clinical_events (optional local History input) 1
level1_predictions.parquet case_id, concept_id, score 1
generated_trajectories.parquet case_id, trajectory_id, death_day 2–3
generated_events.parquet case_id, trajectory_id, elapsed_days, concept_id 2–3

Use strictly pre-index model context. IDs must agree across tables. Event/death times are positive elapsed days from index; follow-up is nonnegative. Unknown death is null. Observed endpoints cannot exceed follow-up; events cannot follow death. Add a local patient_id column to cases.parquet for patient-level uncertainty; never substitute independent IDs for repeated cases from the same patient.

Level 1. Construct eligible candidate queries with preceding history and an observed next canonical target. Add patient_id (string), index_time (numeric days on a fixed patient clock) and target_event_id (string identifying the source target/time group, not its concept). Fix simultaneous-target ordering before inference, independently of model scores. Simultaneous targets share a target ID. Select cases before running the model:

from levels.level1 import sample_landmarks

selected_cases = sample_landmarks(candidate_cases)
# Run your model on selected_cases and export cases, observed events and scores.

The sampler selects at most 20 distinct targets per patient, stratified over time. index_age is the actual age, not a fixed birthday. The target is the smallest event_order per case. Scores must be finite; larger means more likely. Missing concept scores rank below supplied scores. Each patient has equal total weight within each stratum. Legacy inputs without the three landmark fields retain birthday-based evaluation; use the fields above for repeated sampling.

Levels 2–3. Use index ages 30, 50 and 80, with one case per patient and age. Register every generated trajectory, even if it contains no mapped event. The reference generation setting is 100 futures per case. Level 2 evaluates 30, 90, 180 and 365 days: a positive needs a recorded event in the window; a negative needs follow-up through its end. Other outcomes are indeterminate.

Level 3 requires complete five-year generation or death, and six non-null Boolean columns in cases.parquet: disease_free_E11, disease_free_J44, disease_free_C34, disease_free_F32, disease_free_N17, disease_free_I21. True means no diagnosis in that prefix family, including descendants, at or before index. Unknown history is not false. Declare any observation or death-ascertainment limitations; numerical computability alone does not establish clinical validity.

Metadata. Copy metadata.template.json to submission/metadata.json and complete the applicable sections for website submission. Identify the model and evaluation cohort, declare separation from pretraining, and describe mapping and generation. Unknown counts are null, not zero. Cite pretraining sources as URLs when available. Remove unused optional sections.

If supplying vocabulary_mapping.json, use schema version 1 with native_to_canonical, family_sets, policy descriptions and source URLs. Declare metadata.vocabulary_mapping as {"file":"vocabulary_mapping.json","sha256":"<file SHA-256>"}. Otherwise fill in mapping_coverage. The mapping must contain terminology only.

3. Run

python -m levels.level1 submission/ --output results.json
python -m levels.level2 submission/ --output results.json
python -m levels.level3 submission/ --output results.json

To validate without evaluating, use python validate.py submission/ --level 1 (or 2 or 3).

Levels 1–2 macro-average equally across concepts with both classes observed. AP is non-interpolated average precision. With explicit patient IDs, Levels 1–3 use 1,000 patient-level Bayesian-bootstrap replicates. Level 3 also reports patient-disjoint observed split-half references and transition counts.

4. Level 4: prepare, fit, evaluate

Build representations from events strictly before the anchor timestamp and the one selected anchor event. Exclude every other event at or after that timestamp. For date-only sources, all events on the anchor date tie. Declare deterministic selection for eligible anchors with the same timestamp.

Follow the task definitions in level4/catalogue.json and fixed settings in level4/protocol.json.

File Required columns Created by
level4_cases.parquet task_id, case_id, patient_id, split, followup_days, target_day, death_day You
level4_support.parquet task_id, k, draw, case_id Preparation
level4_runs.parquet task_id, k, draw, status, reason Preparation
level4_predictions.parquet task_id, k, draw, case_id, probability You

Use one case per patient/task, nonempty string IDs and splits adaptation or test. Patient assignment must be consistent across tasks and disjoint between splits. Times are nonnegative days from anchor. Use null for unknown times. Recorded endpoints cannot exceed follow-up or put the target after death. A recorded endpoint within the horizon is positive. Otherwise, cases with unknown or shorter follow-up, or with death within the horizon, are censored and excluded from training and scoring. Death is the endpoint in mortality tasks. A target tied with death counts as positive. Test summaries report censored cases as n_indeterminate.

Add this section to submission/metadata.json:

"level4": {
  "protocol_id": "frozen-linear-v1",
  "backbone_frozen": true,
  "backbone_eval_mode": true,
  "no_future_information": true,
  "representation_method": "Describe how your model's state is extracted"
}
  1. Export level4_cases.parquet following the catalogue.
  2. Run python -m levels.level4 submission/ --prepare to create support sets and the run manifest. Existing manifests are not overwritten.
  3. Extract frozen representations with your model in evaluation mode. Fit a new head for each ready task/K/draw using level4/head.py, then export probabilities for every uncensored test case of that task. Do not tune on test data.
  4. Run python -m levels.level4 submission/ --output results.json.

K is per class: 8, 16, 32, 64, 128, with 20 support draws. Test evaluation requires 20 patients per class. Unsupported settings remain not_estimable. Intervals use 2,000 bootstrap resamples of support-draw scores with the test cohort fixed. Level 4 can run independently of the other levels.

Try the complete synthetic example, without a clinical model:

python -m examples.level4_synthetic /tmp/ehrmeneia-demo

Use a new output directory. This example checks the workflow; it is not a public model submission.

5. Submit results for review

Each run writes aggregate results.json, local Parquet details and results_submission.zip. Level 3 also saves local PNG/SVG figures. The ZIP contains:

  • results.json;
  • vocabulary_mapping.json, when declared;
  • concept_metrics.json, automatically exported from Level 1–2 detail tables;
  • population_curves.json, required for completed Level 3 and exported from its actual level3_curves.parquet.

These aggregates drive the website's plots and concept inspector. Patients, individual predictions, representations, and checkpoints are not included. The administrator validates the ZIP before publication. Results declare benchmark and concept-space version.

If levels were evaluated separately for the same checkpoint, combine them without recomputing metrics:

python -m levels.combine temporal/results.json \
  --level level1=landmarks/results.json --output final/results.json

Submit final/results_submission.zip through Submit for review on the website, with a contact email. Results become public only after approval. A combined result must use the same checkpoint and compatible model, pretraining and mapping metadata.

Article implementations

implementations/ preserves the source-only adapters for CLMBR-T, Delphi, CEHR-GPT and ETHOS. These are optional model-specific workflows, not dependencies of the evaluator. They contain no datasets or checkpoints. Obtain upstream resources separately in a private workspace outside this repository. Set EHRMENEIA_WORKSPACE to its absolute path before running an adapter. The adapters require the corresponding upstream software and dependencies, beyond requirements.txt; inspect their source paths before preparing resources. They preserve the article implementations rather than providing automatic downloads.

Baselines (Levels 1–3)

The references use empirical concept frequencies. Developers supply their inputs and results alongside the other evaluation outputs. Test cases identify patients with patient_id.

Level Additional local inputs
1 context_history.parquet: one row per test case with case_id, concept_ids (list of mapped occurrences) and n_clinical_events (integer).
2 A separate cohort's cases.parquet and observed_events.parquet, using the existing schemas plus patient_id in cases.

For L1, export the clinical events actually retained in the model input strictly before each query, after filtering and truncation. Count each occurrence once, including unmapped events, and exclude padding and technical tokens. Keep duplicates in concept_ids and list only canonical IDs.

History divides each concept's count by n_clinical_events. A zero total gives uniform canonical scores. Ties use canonical CSV order. The bundled adapters export the file automatically. Regenerate older exports to add the total.

For L2, use the same source-cohort eligibility, ages and outcome definitions as test, with disjoint patients. The reference predicts each concept's proportion of positives among determinate outcomes, separately by age and horizon. It assigns that same probability to every test patient in the setting. There is no smoothing; if no reference outcomes are determinate, it uses probability 0.5 and reports the number of affected computable concepts. No test outcomes estimate the rates.

Place context_history.parquet directly in the Level 1 submission directory. For Level 2, place the reference cohort's cases.parquet and observed_events.parquet in submission/reference/. When these inputs are supplied, the normal level commands compute the baselines automatically and attach them before generating the ZIP; no separate baseline command or metadata form is needed.

Level 3 computes the patient-disjoint observed–observed split-half baseline from its existing observed data when patient identity is supplied and resampling is enabled. Supply explicit patient_id to calculate patient-based references. Reference rows remain present with null estimates and zero valid splits when the baseline is not computable; unknown values are never zeros.

The ZIP includes the baseline aggregates produced by the run alongside the other level results. Level 4 uses its own adaptation protocol. Local metric/curve outputs must remain beside results.json; no private histories or reference outcomes enter the ZIP.

The website displays History (L1) or Marginal (L2) within the model row. For L2, constant scores imply AUROC 0.5 and AP equal to test prevalence; Brier is the useful probability-quality comparison. The usual patient Bayesian-bootstrap intervals resample test patients and hold the reference rates fixed. Only aggregate results enter the ZIP; histories, reference patient IDs and outcomes remain local.