Update app.py
Browse files
app.py
CHANGED
@@ -26,18 +26,33 @@ app.add_middleware(
|
|
26 |
)
|
27 |
|
28 |
|
29 |
-
@app.get("/
|
30 |
-
async def
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
|
42 |
|
43 |
app.mount("/", StaticFiles(directory="static", html=True), name="static")
|
|
|
26 |
)
|
27 |
|
28 |
|
29 |
+
@app.get("/api/results")
|
30 |
+
async def get_results():
|
31 |
+
# Load the dataset
|
32 |
+
dataset = load_dataset("smolagents-benchmark/results")
|
33 |
+
|
34 |
+
# Convert to list for processing
|
35 |
+
data = dataset["train"].to_pandas()
|
36 |
+
|
37 |
+
# Process the data to group by model and calculate scores
|
38 |
+
processed_data = []
|
39 |
+
grouped = data.groupby('model_id')
|
40 |
+
|
41 |
+
for model_id, group in grouped:
|
42 |
+
model_data = {
|
43 |
+
'model_id': model_id,
|
44 |
+
'scores': {}
|
45 |
+
}
|
46 |
+
|
47 |
+
# Calculate scores for each source
|
48 |
+
for source in group['source'].unique():
|
49 |
+
source_data = group[group['source'] == source]
|
50 |
+
avg_acc = source_data['acc'].mean()
|
51 |
+
model_data['scores'][source] = float(avg_acc)
|
52 |
+
|
53 |
+
processed_data.append(model_data)
|
54 |
+
|
55 |
+
return processed_data
|
56 |
|
57 |
|
58 |
app.mount("/", StaticFiles(directory="static", html=True), name="static")
|