File size: 2,447 Bytes
c744934
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e3ce2e2
 
 
c744934
 
 
 
 
 
 
 
 
 
 
 
 
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import os
import json
import pandas as pd

def model_hyperlink(model_link, model):
    return f'<a target="_blank" href="{model_link}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;">{model}</a>'

def load_all_data(data_dir):
    data_list = []
    
    # Traverse the directory to find all JSON files
    for root, dirs, files in os.walk(data_dir):
        for file in files:
            if file.endswith('.json'):
                file_path = os.path.join(root, file)
                
                # Load JSON data
                with open(file_path, 'r', encoding='utf-8') as f:
                    data = json.load(f)
                    
                    # Extract relevant data
                    model = data.get("model", "")
                    model_link = data.get("model_link", "")
                    with_tie = data.get("with_tie", {})
                    without_tie = data.get("without_tie", {})
                    
                    # Calculate averages
                    avg_with_tie = round(sum(with_tie.values()) / len(with_tie), 2) if with_tie else 0
                    avg_without_tie = round(sum(without_tie.values()) / len(without_tie), 2) if without_tie else 0
                    avg = round((avg_with_tie + avg_without_tie) / 2, 2)
                    
                    # Append to list
                    data_list.append({
                        "Model": model_hyperlink(model_link, model),
                        "Model Type": data.get("model_type", ""),
                        "Avg.": avg,
                        "Avg. (w/o Ties)": avg_without_tie,
                        "Avg. (w/ Ties)": avg_with_tie,
                        "Overall (w/o Ties)": round(without_tie.get("overall", 0), 2),
                        "VQ (w/o Ties)": round(without_tie.get("vq", 0), 2),
                        "MQ (w/o Ties)": round(without_tie.get("mq", 0), 2),
                        "TA (w/o Ties)": round(without_tie.get("ta", 0), 2),
                        "Overall (w/ Ties)": round(with_tie.get("overall", 0), 2),
                        "VQ (w/ Ties)": round(with_tie.get("vq", 0), 2),
                        "MQ (w/ Ties)": round(with_tie.get("mq", 0), 2),
                        "TA (w/ Ties)": round(with_tie.get("ta", 0), 2),
                    })
    
    # Create a DataFrame from the list of data
    df = pd.DataFrame(data_list)
    return df