Skip to content

Commit

Permalink
fix sub summarizer order
Browse files Browse the repository at this point in the history
  • Loading branch information
bittersweet1999 committed Aug 15, 2024
1 parent d72ca83 commit c8c5c17
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions opencompass/summarizers/subjective/subjective.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import pandas as pd
from mmengine import ConfigDict

from collections import OrderedDict
from .utils import get_outdir


Expand Down Expand Up @@ -73,24 +73,24 @@ def summarize(
None
"""
output_dir, results_folder = get_outdir(self.cfg, time_str)

flat_data, models_order = flatten_data(subjective_scores)

# Create a DataFrame for each judgemodel with models as rows and datasets as columns
judgemodel_dfs_final_corrected = {}
for judgemodel_name, datasets_scores in flat_data.items():
dfs = {} # Dictionary to hold DataFrames for each dataset
for dataset_name, scores in datasets_scores.items():
# Create a DataFrame with models as index and datasets as columns
df = pd.DataFrame.from_dict(scores,
orient='index',
columns=models_order)

order_of_rows = list(scores.keys())
df = pd.DataFrame.from_dict({k: scores[k] for k in order_of_rows}, orient='index')
df = df.reindex(order_of_rows)
# Insert a new row at the top for the dataset names
df.insert(0, 'Detailed Scores', df.index.values)
df.insert(0, 'Dataset',
[dataset_name for _ in range(len(df.index))])
dfs[dataset_name] = df


# Concatenate all DataFrames for the current judgemodel
judgemodel_df = pd.concat(dfs.values(), ignore_index=True)
judgemodel_dfs_final_corrected[judgemodel_name] = judgemodel_df
Expand All @@ -103,3 +103,6 @@ def summarize(
print('Your subjective evaluation results have been saved at ' +
str(fout))
df.to_csv(fout, index=False)



0 comments on commit c8c5c17

Please sign in to comment.