Spaces:
Sleeping
Sleeping
File size: 1,167 Bytes
9d527ba b0a10e7 9d527ba |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
from datasets.utils.logging import disable_progress_bar
from constants import column_names, RANKING_COLUMN, ORDERED_COLUMN_NAMES
from utils_display import make_clickable_model
disable_progress_bar()
import json
import os
summary_file = "hardcorelogic.summary.json"
#result_dir = "HardcoreLogic-Eval/results_dirs"
results_by_model = {}
# Formats the columns
def formatter(x):
if type(x) is str:
x = x
else:
x = round(x, 2)
return x
def post_processing(df, column_names, rank_column=RANKING_COLUMN, ordered_columns=ORDERED_COLUMN_NAMES, click_url=True):
df = df[[col for col in column_names.keys() if col in df.columns]].copy()
for col in df.columns:
if col == "model" and click_url:
df[col] = df[col].apply(lambda x: x.replace(x, make_clickable_model(x)))
else:
df[col] = df[col].apply(formatter) # For numerical values
list_columns = [col for col in ordered_columns if col in df.columns]
df = df[list_columns]
if rank_column in df.columns:
df.sort_values(by=rank_column, inplace=True, ascending=False)
df.rename(columns=column_names, inplace=True)
return df
|