Spaces:
Running
Running
Replace S_fair with S_worst (min cohort skill) + show evaluated-user counts per cohort
Browse files- S_worst = per-method minimum headline skill across the four demographic
cohorts (age <40 / 40+, female / male); shown on all views and in /api/data.
- Each cohort view now shows its evaluated-user count above the table.
- Drop the MAPD disparity-ratio fairness computation (all three tracks).
- README.md +4 -3
- app.py +79 -36
- leaderboard_compute.py +66 -70
README.md
CHANGED
|
@@ -21,9 +21,10 @@ dataset.
|
|
| 21 |
|
| 22 |
- `GET /` renders the leaderboard table (HTML).
|
| 23 |
- On first request the app downloads each track's per-method substrate
|
| 24 |
-
(`<track>/<method>.parquet`), reduces it to point skill
|
| 25 |
-
|
| 26 |
-
|
|
|
|
| 27 |
- `GET /health` — liveness + method count.
|
| 28 |
|
| 29 |
There is **no JSON API** — this Space *is* the leaderboard UI.
|
|
|
|
| 21 |
|
| 22 |
- `GET /` renders the leaderboard table (HTML).
|
| 23 |
- On first request the app downloads each track's per-method substrate
|
| 24 |
+
(`<track>/<method>.parquet`), reduces it to point skill scores (overall + per
|
| 25 |
+
demographic cohort; the worst cohort is the S_worst column) + cross-method
|
| 26 |
+
ranks vs each track's baseline using the canonical `openmhc` point-flow
|
| 27 |
+
reducers, and caches the result in-process (per track/cohort, until restart).
|
| 28 |
- `GET /health` — liveness + method count.
|
| 29 |
|
| 30 |
There is **no JSON API** — this Space *is* the leaderboard UI.
|
app.py
CHANGED
|
@@ -9,8 +9,9 @@ The dataset is public, so no token is required. Styling mirrors the public
|
|
| 9 |
MyHeartCounts / OpenMHC site (light theme, red accent). The table is grouped by
|
| 10 |
sub-track (single-day / long-context) and can be filtered by method type. A
|
| 11 |
cohort selector recomputes every track within one demographic cohort (a
|
| 12 |
-
near-median age split at 40, or sex);
|
| 13 |
-
and
|
|
|
|
| 14 |
"""
|
| 15 |
|
| 16 |
from __future__ import annotations
|
|
@@ -26,6 +27,7 @@ from fastapi.responses import FileResponse, HTMLResponse, JSONResponse
|
|
| 26 |
|
| 27 |
from leaderboard_compute import (
|
| 28 |
SUBGROUPS,
|
|
|
|
| 29 |
compute_downstream_rows,
|
| 30 |
compute_forecasting_rows,
|
| 31 |
compute_imputation_rows,
|
|
@@ -45,6 +47,10 @@ app.add_middleware(
|
|
| 45 |
# A merged-bin cohort joins its substrate bin values with "|", e.g.
|
| 46 |
# "age_group:18-29|30-39"; `_rows` parses the key back into (attr, values).
|
| 47 |
COHORT_KEYS = ["all"] + [f"{attr}:{'|'.join(values)}" for attr, values, _ in SUBGROUPS]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
# Compute is mildly expensive (download + reduce); cache per (track, cohort)
|
| 50 |
# in-process. A daemon thread warms every variant at startup (see `_warm_cache`)
|
|
@@ -61,7 +67,7 @@ _IMPUTATION_COLUMNS = [
|
|
| 61 |
("mtype", "Type"),
|
| 62 |
("rank", "R ↓"),
|
| 63 |
("skill", "S ↑"),
|
| 64 |
-
("
|
| 65 |
("activity", "Activity ↑"),
|
| 66 |
("physiology", "Physio. ↑"),
|
| 67 |
("sleep", "Sleep ↑"),
|
|
@@ -80,7 +86,7 @@ _DOWNSTREAM_COLUMNS = [
|
|
| 80 |
("mtype", "Type"),
|
| 81 |
("rank", "R ↓"),
|
| 82 |
("skill", "S ↑"),
|
| 83 |
-
("
|
| 84 |
("demographics", "Demo. ↑"),
|
| 85 |
("conditions", "Medical ↑"),
|
| 86 |
("vitals", "Vitals ↑"),
|
|
@@ -97,8 +103,9 @@ _IMPUTATION_NOTE = (
|
|
| 97 |
"tasks; <b>1 = best</b> (lower is better).<br>"
|
| 98 |
"<b>S</b> (Skill Score) — overall % reduction in reconstruction error vs LOCF "
|
| 99 |
"(paired per-user geometric mean across tasks); higher is better.<br>"
|
| 100 |
-
"<b>
|
| 101 |
-
"(age
|
|
|
|
| 102 |
"<b>Activity / Physio. / Sleep / Workout</b> — per-category skill on that sensor group's "
|
| 103 |
"channels (activity = steps, distance, flights; physiology = heart rate, active energy; "
|
| 104 |
"sleep = asleep / in-bed; workout = the 10 workout-type channels).<br>"
|
|
@@ -115,8 +122,9 @@ _FORECASTING_NOTE = (
|
|
| 115 |
"<b>1 = best</b> (lower is better).<br>"
|
| 116 |
"<b>S</b> (Skill Score) — overall category-balanced % reduction in forecast error vs "
|
| 117 |
"Seasonal Naive (paired per-user geometric mean); higher is better.<br>"
|
| 118 |
-
"<b>
|
| 119 |
-
"(age
|
|
|
|
| 120 |
"<b>Activity / Physio. / Sleep / Workout</b> — per-category skill on that sensor group's "
|
| 121 |
"channels (activity = steps, distance, flights; physiology = heart rate, active energy; "
|
| 122 |
"sleep = asleep / in-bed; workout = the 10 workout-type channels).<br>"
|
|
@@ -131,8 +139,9 @@ _DOWNSTREAM_NOTE = (
|
|
| 131 |
"<b>1 = best</b> (lower is better).<br>"
|
| 132 |
"<b>S</b> (Skill Score) — category-balanced % improvement over Linear across tasks "
|
| 133 |
"(per-task AUPRC / Spearman / Pearson, paired-bootstrap mean); higher is better.<br>"
|
| 134 |
-
"<b>
|
| 135 |
-
"(age
|
|
|
|
| 136 |
"<b>Demo. / Medical / Vitals / Mental / Lifestyle</b> — per-category skill on that outcome "
|
| 137 |
"group's tasks (Demographics; Medical Conditions & Risk; Vitals & Blood Biomarkers; "
|
| 138 |
"Mental Well-Being; Sleep & Lifestyle), category-balanced like S.<br>"
|
|
@@ -153,9 +162,10 @@ def _column_tips(baseline: str) -> dict[str, str]:
|
|
| 153 |
f"Skill Score (S): overall % reduction in error vs the {baseline} baseline "
|
| 154 |
"(paired per-user geometric mean); higher is better."
|
| 155 |
),
|
| 156 |
-
"
|
| 157 |
-
f"
|
| 158 |
-
f"
|
|
|
|
| 159 |
),
|
| 160 |
"activity": f"Skill on activity channels — steps, distance, flights — vs {baseline}.",
|
| 161 |
"physiology": f"Skill on physiology channels — heart rate, active energy — vs {baseline}.",
|
|
@@ -304,6 +314,9 @@ td.type{color:var(--muted);}
|
|
| 304 |
tr.sec td{font-weight:800;font-size:15px;padding-top:24px;padding-bottom:10px;border-bottom:1px solid var(--line);background:#fff;}
|
| 305 |
|
| 306 |
.note{color:var(--muted);font-size:13px;margin-top:18px;line-height:1.6;}
|
|
|
|
|
|
|
|
|
|
| 307 |
.err{color:var(--accent);background:#fdecef;border:1px solid #f6c9d2;padding:16px 18px;border-radius:12px;white-space:pre-wrap;}
|
| 308 |
code{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.9em;color:#3f4754;}
|
| 309 |
|
|
@@ -378,8 +391,8 @@ thead th[data-tip]{position:relative;}
|
|
| 378 |
that adds your per-user evaluation substrate
|
| 379 |
(<code><track>/<method>.parquet</code>) plus a small
|
| 380 |
<code><method>.meta.json</code> sidecar. Produce the substrate by running the OpenMHC
|
| 381 |
-
eval with <code>output_dir=…</code>; the maintainers recompute the skill,
|
| 382 |
-
and
|
| 383 |
<a href="%%SUBMIT%%" target="_blank" rel="noopener">step-by-step submission guide</a>
|
| 384 |
for the exact file schema.</p>
|
| 385 |
</div>
|
|
@@ -544,7 +557,7 @@ def _warm_cache() -> None:
|
|
| 544 |
# `fallback` is a diagnostic, not a score, so it is left out and renders plain on every
|
| 545 |
# track. (Heatmapping it shades the column only when there's a range of values — a track
|
| 546 |
# with a non-zero fallback would get a coloured column while all-zero tracks would not.)
|
| 547 |
-
HIGHER_BETTER = {"skill", "
|
| 548 |
"demographics", "conditions", "vitals", "mental", "lifestyle"}
|
| 549 |
LOWER_BETTER = {"rank"}
|
| 550 |
_HEAT_RGB = (59, 130, 246)
|
|
@@ -701,28 +714,46 @@ def _table(rows: list[dict], columns: list, subtracks: list, tips: dict) -> str:
|
|
| 701 |
# Appended to every track's metric legend — describes the cohort selector.
|
| 702 |
_COHORT_NOTE = (
|
| 703 |
"<br><b>Cohort</b> — the selector above recomputes R, S, and the per-category "
|
| 704 |
-
"skills within one demographic cohort (a near-median age split at 40, or sex)
|
| 705 |
-
"
|
| 706 |
-
"
|
| 707 |
-
"population, so scores are noisier;
|
| 708 |
-
"within the cohort) drop from the
|
|
|
|
| 709 |
)
|
| 710 |
|
| 711 |
|
| 712 |
-
def
|
| 713 |
-
"""
|
| 714 |
-
|
| 715 |
-
|
| 716 |
-
|
| 717 |
-
|
| 718 |
-
|
| 719 |
-
|
| 720 |
-
|
| 721 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 722 |
|
| 723 |
|
| 724 |
def _render_section(cfg: dict, active: bool) -> str:
|
| 725 |
views = []
|
|
|
|
| 726 |
for cohort in COHORT_KEYS:
|
| 727 |
rows, error = _rows(cfg["key"], cfg["compute"], cohort)
|
| 728 |
if error is not None:
|
|
@@ -730,7 +761,19 @@ def _render_section(cfg: dict, active: bool) -> str:
|
|
| 730 |
elif not rows:
|
| 731 |
body = '<div class="err">No methods found in the substrate dataset.</div>'
|
| 732 |
else:
|
| 733 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 734 |
hidden_view = "" if cohort == "all" else " hidden"
|
| 735 |
views.append(
|
| 736 |
f'<div class="cohortview" data-cohort="{html.escape(cohort)}"{hidden_view}>{body}</div>'
|
|
@@ -850,10 +893,10 @@ def _track_payload(cfg: dict, rows: list[dict] | None, error: str | None) -> dic
|
|
| 850 |
|
| 851 |
@app.get("/api/data")
|
| 852 |
def api_data() -> JSONResponse:
|
| 853 |
-
payload = {
|
| 854 |
-
|
| 855 |
-
|
| 856 |
-
|
| 857 |
return JSONResponse(payload)
|
| 858 |
|
| 859 |
|
|
|
|
| 9 |
MyHeartCounts / OpenMHC site (light theme, red accent). The table is grouped by
|
| 10 |
sub-track (single-day / long-context) and can be filtered by method type. A
|
| 11 |
cohort selector recomputes every track within one demographic cohort (a
|
| 12 |
+
near-median age split at 40, or sex); each view shows the cohort's
|
| 13 |
+
evaluated-user count, and the S_worst column is the per-method minimum cohort
|
| 14 |
+
skill across the four cohorts (the worst-served subgroup).
|
| 15 |
"""
|
| 16 |
|
| 17 |
from __future__ import annotations
|
|
|
|
| 27 |
|
| 28 |
from leaderboard_compute import (
|
| 29 |
SUBGROUPS,
|
| 30 |
+
cohort_user_counts,
|
| 31 |
compute_downstream_rows,
|
| 32 |
compute_forecasting_rows,
|
| 33 |
compute_imputation_rows,
|
|
|
|
| 47 |
# A merged-bin cohort joins its substrate bin values with "|", e.g.
|
| 48 |
# "age_group:18-29|30-39"; `_rows` parses the key back into (attr, values).
|
| 49 |
COHORT_KEYS = ["all"] + [f"{attr}:{'|'.join(values)}" for attr, values, _ in SUBGROUPS]
|
| 50 |
+
# cohort key -> label shown next to the evaluated-user count above each table.
|
| 51 |
+
COHORT_LABELS = {"all": "All participants"} | {
|
| 52 |
+
f"{attr}:{'|'.join(values)}": label for attr, values, label in SUBGROUPS
|
| 53 |
+
}
|
| 54 |
|
| 55 |
# Compute is mildly expensive (download + reduce); cache per (track, cohort)
|
| 56 |
# in-process. A daemon thread warms every variant at startup (see `_warm_cache`)
|
|
|
|
| 67 |
("mtype", "Type"),
|
| 68 |
("rank", "R ↓"),
|
| 69 |
("skill", "S ↑"),
|
| 70 |
+
("worst_group", "S_worst ↑"),
|
| 71 |
("activity", "Activity ↑"),
|
| 72 |
("physiology", "Physio. ↑"),
|
| 73 |
("sleep", "Sleep ↑"),
|
|
|
|
| 86 |
("mtype", "Type"),
|
| 87 |
("rank", "R ↓"),
|
| 88 |
("skill", "S ↑"),
|
| 89 |
+
("worst_group", "S_worst ↑"),
|
| 90 |
("demographics", "Demo. ↑"),
|
| 91 |
("conditions", "Medical ↑"),
|
| 92 |
("vitals", "Vitals ↑"),
|
|
|
|
| 103 |
"tasks; <b>1 = best</b> (lower is better).<br>"
|
| 104 |
"<b>S</b> (Skill Score) — overall % reduction in reconstruction error vs LOCF "
|
| 105 |
"(paired per-user geometric mean across tasks); higher is better.<br>"
|
| 106 |
+
"<b>S_worst</b> (Worst-subgroup skill) — the method's lowest skill score across the four "
|
| 107 |
+
"demographic cohorts (age <40 / 40+, female / male): its performance for the "
|
| 108 |
+
"worst-served subgroup; higher is better.<br>"
|
| 109 |
"<b>Activity / Physio. / Sleep / Workout</b> — per-category skill on that sensor group's "
|
| 110 |
"channels (activity = steps, distance, flights; physiology = heart rate, active energy; "
|
| 111 |
"sleep = asleep / in-bed; workout = the 10 workout-type channels).<br>"
|
|
|
|
| 122 |
"<b>1 = best</b> (lower is better).<br>"
|
| 123 |
"<b>S</b> (Skill Score) — overall category-balanced % reduction in forecast error vs "
|
| 124 |
"Seasonal Naive (paired per-user geometric mean); higher is better.<br>"
|
| 125 |
+
"<b>S_worst</b> (Worst-subgroup skill) — the method's lowest skill score across the four "
|
| 126 |
+
"demographic cohorts (age <40 / 40+, female / male): its performance for the "
|
| 127 |
+
"worst-served subgroup; higher is better.<br>"
|
| 128 |
"<b>Activity / Physio. / Sleep / Workout</b> — per-category skill on that sensor group's "
|
| 129 |
"channels (activity = steps, distance, flights; physiology = heart rate, active energy; "
|
| 130 |
"sleep = asleep / in-bed; workout = the 10 workout-type channels).<br>"
|
|
|
|
| 139 |
"<b>1 = best</b> (lower is better).<br>"
|
| 140 |
"<b>S</b> (Skill Score) — category-balanced % improvement over Linear across tasks "
|
| 141 |
"(per-task AUPRC / Spearman / Pearson, paired-bootstrap mean); higher is better.<br>"
|
| 142 |
+
"<b>S_worst</b> (Worst-subgroup skill) — the method's lowest skill score across the four "
|
| 143 |
+
"demographic cohorts (age <40 / 40+, female / male): its performance for the "
|
| 144 |
+
"worst-served subgroup; higher is better.<br>"
|
| 145 |
"<b>Demo. / Medical / Vitals / Mental / Lifestyle</b> — per-category skill on that outcome "
|
| 146 |
"group's tasks (Demographics; Medical Conditions & Risk; Vitals & Blood Biomarkers; "
|
| 147 |
"Mental Well-Being; Sleep & Lifestyle), category-balanced like S.<br>"
|
|
|
|
| 162 |
f"Skill Score (S): overall % reduction in error vs the {baseline} baseline "
|
| 163 |
"(paired per-user geometric mean); higher is better."
|
| 164 |
),
|
| 165 |
+
"worst_group": (
|
| 166 |
+
f"Worst-subgroup skill (S_worst): the minimum of the method's skill score vs "
|
| 167 |
+
f"{baseline} across the four demographic cohorts (age < 40, age 40+, female, "
|
| 168 |
+
f"male) — its performance for the worst-served subgroup; higher is better."
|
| 169 |
),
|
| 170 |
"activity": f"Skill on activity channels — steps, distance, flights — vs {baseline}.",
|
| 171 |
"physiology": f"Skill on physiology channels — heart rate, active energy — vs {baseline}.",
|
|
|
|
| 314 |
tr.sec td{font-weight:800;font-size:15px;padding-top:24px;padding-bottom:10px;border-bottom:1px solid var(--line);background:#fff;}
|
| 315 |
|
| 316 |
.note{color:var(--muted);font-size:13px;margin-top:18px;line-height:1.6;}
|
| 317 |
+
/* evaluated-user count above each cohort's table */
|
| 318 |
+
.cohort-meta{font-size:13px;color:var(--muted);margin:0 0 10px 2px;}
|
| 319 |
+
.cohort-meta b{color:var(--fg);font-variant-numeric:tabular-nums;}
|
| 320 |
.err{color:var(--accent);background:#fdecef;border:1px solid #f6c9d2;padding:16px 18px;border-radius:12px;white-space:pre-wrap;}
|
| 321 |
code{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.9em;color:#3f4754;}
|
| 322 |
|
|
|
|
| 391 |
that adds your per-user evaluation substrate
|
| 392 |
(<code><track>/<method>.parquet</code>) plus a small
|
| 393 |
<code><method>.meta.json</code> sidecar. Produce the substrate by running the OpenMHC
|
| 394 |
+
eval with <code>output_dir=…</code>; the maintainers recompute the skill,
|
| 395 |
+
rank, and worst-subgroup scores from it. See the
|
| 396 |
<a href="%%SUBMIT%%" target="_blank" rel="noopener">step-by-step submission guide</a>
|
| 397 |
for the exact file schema.</p>
|
| 398 |
</div>
|
|
|
|
| 557 |
# `fallback` is a diagnostic, not a score, so it is left out and renders plain on every
|
| 558 |
# track. (Heatmapping it shades the column only when there's a range of values — a track
|
| 559 |
# with a non-zero fallback would get a coloured column while all-zero tracks would not.)
|
| 560 |
+
HIGHER_BETTER = {"skill", "worst_group", "activity", "physiology", "sleep", "workout", "semantic",
|
| 561 |
"demographics", "conditions", "vitals", "mental", "lifestyle"}
|
| 562 |
LOWER_BETTER = {"rank"}
|
| 563 |
_HEAT_RGB = (59, 130, 246)
|
|
|
|
| 714 |
# Appended to every track's metric legend — describes the cohort selector.
|
| 715 |
_COHORT_NOTE = (
|
| 716 |
"<br><b>Cohort</b> — the selector above recomputes R, S, and the per-category "
|
| 717 |
+
"skills within one demographic cohort (a near-median age split at 40, or sex); "
|
| 718 |
+
"the count above each table is the cohort's evaluated users. S_worst is the "
|
| 719 |
+
"minimum cohort skill across the four cohorts, so it reads the same in every "
|
| 720 |
+
"view. Cohorts are smaller than the full population, so scores are noisier; "
|
| 721 |
+
"tasks without enough users (or degenerate within the cohort) drop from the "
|
| 722 |
+
"aggregates."
|
| 723 |
)
|
| 724 |
|
| 725 |
|
| 726 |
+
def _worst_group(cfg: dict) -> dict[str, float | None] | None:
|
| 727 |
+
"""Per-method minimum headline skill across the four demographic cohorts.
|
| 728 |
+
|
| 729 |
+
Returns ``None`` (S_worst renders as missing) when any cohort variant
|
| 730 |
+
failed. A method whose skill is missing in any cohort maps to ``None`` —
|
| 731 |
+
its worst cohort is unknown, not the min of the cohorts that did compute.
|
| 732 |
+
"""
|
| 733 |
+
per_cohort: list[dict[str, float | None]] = []
|
| 734 |
+
for cohort in COHORT_KEYS[1:]:
|
| 735 |
+
rows, error = _rows(cfg["key"], cfg["compute"], cohort)
|
| 736 |
+
if error is not None or not rows:
|
| 737 |
+
return None
|
| 738 |
+
per_cohort.append({r["method"]: r.get("skill") for r in rows})
|
| 739 |
+
worst: dict[str, float | None] = {}
|
| 740 |
+
for m in set().union(*per_cohort):
|
| 741 |
+
vals = [d.get(m) for d in per_cohort]
|
| 742 |
+
worst[m] = None if any(v is None for v in vals) else min(vals)
|
| 743 |
+
return worst
|
| 744 |
+
|
| 745 |
+
|
| 746 |
+
def _augment_worst(cfg: dict, rows: list[dict] | None) -> list[dict] | None:
|
| 747 |
+
"""Attach the S_worst column; identical values on every cohort view."""
|
| 748 |
+
if rows is None:
|
| 749 |
+
return None
|
| 750 |
+
worst = _worst_group(cfg) or {}
|
| 751 |
+
return [dict(r, worst_group=worst.get(r["method"])) for r in rows]
|
| 752 |
|
| 753 |
|
| 754 |
def _render_section(cfg: dict, active: bool) -> str:
|
| 755 |
views = []
|
| 756 |
+
counts: dict[str, int] | None = None
|
| 757 |
for cohort in COHORT_KEYS:
|
| 758 |
rows, error = _rows(cfg["key"], cfg["compute"], cohort)
|
| 759 |
if error is not None:
|
|
|
|
| 761 |
elif not rows:
|
| 762 |
body = '<div class="err">No methods found in the substrate dataset.</div>'
|
| 763 |
else:
|
| 764 |
+
if counts is None:
|
| 765 |
+
# substrate is cached by the successful compute above, so this
|
| 766 |
+
# cannot re-download; only computed when a table renders.
|
| 767 |
+
counts = cohort_user_counts(cfg["key"])
|
| 768 |
+
n = counts.get(cohort)
|
| 769 |
+
meta = (
|
| 770 |
+
f'<p class="cohort-meta">{html.escape(COHORT_LABELS.get(cohort, cohort))}'
|
| 771 |
+
f" · <b>{n:,}</b> users evaluated</p>"
|
| 772 |
+
if n is not None
|
| 773 |
+
else ""
|
| 774 |
+
)
|
| 775 |
+
rows = _augment_worst(cfg, rows)
|
| 776 |
+
body = meta + _table(rows, cfg["columns"], cfg["subtracks"], cfg["tips"])
|
| 777 |
hidden_view = "" if cohort == "all" else " hidden"
|
| 778 |
views.append(
|
| 779 |
f'<div class="cohortview" data-cohort="{html.escape(cohort)}"{hidden_view}>{body}</div>'
|
|
|
|
| 893 |
|
| 894 |
@app.get("/api/data")
|
| 895 |
def api_data() -> JSONResponse:
|
| 896 |
+
payload = {}
|
| 897 |
+
for cfg in TRACKS:
|
| 898 |
+
rows, error = _rows(cfg["key"], cfg["compute"])
|
| 899 |
+
payload[cfg["key"]] = _track_payload(cfg, _augment_worst(cfg, rows), error)
|
| 900 |
return JSONResponse(payload)
|
| 901 |
|
| 902 |
|
leaderboard_compute.py
CHANGED
|
@@ -2,8 +2,7 @@
|
|
| 2 |
|
| 3 |
Downloads each method's per-user error substrate from the OpenMHC leaderboard
|
| 4 |
dataset, then reuses the canonical point-flow reducers from ``openmhc`` to
|
| 5 |
-
produce paired skill scores
|
| 6 |
-
fair skill scores. No bootstrap (point only).
|
| 7 |
|
| 8 |
LOCF is the Track-2 baseline, so when it is the only method present the skill
|
| 9 |
table is empty by construction (baseline-vs-self) — the baseline row is emitted
|
|
@@ -23,12 +22,11 @@ DATASET_REPO = "MyHeartCounts/OpenMHC-leaderboard-data"
|
|
| 23 |
BASELINE = "locf"
|
| 24 |
|
| 25 |
# Demographic cohorts selectable on the board: (attr, substrate bin values, label).
|
| 26 |
-
# Skill/rank recompute within one cohort;
|
| 27 |
-
#
|
| 28 |
-
# merging the substrate's baked decade bins (<40 vs 40+ ≈ 917 vs
|
| 29 |
-
# users) — raw ages are not in the substrate, so only bin unions
|
| 30 |
-
# The tiny "unknown" bins are not selectable
|
| 31 |
-
# the full subgroup frame).
|
| 32 |
SUBGROUPS = [
|
| 33 |
("age_group", ("18-29", "30-39"), "Age < 40"),
|
| 34 |
("age_group", ("40-49", "50-59", "60+"), "Age 40+"),
|
|
@@ -45,17 +43,6 @@ SUBGROUP_SCOPES = {
|
|
| 45 |
"cat:workouts": "workout",
|
| 46 |
"semantic": "semantic",
|
| 47 |
}
|
| 48 |
-
# Columns identifying one (method, task, subgroup) cell. The fairness reducer
|
| 49 |
-
# consumes per-cell MEAN errors, not raw per-user rows.
|
| 50 |
-
PER_CELL_COLS = [
|
| 51 |
-
"method",
|
| 52 |
-
"scenario",
|
| 53 |
-
"channel",
|
| 54 |
-
"channel_type",
|
| 55 |
-
"subgroup_attr",
|
| 56 |
-
"subgroup_value",
|
| 57 |
-
]
|
| 58 |
-
|
| 59 |
# Hardcoded HF model links, keyed by internal method id. Only methods with a
|
| 60 |
# published checkpoint appear here — statistical baselines (locf / mean / mode /
|
| 61 |
# linear / temporal_* / personalized_*) have none, and the forecasting (-fc)
|
|
@@ -135,15 +122,12 @@ def compute_imputation_rows(subgroup: tuple[str, str] | None = None) -> list[dic
|
|
| 135 |
``subgroup=(attr, values)`` — e.g. ``("sex", ("female",))`` or a merged-bin
|
| 136 |
cohort ``("age_group", ("18-29", "30-39"))`` — restricts skill and rank to
|
| 137 |
those bins' per-user cells (the substrate bakes per-user rows per bin).
|
| 138 |
-
Fairness compares errors *across* cohorts, so it is undefined inside one and
|
| 139 |
-
comes back ``None``.
|
| 140 |
"""
|
| 141 |
from imputation_evaluation.evaluation.bootstrap_skill_rank import (
|
| 142 |
compute_per_task_paired_R,
|
| 143 |
)
|
| 144 |
from imputation_evaluation.evaluation.paper_metrics_core import (
|
| 145 |
compute_average_rankings,
|
| 146 |
-
compute_fair_skill_scores,
|
| 147 |
compute_skill_scores,
|
| 148 |
)
|
| 149 |
|
|
@@ -170,14 +154,6 @@ def compute_imputation_rows(subgroup: tuple[str, str] | None = None) -> list[dic
|
|
| 170 |
per_task_r = compute_per_task_paired_R(cell, baseline_method=BASELINE)
|
| 171 |
skill = compute_skill_scores(per_task_r, mode="paired") # [method, scope, skill_score, ...]
|
| 172 |
ranks = compute_average_rankings(cell) # [method, scope, avg_rank, ...]
|
| 173 |
-
if subgroup is None:
|
| 174 |
-
# Disparity-ratio fair skill (MAPD across age_group + sex). The reducer
|
| 175 |
-
# expects per-cell mean errors; feeding raw per-user rows triggers a
|
| 176 |
-
# cartesian-merge blow-up, so collapse users to the cell mean first.
|
| 177 |
-
per_cell = df.groupby(PER_CELL_COLS, observed=True)["E"].mean().reset_index()
|
| 178 |
-
fair = compute_fair_skill_scores(per_cell, baseline_method=BASELINE) # [method, scope, fair_skill_score, ...]
|
| 179 |
-
else:
|
| 180 |
-
fair = None # cross-cohort disparity — undefined within a single cohort
|
| 181 |
|
| 182 |
def skill_at(method: str, scope: str) -> float | None:
|
| 183 |
hit = skill[(skill["method"] == method) & (skill["scope"] == scope)]
|
|
@@ -189,14 +165,6 @@ def compute_imputation_rows(subgroup: tuple[str, str] | None = None) -> list[dic
|
|
| 189 |
hit = ranks[(ranks["method"] == method) & (ranks["scope"] == scope)]
|
| 190 |
return _num(hit["avg_rank"].iloc[0]) if not hit.empty else None
|
| 191 |
|
| 192 |
-
def fair_at(method: str, scope: str) -> float | None:
|
| 193 |
-
if fair is None:
|
| 194 |
-
return None
|
| 195 |
-
hit = fair[(fair["method"] == method) & (fair["scope"] == scope)]
|
| 196 |
-
if not hit.empty:
|
| 197 |
-
return _num(hit["fair_skill_score"].iloc[0])
|
| 198 |
-
return 0.0 if method == BASELINE else None # baseline-vs-self -> 0
|
| 199 |
-
|
| 200 |
rows = []
|
| 201 |
for m in methods:
|
| 202 |
name, mtype, submitter, subtrack, fallback = read_method_meta(root, "imputation", m)
|
|
@@ -208,7 +176,6 @@ def compute_imputation_rows(subgroup: tuple[str, str] | None = None) -> list[dic
|
|
| 208 |
"subtrack": subtrack,
|
| 209 |
"model_url": MODEL_URLS.get(m),
|
| 210 |
"skill": skill_at(m, HEADLINE_SCOPE),
|
| 211 |
-
"fair_skill": fair_at(m, HEADLINE_SCOPE),
|
| 212 |
"rank": rank_at(m, HEADLINE_SCOPE),
|
| 213 |
"fallback": fallback,
|
| 214 |
**{col: skill_at(m, scope) for scope, col in SUBGROUP_SCOPES.items()},
|
|
@@ -246,9 +213,9 @@ def _load_demographics() -> dict[str, dict[str, str]]:
|
|
| 246 |
The forecasting per-user substrate carries no demographic columns, but every
|
| 247 |
forecasting user is also in the imputation substrate (which bakes per-user
|
| 248 |
``age_group`` / ``sex`` subgroup rows under the canonical 18/30/40/50/60 age
|
| 249 |
-
bins). Reusing that partition
|
| 250 |
-
|
| 251 |
-
with no extra artifact. Cached in-process.
|
| 252 |
"""
|
| 253 |
from huggingface_hub import hf_hub_download
|
| 254 |
|
|
@@ -273,21 +240,17 @@ def compute_forecasting_rows(subgroup: tuple[str, str] | None = None) -> list[di
|
|
| 273 |
|
| 274 |
``subgroup=(attr, values)`` restricts skill and rank to users whose bin (from
|
| 275 |
the shared imputation demographics — every forecasting user is in it) is in
|
| 276 |
-
``values``.
|
| 277 |
"""
|
| 278 |
from forecasting_evaluation.metrics import metric_spec as spec
|
| 279 |
-
from forecasting_evaluation.metrics.fair_skill_score import (
|
| 280 |
-
compute_fair_skill_scores_from_errors,
|
| 281 |
-
)
|
| 282 |
from forecasting_evaluation.metrics.grouped_metric_rank_summary import (
|
| 283 |
build_grouped_metric_rank_tables,
|
| 284 |
)
|
| 285 |
-
from forecasting_evaluation.metrics.per_user_errors import to_error_df
|
| 286 |
from forecasting_evaluation.metrics.skill_score_summary import compute_skill_score_tables
|
| 287 |
|
| 288 |
df, root = load_substrate("forecasting")
|
| 289 |
-
demo = _load_demographics()
|
| 290 |
if subgroup is not None:
|
|
|
|
| 291 |
attr, values = subgroup
|
| 292 |
cohort = {uid for uid, d in demo.items() if d.get(attr) in values}
|
| 293 |
df = df[df["user_id"].astype(str).isin(cohort)].copy()
|
|
@@ -326,16 +289,6 @@ def compute_forecasting_rows(subgroup: tuple[str, str] | None = None) -> list[di
|
|
| 326 |
rank_long["model"] = rank_long["model"].astype(str)
|
| 327 |
overall_rank = rank_long[rank_long["scope"] == "overall"].set_index("model")["rank"]
|
| 328 |
|
| 329 |
-
if subgroup is None:
|
| 330 |
-
# Disparity-ratio (MAPD) fair skill across age_group + sex. Demographics come
|
| 331 |
-
# from the imputation substrate (same user->subgroup partition); the reducer
|
| 332 |
-
# is the canonical forecasting one (point estimate == leaderboard value).
|
| 333 |
-
err = to_error_df(df, user_col="user_id")
|
| 334 |
-
fair = compute_fair_skill_scores_from_errors(err, demo, baseline_method=FC_BASELINE)
|
| 335 |
-
fair_overall = fair[fair["scope"] == "overall"].set_index("model")["fair_skill_score"]
|
| 336 |
-
else:
|
| 337 |
-
fair_overall = None # cross-cohort disparity — undefined within a single cohort
|
| 338 |
-
|
| 339 |
rows = []
|
| 340 |
for m in methods:
|
| 341 |
name, mtype, submitter, subtrack, fallback = read_method_meta(root, "forecasting", m)
|
|
@@ -348,7 +301,6 @@ def compute_forecasting_rows(subgroup: tuple[str, str] | None = None) -> list[di
|
|
| 348 |
"subtrack": subtrack,
|
| 349 |
"model_url": FC_MODEL_URLS.get(m),
|
| 350 |
"skill": _num(srow["overall_score"]) if srow is not None else None,
|
| 351 |
-
"fair_skill": _num(fair_overall.get(m)) if fair_overall is not None else None,
|
| 352 |
"rank": _num(overall_rank.get(m)),
|
| 353 |
"activity": _num(srow["activity_score"]) if srow is not None else None,
|
| 354 |
"physiology": _num(srow["physiology_score"]) if srow is not None else None,
|
|
@@ -393,18 +345,17 @@ DOWNSTREAM_META = {
|
|
| 393 |
def compute_downstream_rows(subgroup: tuple[str, str] | None = None) -> list[dict]:
|
| 394 |
"""Return leaderboard rows (sorted by skill desc) for the Track-1 (predictive tasks) track.
|
| 395 |
|
| 396 |
-
Reduces the per-user-pairs substrate live — point skill / rank
|
| 397 |
-
|
| 398 |
-
|
| 399 |
-
|
| 400 |
-
|
| 401 |
|
| 402 |
``subgroup=(attr, values)`` restricts the reduction to users in any of those bins
|
| 403 |
-
(the substrate's demographic cells give the membership)
|
| 404 |
-
rows are passed on
|
| 405 |
-
|
| 406 |
-
|
| 407 |
-
NaN metrics and drop from the aggregates via the reducer's finite-guards.
|
| 408 |
"""
|
| 409 |
from downstream_evaluation.evaluation.bootstrap_skill_rank import reduce_substrate_to_point
|
| 410 |
|
|
@@ -429,7 +380,6 @@ def compute_downstream_rows(subgroup: tuple[str, str] | None = None) -> list[dic
|
|
| 429 |
"subtrack": subtrack,
|
| 430 |
"model_url": model_url,
|
| 431 |
"skill": _num(skill.get("Overall")),
|
| 432 |
-
"fair_skill": None if subgroup is not None else _num(point[m]["fair_skill"]),
|
| 433 |
"rank": _num(point[m]["rank"].get("Overall")),
|
| 434 |
"fallback": fallback,
|
| 435 |
**{col: _num(skill.get(scope)) for scope, col in DOWNSTREAM_SUBGROUP_SCOPES.items()},
|
|
@@ -438,6 +388,52 @@ def compute_downstream_rows(subgroup: tuple[str, str] | None = None) -> list[dic
|
|
| 438 |
return rows
|
| 439 |
|
| 440 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 441 |
if __name__ == "__main__":
|
| 442 |
import json
|
| 443 |
|
|
|
|
| 2 |
|
| 3 |
Downloads each method's per-user error substrate from the OpenMHC leaderboard
|
| 4 |
dataset, then reuses the canonical point-flow reducers from ``openmhc`` to
|
| 5 |
+
produce paired skill scores and cross-method ranks. No bootstrap (point only).
|
|
|
|
| 6 |
|
| 7 |
LOCF is the Track-2 baseline, so when it is the only method present the skill
|
| 8 |
table is empty by construction (baseline-vs-self) — the baseline row is emitted
|
|
|
|
| 22 |
BASELINE = "locf"
|
| 23 |
|
| 24 |
# Demographic cohorts selectable on the board: (attr, substrate bin values, label).
|
| 25 |
+
# Skill/rank recompute within one cohort; the board's S_worst column is the
|
| 26 |
+
# per-method minimum cohort skill across these four cohorts. Age is a near-median
|
| 27 |
+
# split built by merging the substrate's baked decade bins (<40 vs 40+ ≈ 917 vs
|
| 28 |
+
# 922 imputation users) — raw ages are not in the substrate, so only bin unions
|
| 29 |
+
# are possible. The tiny "unknown" bins are not selectable.
|
|
|
|
| 30 |
SUBGROUPS = [
|
| 31 |
("age_group", ("18-29", "30-39"), "Age < 40"),
|
| 32 |
("age_group", ("40-49", "50-59", "60+"), "Age 40+"),
|
|
|
|
| 43 |
"cat:workouts": "workout",
|
| 44 |
"semantic": "semantic",
|
| 45 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
# Hardcoded HF model links, keyed by internal method id. Only methods with a
|
| 47 |
# published checkpoint appear here — statistical baselines (locf / mean / mode /
|
| 48 |
# linear / temporal_* / personalized_*) have none, and the forecasting (-fc)
|
|
|
|
| 122 |
``subgroup=(attr, values)`` — e.g. ``("sex", ("female",))`` or a merged-bin
|
| 123 |
cohort ``("age_group", ("18-29", "30-39"))`` — restricts skill and rank to
|
| 124 |
those bins' per-user cells (the substrate bakes per-user rows per bin).
|
|
|
|
|
|
|
| 125 |
"""
|
| 126 |
from imputation_evaluation.evaluation.bootstrap_skill_rank import (
|
| 127 |
compute_per_task_paired_R,
|
| 128 |
)
|
| 129 |
from imputation_evaluation.evaluation.paper_metrics_core import (
|
| 130 |
compute_average_rankings,
|
|
|
|
| 131 |
compute_skill_scores,
|
| 132 |
)
|
| 133 |
|
|
|
|
| 154 |
per_task_r = compute_per_task_paired_R(cell, baseline_method=BASELINE)
|
| 155 |
skill = compute_skill_scores(per_task_r, mode="paired") # [method, scope, skill_score, ...]
|
| 156 |
ranks = compute_average_rankings(cell) # [method, scope, avg_rank, ...]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 157 |
|
| 158 |
def skill_at(method: str, scope: str) -> float | None:
|
| 159 |
hit = skill[(skill["method"] == method) & (skill["scope"] == scope)]
|
|
|
|
| 165 |
hit = ranks[(ranks["method"] == method) & (ranks["scope"] == scope)]
|
| 166 |
return _num(hit["avg_rank"].iloc[0]) if not hit.empty else None
|
| 167 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
rows = []
|
| 169 |
for m in methods:
|
| 170 |
name, mtype, submitter, subtrack, fallback = read_method_meta(root, "imputation", m)
|
|
|
|
| 176 |
"subtrack": subtrack,
|
| 177 |
"model_url": MODEL_URLS.get(m),
|
| 178 |
"skill": skill_at(m, HEADLINE_SCOPE),
|
|
|
|
| 179 |
"rank": rank_at(m, HEADLINE_SCOPE),
|
| 180 |
"fallback": fallback,
|
| 181 |
**{col: skill_at(m, scope) for scope, col in SUBGROUP_SCOPES.items()},
|
|
|
|
| 213 |
The forecasting per-user substrate carries no demographic columns, but every
|
| 214 |
forecasting user is also in the imputation substrate (which bakes per-user
|
| 215 |
``age_group`` / ``sex`` subgroup rows under the canonical 18/30/40/50/60 age
|
| 216 |
+
bins). Reusing that partition gives the forecasting cohort views (and
|
| 217 |
+
user counts) the *identical* user->subgroup mapping as the imputation
|
| 218 |
+
cohorts, with no extra artifact. Cached in-process.
|
| 219 |
"""
|
| 220 |
from huggingface_hub import hf_hub_download
|
| 221 |
|
|
|
|
| 240 |
|
| 241 |
``subgroup=(attr, values)`` restricts skill and rank to users whose bin (from
|
| 242 |
the shared imputation demographics — every forecasting user is in it) is in
|
| 243 |
+
``values``.
|
| 244 |
"""
|
| 245 |
from forecasting_evaluation.metrics import metric_spec as spec
|
|
|
|
|
|
|
|
|
|
| 246 |
from forecasting_evaluation.metrics.grouped_metric_rank_summary import (
|
| 247 |
build_grouped_metric_rank_tables,
|
| 248 |
)
|
|
|
|
| 249 |
from forecasting_evaluation.metrics.skill_score_summary import compute_skill_score_tables
|
| 250 |
|
| 251 |
df, root = load_substrate("forecasting")
|
|
|
|
| 252 |
if subgroup is not None:
|
| 253 |
+
demo = _load_demographics()
|
| 254 |
attr, values = subgroup
|
| 255 |
cohort = {uid for uid, d in demo.items() if d.get(attr) in values}
|
| 256 |
df = df[df["user_id"].astype(str).isin(cohort)].copy()
|
|
|
|
| 289 |
rank_long["model"] = rank_long["model"].astype(str)
|
| 290 |
overall_rank = rank_long[rank_long["scope"] == "overall"].set_index("model")["rank"]
|
| 291 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 292 |
rows = []
|
| 293 |
for m in methods:
|
| 294 |
name, mtype, submitter, subtrack, fallback = read_method_meta(root, "forecasting", m)
|
|
|
|
| 301 |
"subtrack": subtrack,
|
| 302 |
"model_url": FC_MODEL_URLS.get(m),
|
| 303 |
"skill": _num(srow["overall_score"]) if srow is not None else None,
|
|
|
|
| 304 |
"rank": _num(overall_rank.get(m)),
|
| 305 |
"activity": _num(srow["activity_score"]) if srow is not None else None,
|
| 306 |
"physiology": _num(srow["physiology_score"]) if srow is not None else None,
|
|
|
|
| 345 |
def compute_downstream_rows(subgroup: tuple[str, str] | None = None) -> list[dict]:
|
| 346 |
"""Return leaderboard rows (sorted by skill desc) for the Track-1 (predictive tasks) track.
|
| 347 |
|
| 348 |
+
Reduces the per-user-pairs substrate live — point skill / rank vs the Linear
|
| 349 |
+
baseline — mirroring the imputation/forecasting tracks, so a newly-uploaded
|
| 350 |
+
substrate appears without a maintainer regenerating a precomputed rows file.
|
| 351 |
+
Point only (the bootstrap CIs live under downstream/bootstrap/); reuses the
|
| 352 |
+
paper's reducers, so the board equals the paper's point estimate.
|
| 353 |
|
| 354 |
``subgroup=(attr, values)`` restricts the reduction to users in any of those bins
|
| 355 |
+
(the substrate's demographic cells give the membership); only the global "all"
|
| 356 |
+
rows are passed on. Tasks degenerate inside the cohort (e.g. sex prediction in a
|
| 357 |
+
single-sex cohort) yield NaN metrics and drop from the aggregates via the
|
| 358 |
+
reducer's finite-guards.
|
|
|
|
| 359 |
"""
|
| 360 |
from downstream_evaluation.evaluation.bootstrap_skill_rank import reduce_substrate_to_point
|
| 361 |
|
|
|
|
| 380 |
"subtrack": subtrack,
|
| 381 |
"model_url": model_url,
|
| 382 |
"skill": _num(skill.get("Overall")),
|
|
|
|
| 383 |
"rank": _num(point[m]["rank"].get("Overall")),
|
| 384 |
"fallback": fallback,
|
| 385 |
**{col: _num(skill.get(scope)) for scope, col in DOWNSTREAM_SUBGROUP_SCOPES.items()},
|
|
|
|
| 388 |
return rows
|
| 389 |
|
| 390 |
|
| 391 |
+
# ---------------------------------------------------------------------------
|
| 392 |
+
# Cohort sizes — evaluated-user counts per (track, cohort), shown on the board
|
| 393 |
+
# ---------------------------------------------------------------------------
|
| 394 |
+
|
| 395 |
+
_COUNTS_CACHE: dict[str, dict[str, int]] = {}
|
| 396 |
+
|
| 397 |
+
|
| 398 |
+
def cohort_user_counts(track: str) -> dict[str, int]:
|
| 399 |
+
"""Distinct evaluated users per cohort key ("all" + one per SUBGROUPS entry).
|
| 400 |
+
|
| 401 |
+
Mirrors each track's cohort-membership rule in its compute function, so the
|
| 402 |
+
count matches the users actually feeding that cohort's table. Cached
|
| 403 |
+
in-process (substrates are already cached by ``load_substrate``).
|
| 404 |
+
"""
|
| 405 |
+
if track in _COUNTS_CACHE:
|
| 406 |
+
return _COUNTS_CACHE[track]
|
| 407 |
+
df, _ = load_substrate(track)
|
| 408 |
+
counts: dict[str, int] = {}
|
| 409 |
+
if track == "forecasting":
|
| 410 |
+
# No demographic columns in the substrate — membership comes from the
|
| 411 |
+
# shared imputation demographics, exactly as compute_forecasting_rows.
|
| 412 |
+
demo = _load_demographics()
|
| 413 |
+
users = set(df["user_id"].astype(str).unique())
|
| 414 |
+
counts["all"] = len(users)
|
| 415 |
+
for attr, values, _label in SUBGROUPS:
|
| 416 |
+
counts[f"{attr}:{'|'.join(values)}"] = sum(
|
| 417 |
+
1 for u in users if demo.get(u, {}).get(attr) in values
|
| 418 |
+
)
|
| 419 |
+
else: # imputation / downstream: membership from the baked subgroup cells
|
| 420 |
+
all_users = set(df.loc[df["subgroup_attr"] == "all", "user_id"].astype(str))
|
| 421 |
+
counts["all"] = len(all_users)
|
| 422 |
+
for attr, values, _label in SUBGROUPS:
|
| 423 |
+
members = set(
|
| 424 |
+
df.loc[
|
| 425 |
+
(df["subgroup_attr"] == attr) & (df["subgroup_value"].isin(values)),
|
| 426 |
+
"user_id",
|
| 427 |
+
].astype(str)
|
| 428 |
+
)
|
| 429 |
+
# Downstream restricts the reduction to members' global rows; the
|
| 430 |
+
# subgroup cells are a subset of the global users on both tracks,
|
| 431 |
+
# so the intersection is the evaluated population either way.
|
| 432 |
+
counts[f"{attr}:{'|'.join(values)}"] = len(members & all_users)
|
| 433 |
+
_COUNTS_CACHE[track] = counts
|
| 434 |
+
return counts
|
| 435 |
+
|
| 436 |
+
|
| 437 |
if __name__ == "__main__":
|
| 438 |
import json
|
| 439 |
|