lukecq's picture
udpate the results format
541cf85
raw
history blame
2.17 kB
import pandas as pd
def load_data(data_path):
df = pd.read_csv(data_path, skiprows=1, header=0).dropna()
columns = ['Model', 'type', 'open?', 'shot', 'en', 'zh', 'id', 'th', 'vi', 'avg', 'avg_sea']
# Splitting into three separate DataFrames based on the groups M3Exam and MMLU and average
df_m3exam = df.iloc[:, :11] # M3Exam columns
df_mmlu = df.iloc[:, [0, 1, 2, 3, 11, 12, 13, 14, 15, 16, 17]] # MMLU columns
df_avg = df.iloc[:, [0, 1, 2, 3, 18, 19, 20, 21, 22, 23, 24]] # Average columns
df_mmlu.columns = columns
df_avg.columns = columns
# # multiply the values in the ['en', 'zh', 'id', 'th', 'vi', 'avg', 'avg_sea'] by 100 and display as 1 decimal
for df_tmp in [df_m3exam, df_mmlu, df_avg]:
df_tmp[['en', 'zh', 'id', 'th', 'vi', 'avg', 'avg_sea']] *= 100
df_tmp[['en', 'zh', 'id', 'th', 'vi', 'avg', 'avg_sea']] = df_tmp[['en', 'zh', 'id', 'th', 'vi', 'avg', 'avg_sea']].round(2)
df_tmp['rank'] = df_tmp['avg'].rank(ascending=False).astype(int)
# change the order of the columns to ['Model', 'type', 'open?', 'shot', 'avg', 'avg_sea', 'en', 'zh', 'id', 'th', 'vi']
# and sort the columns by 'avg' in descending order
columns_sorted = ['rank','type', 'Model', 'open?', 'shot', 'avg', 'avg_sea', 'en', 'zh', 'id', 'th', 'vi']
df_m3exam = df_m3exam[columns_sorted].sort_values(by='avg', ascending=False)
df_mmlu = df_mmlu[columns_sorted].sort_values(by='avg', ascending=False)
df_avg = df_avg[columns_sorted].sort_values(by='avg', ascending=False)
# change the column name from 'avg' to 'avg⬆️'
df_m3exam = df_m3exam.rename(columns={'avg': 'avg⬆️'})
df_mmlu = df_mmlu.rename(columns={'avg': 'avg⬆️'})
df_avg = df_avg.rename(columns={'avg': 'avg⬆️'})
# map the values in the 'type' column to the following values: {'base': 'Base', 'chat': 'Chat'}
df_m3exam['type'] = df_m3exam['type'].map({'base': '🟢', 'chat': '🔶'})
df_mmlu['type'] = df_mmlu['type'].map({'base': '🟢', 'chat': '🔶'})
df_avg['type'] = df_avg['type'].map({'base': '🟢', 'chat': '🔶'})
return df_m3exam, df_mmlu, df_avg