Commit
·
f740333
1
Parent(s):
28ad8cf
weighted accuracy between 0 and 1. Cleaning
Browse files- app.py +11 -43
- notebooks/weighted_accuracy_ranking.ipynb +0 -0
- tabs/tool_accuracy.py +51 -0
app.py
CHANGED
|
@@ -19,6 +19,12 @@ from tabs.tool_win import (
|
|
| 19 |
plot_tool_winnings_overall,
|
| 20 |
plot_tool_winnings_by_tool,
|
| 21 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
from tabs.error import (
|
| 23 |
get_error_data,
|
| 24 |
get_error_data_overall,
|
|
@@ -112,19 +118,6 @@ def get_all_data():
|
|
| 112 |
return df1, df2, df3
|
| 113 |
|
| 114 |
|
| 115 |
-
def get_weighted_accuracy(row, global_requests: int):
|
| 116 |
-
"""Function to compute the weighted accuracy of a tool"""
|
| 117 |
-
return row["tool_accuracy"] * (row["total_requests"] / global_requests)
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
def compute_weighted_accuracy(tools_accuracy: pd.DataFrame):
|
| 121 |
-
global_requests = tools_accuracy.total_requests.sum()
|
| 122 |
-
tools_accuracy["weighted_accuracy"] = tools_accuracy.apply(
|
| 123 |
-
lambda x: get_weighted_accuracy(x, global_requests), axis=1
|
| 124 |
-
)
|
| 125 |
-
return tools_accuracy
|
| 126 |
-
|
| 127 |
-
|
| 128 |
def prepare_data():
|
| 129 |
"""
|
| 130 |
Prepare the data for the dashboard
|
|
@@ -267,47 +260,22 @@ with demo:
|
|
| 267 |
with gr.TabItem("🎯 Tool Accuracy Dashboard"):
|
| 268 |
with gr.Row():
|
| 269 |
gr.Markdown("# Tools accuracy ranking")
|
| 270 |
-
|
| 271 |
gr.Markdown(
|
| 272 |
"The data used for this metric is from the past two months. This accuracy is computed based on right answers from the total requests received."
|
| 273 |
)
|
| 274 |
|
| 275 |
with gr.Row():
|
| 276 |
-
tools_accuracy_info
|
| 277 |
-
|
| 278 |
-
)
|
| 279 |
-
plt.figure(figsize=(25, 10))
|
| 280 |
-
plot = sns.barplot(
|
| 281 |
-
tools_accuracy_info,
|
| 282 |
-
x="tool_accuracy",
|
| 283 |
-
y="tool",
|
| 284 |
-
hue="tool",
|
| 285 |
-
dodge=False,
|
| 286 |
-
palette="viridis",
|
| 287 |
-
)
|
| 288 |
-
gr.Plot(value=plot.get_figure())
|
| 289 |
with gr.Row():
|
| 290 |
gr.Markdown("# Weighted accuracy ranking per tool")
|
| 291 |
-
|
| 292 |
gr.Markdown(
|
| 293 |
"The data used for this metric is from the past two months. This metric is computed using both the tool accuracy and the volume of requests received by the tool"
|
| 294 |
)
|
| 295 |
with gr.Row():
|
| 296 |
-
tools_accuracy_info
|
| 297 |
-
by="weighted_accuracy", ascending=False
|
| 298 |
-
)
|
| 299 |
-
# Create the Seaborn bar plot
|
| 300 |
-
sns.set_theme(palette="viridis")
|
| 301 |
-
plt.figure(figsize=(25, 10))
|
| 302 |
-
plot = sns.barplot(
|
| 303 |
-
tools_accuracy_info,
|
| 304 |
-
x="weighted_accuracy",
|
| 305 |
-
y="tool",
|
| 306 |
-
hue="tool",
|
| 307 |
-
dodge=False,
|
| 308 |
-
)
|
| 309 |
-
# Display the plot using gr.Plot
|
| 310 |
-
gr.Plot(value=plot.get_figure())
|
| 311 |
|
| 312 |
with gr.TabItem("🏥 Tool Error Dashboard"):
|
| 313 |
with gr.Row():
|
|
|
|
| 19 |
plot_tool_winnings_overall,
|
| 20 |
plot_tool_winnings_by_tool,
|
| 21 |
)
|
| 22 |
+
|
| 23 |
+
from tabs.tool_accuracy import (
|
| 24 |
+
compute_weighted_accuracy,
|
| 25 |
+
plot_tools_accuracy_graph,
|
| 26 |
+
plot_tools_weighted_accuracy_graph,
|
| 27 |
+
)
|
| 28 |
from tabs.error import (
|
| 29 |
get_error_data,
|
| 30 |
get_error_data_overall,
|
|
|
|
| 118 |
return df1, df2, df3
|
| 119 |
|
| 120 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
def prepare_data():
|
| 122 |
"""
|
| 123 |
Prepare the data for the dashboard
|
|
|
|
| 260 |
with gr.TabItem("🎯 Tool Accuracy Dashboard"):
|
| 261 |
with gr.Row():
|
| 262 |
gr.Markdown("# Tools accuracy ranking")
|
| 263 |
+
with gr.Row():
|
| 264 |
gr.Markdown(
|
| 265 |
"The data used for this metric is from the past two months. This accuracy is computed based on right answers from the total requests received."
|
| 266 |
)
|
| 267 |
|
| 268 |
with gr.Row():
|
| 269 |
+
plot_tools_accuracy_graph(tools_accuracy_info)
|
| 270 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 271 |
with gr.Row():
|
| 272 |
gr.Markdown("# Weighted accuracy ranking per tool")
|
| 273 |
+
with gr.Row():
|
| 274 |
gr.Markdown(
|
| 275 |
"The data used for this metric is from the past two months. This metric is computed using both the tool accuracy and the volume of requests received by the tool"
|
| 276 |
)
|
| 277 |
with gr.Row():
|
| 278 |
+
plot_tools_weighted_accuracy_graph(tools_accuracy_info)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 279 |
|
| 280 |
with gr.TabItem("🏥 Tool Error Dashboard"):
|
| 281 |
with gr.Row():
|
notebooks/weighted_accuracy_ranking.ipynb
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tabs/tool_accuracy.py
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import pandas as pd
|
| 2 |
+
import gradio as gr
|
| 3 |
+
import matplotlib.pyplot as plt
|
| 4 |
+
import seaborn as sns
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
def get_weighted_accuracy(row, global_requests: int):
|
| 8 |
+
"""Function to compute the weighted accuracy of a tool"""
|
| 9 |
+
return (row["tool_accuracy"] / 100.0) * (row["total_requests"] / global_requests)
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
def compute_weighted_accuracy(tools_accuracy: pd.DataFrame):
|
| 13 |
+
global_requests = tools_accuracy.total_requests.sum()
|
| 14 |
+
tools_accuracy["weighted_accuracy"] = tools_accuracy.apply(
|
| 15 |
+
lambda x: get_weighted_accuracy(x, global_requests), axis=1
|
| 16 |
+
)
|
| 17 |
+
return tools_accuracy
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def plot_tools_accuracy_graph(tools_accuracy_info: pd.DataFrame):
|
| 21 |
+
tools_accuracy_info = tools_accuracy_info.sort_values(
|
| 22 |
+
by="tool_accuracy", ascending=False
|
| 23 |
+
)
|
| 24 |
+
plt.figure(figsize=(25, 10))
|
| 25 |
+
plot = sns.barplot(
|
| 26 |
+
tools_accuracy_info,
|
| 27 |
+
x="tool_accuracy",
|
| 28 |
+
y="tool",
|
| 29 |
+
hue="tool",
|
| 30 |
+
dodge=False,
|
| 31 |
+
palette="viridis",
|
| 32 |
+
)
|
| 33 |
+
return gr.Plot(value=plot.get_figure())
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
def plot_tools_weighted_accuracy_graph(tools_accuracy_info: pd.DataFrame):
|
| 37 |
+
tools_accuracy_info = tools_accuracy_info.sort_values(
|
| 38 |
+
by="weighted_accuracy", ascending=False
|
| 39 |
+
)
|
| 40 |
+
# Create the Seaborn bar plot
|
| 41 |
+
sns.set_theme(palette="viridis")
|
| 42 |
+
plt.figure(figsize=(25, 10))
|
| 43 |
+
plot = sns.barplot(
|
| 44 |
+
tools_accuracy_info,
|
| 45 |
+
x="weighted_accuracy",
|
| 46 |
+
y="tool",
|
| 47 |
+
hue="tool",
|
| 48 |
+
dodge=False,
|
| 49 |
+
)
|
| 50 |
+
# Display the plot using gr.Plot
|
| 51 |
+
gr.Plot(value=plot.get_figure())
|