LiveBench / src /populate.py
pufanyi's picture
Refactor init_leaderboard function to handle multiple subsets, improve column selection and hiding, and include Dataset Version in filter_columns
35850bf
raw
history blame
888 Bytes
import json
import os
import pandas as pd
from src.display.formatting import has_no_nan_values, make_clickable_model
from src.display.utils import AutoEvalColumn, EvalQueueColumn
from datasets import load_dataset, get_dataset_config_names
def get_leaderboard_df(results_repo):
subsets = get_dataset_config_names(results_repo)
subset_dfs = {}
for subset in subsets:
subset_data = load_dataset(results_repo, subset, split="test")
subset_df = subset_data.to_pandas()
subset_df = subset_df.sort_values(by="Total", ascending=False)
subset_df = subset_df.round(2) # Round all numeric columns to two decimal places
# subset_df["Dataset Version"] = [subset] * len(subset_df)
print(subset_df)
subset_dfs[subset] = subset_df
# df = pd.concat(subset_dfs.values())
# return df, subset_dfs.keys()
return subset_dfs