Spaces:
Sleeping
Sleeping
michal
commited on
Commit
·
d09c531
1
Parent(s):
3930665
Upload
Browse files
src/structures/ldek_structure.py
CHANGED
@@ -21,7 +21,7 @@ def generate_ORDER_LIST_LDEK_and_data_types(json_data):
|
|
21 |
data_types = ["markdown", "number"]
|
22 |
|
23 |
for key in json_data.keys():
|
24 |
-
if key not in ["model_name"]:
|
25 |
ORDER_LIST_LDEK.append(key)
|
26 |
data_types.append("number")
|
27 |
ORDER_LIST_LDEK[2:] = sorted(ORDER_LIST_LDEK[2:])
|
@@ -32,26 +32,38 @@ def filter_columns_ldek(column_choices):
|
|
32 |
return LDEK_ACCS[selected_columns]
|
33 |
|
34 |
def load_json_data(file_path, ORDER_LIST_LDEK):
|
|
|
35 |
LDEK_ACCS = pd.read_json(file_path)
|
|
|
|
|
36 |
for column in LDEK_ACCS.columns:
|
37 |
if LDEK_ACCS[column].apply(type).eq(dict).any():
|
38 |
LDEK_ACCS[column] = LDEK_ACCS[column].apply(str)
|
39 |
|
|
|
40 |
LDEK_ACCS["model_name"] = LDEK_ACCS["model_name"].apply(
|
41 |
lambda name: replace_models_names(name)
|
42 |
)
|
43 |
|
|
|
44 |
for column in LDEK_ACCS.select_dtypes(include='number').columns:
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
46 |
ordered_columns = [col for col in ORDER_LIST_LDEK if col in LDEK_ACCS.columns]
|
47 |
LDEK_ACCS = LDEK_ACCS[ordered_columns]
|
48 |
|
49 |
-
|
50 |
-
|
|
|
51 |
|
52 |
return LDEK_ACCS
|
53 |
|
54 |
|
|
|
55 |
# file_path = str(abs_path / "leaderboards/r_ldek_report_scores.json")
|
56 |
file_path = str(abs_path / "leaderboards/ldek_accs.json")
|
57 |
with open(file_path, 'r', encoding='utf-8') as file:
|
|
|
21 |
data_types = ["markdown", "number"]
|
22 |
|
23 |
for key in json_data.keys():
|
24 |
+
if key not in ["model_name", "overall_accuracy"]:
|
25 |
ORDER_LIST_LDEK.append(key)
|
26 |
data_types.append("number")
|
27 |
ORDER_LIST_LDEK[2:] = sorted(ORDER_LIST_LDEK[2:])
|
|
|
32 |
return LDEK_ACCS[selected_columns]
|
33 |
|
34 |
def load_json_data(file_path, ORDER_LIST_LDEK):
|
35 |
+
# Load JSON data into a DataFrame
|
36 |
LDEK_ACCS = pd.read_json(file_path)
|
37 |
+
|
38 |
+
# Convert nested dictionary fields (if any) to strings
|
39 |
for column in LDEK_ACCS.columns:
|
40 |
if LDEK_ACCS[column].apply(type).eq(dict).any():
|
41 |
LDEK_ACCS[column] = LDEK_ACCS[column].apply(str)
|
42 |
|
43 |
+
# Apply the custom model name replacement function
|
44 |
LDEK_ACCS["model_name"] = LDEK_ACCS["model_name"].apply(
|
45 |
lambda name: replace_models_names(name)
|
46 |
)
|
47 |
|
48 |
+
# Convert numeric columns and round
|
49 |
for column in LDEK_ACCS.select_dtypes(include='number').columns:
|
50 |
+
LDEK_ACCS[column] = LDEK_ACCS[column].round(2)
|
51 |
+
|
52 |
+
# Ensure overall_accuracy is treated as numeric for sorting
|
53 |
+
LDEK_ACCS["overall_accuracy"] = pd.to_numeric(LDEK_ACCS["overall_accuracy"], errors='coerce')
|
54 |
+
|
55 |
+
# Reorder columns based on ORDER_LIST_LDEK
|
56 |
ordered_columns = [col for col in ORDER_LIST_LDEK if col in LDEK_ACCS.columns]
|
57 |
LDEK_ACCS = LDEK_ACCS[ordered_columns]
|
58 |
|
59 |
+
# Sort by overall_accuracy in descending order if it exists
|
60 |
+
if "overall_accuracy" in LDEK_ACCS.columns:
|
61 |
+
LDEK_ACCS = LDEK_ACCS.sort_values(by="overall_accuracy", ascending=False)
|
62 |
|
63 |
return LDEK_ACCS
|
64 |
|
65 |
|
66 |
+
|
67 |
# file_path = str(abs_path / "leaderboards/r_ldek_report_scores.json")
|
68 |
file_path = str(abs_path / "leaderboards/ldek_accs.json")
|
69 |
with open(file_path, 'r', encoding='utf-8') as file:
|