Pivot repeated eval runs into a model by benchmark score table
Leaderboards are wide tables: one row per model, one column per benchmark. Raw eval logs are long, and the same model and benchmark may have several runs with different seeds.
Write score_table(df) where df has columns model (str), benchmark (str) and score (float).
Return a DataFrame with first column model, then one column per benchmark name in alphabetical order. Each cell is the MEAN score over that model's runs on that benchmark, or 0.0 if the model never ran it. Rows sorted by model ascending, plain 0..n-1 index.
def score_table(df)Example
('a', 'math', 0.4), ('a', 'math', 0.6), ('b', 'code', 0.9) gives columns [model, code, math] and rows a: 0.0, 0.5; b: 0.9, 0.0.
Understand the idea
Eval logs are long: one row per run, and the same model and benchmark can appear several times with different seeds. Leaderboards are wide: one row per model, one column per benchmark. A pivot table does the reshaping and averages the repeats. Pairs that never ran must show 0.0 rather than NaN. Worked example: ('a', 'code', 0.7), ('a', 'code', 0.9), ('b', 'math', 0.4). Model a on code: mean of 0.7 and 0.9 = 0.8; a never ran math, so 0.0. Model b on math: 0.4; on code: 0.0. Columns in alphabetical order: [model, code, math]. Rows: a: 0.8, 0.0; b: 0.0, 0.4. Rule: pivot with model as rows, benchmark as columns, mean as the aggregation and 0.0 as the fill value; sort benchmark columns alphabetically; turn the model index back into the first column; sort rows by model and reset to a plain 0 to n-1 index; clear the leftover columns name so the frame looks flat. Using max reports the luckiest seed instead of the typical score. This is how model comparison tables are built from raw eval runs.