Spaces:
Running
Running
Update dashboard.py
Browse files- dashboard.py +4 -71
dashboard.py
CHANGED
@@ -1,73 +1,6 @@
|
|
1 |
-
|
2 |
-
from firebase_admin import credentials, firestore
|
3 |
-
import pandas as pd
|
4 |
-
import matplotlib.pyplot as plt
|
5 |
-
import io
|
6 |
-
import gradio as gr
|
7 |
-
|
8 |
-
# Initialize Firebase Admin SDK
|
9 |
-
if not firebase_admin._apps:
|
10 |
-
cred = credentials.Certificate("firebase_key.json")
|
11 |
-
firebase_admin.initialize_app(cred)
|
12 |
-
|
13 |
-
db = firestore.client()
|
14 |
-
|
15 |
-
def fetch_logs():
|
16 |
-
docs = db.collection("evo_feedback_logs").stream()
|
17 |
-
data = []
|
18 |
-
for doc in docs:
|
19 |
-
d = doc.to_dict()
|
20 |
-
if all(k in d for k in ["goal", "evo", "gpt", "correct"]):
|
21 |
-
data.append(d)
|
22 |
-
return pd.DataFrame(data)
|
23 |
-
|
24 |
-
def generate_dashboard():
|
25 |
-
df = fetch_logs()
|
26 |
-
if df.empty:
|
27 |
-
return "No data yet.", None
|
28 |
-
|
29 |
-
df["evo_correct"] = df["evo"] == df["correct"]
|
30 |
-
df["gpt_correct"] = df["gpt"] == df["correct"]
|
31 |
-
|
32 |
-
evo_acc = df["evo_correct"].mean()
|
33 |
-
gpt_acc = df["gpt_correct"].mean()
|
34 |
-
agreement = (df["evo"] == df["gpt"]).mean()
|
35 |
|
36 |
-
|
37 |
-
counts = [
|
38 |
-
df["evo_correct"].sum(),
|
39 |
-
df["evo_correct"].count() - df["evo_correct"].sum(),
|
40 |
-
df["gpt_correct"].sum(),
|
41 |
-
df["gpt_correct"].count() - df["gpt_correct"].sum()
|
42 |
-
]
|
43 |
-
bars = ax.bar(["Evo Correct", "Evo Wrong", "GPT Correct", "GPT Wrong"], counts)
|
44 |
-
ax.set_title("Model Accuracy Summary")
|
45 |
-
ax.set_ylabel("Count")
|
46 |
-
|
47 |
-
buf = io.BytesIO()
|
48 |
-
plt.tight_layout()
|
49 |
-
plt.savefig(buf, format="png")
|
50 |
-
plt.close(fig)
|
51 |
-
buf.seek(0)
|
52 |
-
|
53 |
-
summary = (
|
54 |
-
f"π§ Evo Accuracy: {evo_acc:.2%}\n"
|
55 |
-
f"π€ GPT-3.5 Accuracy: {gpt_acc:.2%}\n"
|
56 |
-
f"βοΈ Agreement Rate: {agreement:.2%}\n"
|
57 |
-
f"π Total Examples Logged: {len(df)}"
|
58 |
-
)
|
59 |
-
|
60 |
-
return summary, buf
|
61 |
-
|
62 |
-
def render_dashboard():
|
63 |
-
with gr.Blocks() as dashboard:
|
64 |
-
gr.Markdown("## π EvoTransformer Live Evolution Dashboard")
|
65 |
-
gr.Markdown("> π *Below metrics are based on real-time user feedback.*")
|
66 |
-
|
67 |
-
summary_text = gr.Textbox(label="Summary", interactive=False)
|
68 |
-
plot = gr.Image(type="pil", label="Accuracy Plot")
|
69 |
-
|
70 |
-
refresh = gr.Button("π Refresh Data")
|
71 |
-
refresh.click(fn=generate_dashboard, outputs=[summary_text, plot])
|
72 |
|
73 |
-
|
|
|
|
1 |
+
# dashboard.py
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
+
import gradio as gr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
+
def display_dashboard():
|
6 |
+
return gr.Markdown("## π EvoTransformer Live Dashboard\n\nComing soon!")
|