Spaces:
Running
Running
gradio app to visualize results
Browse files
app.py
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import json
|
| 4 |
+
|
| 5 |
+
from evaluate import get_solution_code
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
# For now, only evaluate first 9 days
|
| 9 |
+
df = pd.read_csv("results.csv")
|
| 10 |
+
df = df[df.day < 10]
|
| 11 |
+
|
| 12 |
+
with open("solutions.json") as f:
|
| 13 |
+
solutions = json.load(f)
|
| 14 |
+
|
| 15 |
+
def score_submissions(row):
|
| 16 |
+
result = row["result"]
|
| 17 |
+
day = row["day"]
|
| 18 |
+
solution = solutions[str(day)]
|
| 19 |
+
|
| 20 |
+
score_1 = solution[0] in result
|
| 21 |
+
score_2 = solution[1] in result
|
| 22 |
+
return [score_1, score_2]
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
df["scores"] = df.apply(score_submissions, axis=1)
|
| 26 |
+
df["code"] = df.apply(lambda x: get_solution_code(day = x["day"], model=x["model"]), axis=1)
|
| 27 |
+
df["code_md"] = df.code.apply(lambda x: "```python"+x+"```")
|
| 28 |
+
|
| 29 |
+
df["part_1"] = df["scores"].apply(lambda x: x[0])
|
| 30 |
+
df["part_2"] = df["scores"].apply(lambda x: x[1])
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
star_summary = {}
|
| 34 |
+
for model in df.model.unique():
|
| 35 |
+
df_model = df[df.model == model]
|
| 36 |
+
silver_stars = df_model.part_1.sum()
|
| 37 |
+
gold_stars = df_model.part_2.sum()
|
| 38 |
+
total_stars = silver_stars + gold_stars
|
| 39 |
+
star_summary[model] = {
|
| 40 |
+
"Model": model,
|
| 41 |
+
"Silver Stars ⭐️": silver_stars,
|
| 42 |
+
"Gold Stars ⭐️": gold_stars,
|
| 43 |
+
"Total Stars ⭐️": total_stars,
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
star_df = pd.DataFrame.from_dict(star_summary, orient="index")
|
| 47 |
+
|
| 48 |
+
with gr.Blocks() as demo:
|
| 49 |
+
md = gr.Markdown("Hello!")
|
| 50 |
+
with gr.Tab("Stars"):
|
| 51 |
+
gr_star_df = gr.DataFrame(star_df)
|
| 52 |
+
with gr.Tab("Daily"):
|
| 53 |
+
|
| 54 |
+
# Parse the info to something more readable
|
| 55 |
+
df_daily = df[["model", "day", "part_1", "part_2", "total_time"]]
|
| 56 |
+
df_daily["Part 1"] = df_daily["part_1"].apply(lambda x: "⭐️" if x else "❌")
|
| 57 |
+
df_daily["Part 2"] = df_daily["part_2"].apply(lambda x: "⭐️" if x else "❌")
|
| 58 |
+
df_daily["Runtime (s)"] = df_daily["total_time"].apply(lambda x: str(x)[0:6])
|
| 59 |
+
df_daily = df_daily[["model", "day", "Part 1", "Part 2", "Runtime (s)"]]
|
| 60 |
+
|
| 61 |
+
gr_df_daily = gr.DataFrame(df_daily.sort_values(by="day"))
|
| 62 |
+
|
| 63 |
+
# with gr.Tab("Code"):
|
| 64 |
+
# gr_code_df = gr.DataFrame(df[["model", "day", "code_md", "result"]], datatype=["str", "str", "markdown", "str"])
|
| 65 |
+
|
| 66 |
+
demo.launch()
|