cyberosa
commited on
Commit
·
3546de0
1
Parent(s):
62eb26c
fixing error in one graph
Browse files- app.py +3 -3
- tabs/tool_accuracy.py +0 -19
- tabs/tool_win.py +43 -0
app.py
CHANGED
|
@@ -27,7 +27,7 @@ from tabs.metrics import (
|
|
| 27 |
from tabs.tool_win import (
|
| 28 |
integrated_plot_tool_winnings_overall_per_market_by_week,
|
| 29 |
integrated_tool_winnings_by_tool_per_market,
|
| 30 |
-
|
| 31 |
)
|
| 32 |
|
| 33 |
from tabs.tool_accuracy import (
|
|
@@ -473,14 +473,14 @@ with demo:
|
|
| 473 |
gr.Markdown("# Daily mech requests by each tool in Pearl markets")
|
| 474 |
|
| 475 |
with gr.Row():
|
| 476 |
-
daily_pearl_requests_plot =
|
| 477 |
daily_mech_req_df=daily_mech_requests, market_creator="pearl"
|
| 478 |
)
|
| 479 |
with gr.Row():
|
| 480 |
gr.Markdown("# Daily mech requests by each tool in Quickstart markets")
|
| 481 |
|
| 482 |
with gr.Row():
|
| 483 |
-
daily_qs_requests_plot =
|
| 484 |
daily_mech_req_df=daily_mech_requests, market_creator="quickstart"
|
| 485 |
)
|
| 486 |
with gr.Row():
|
|
|
|
| 27 |
from tabs.tool_win import (
|
| 28 |
integrated_plot_tool_winnings_overall_per_market_by_week,
|
| 29 |
integrated_tool_winnings_by_tool_per_market,
|
| 30 |
+
get_daily_mech_requests2,
|
| 31 |
)
|
| 32 |
|
| 33 |
from tabs.tool_accuracy import (
|
|
|
|
| 473 |
gr.Markdown("# Daily mech requests by each tool in Pearl markets")
|
| 474 |
|
| 475 |
with gr.Row():
|
| 476 |
+
daily_pearl_requests_plot = get_daily_mech_requests2(
|
| 477 |
daily_mech_req_df=daily_mech_requests, market_creator="pearl"
|
| 478 |
)
|
| 479 |
with gr.Row():
|
| 480 |
gr.Markdown("# Daily mech requests by each tool in Quickstart markets")
|
| 481 |
|
| 482 |
with gr.Row():
|
| 483 |
+
daily_qs_requests_plot = get_daily_mech_requests2(
|
| 484 |
daily_mech_req_df=daily_mech_requests, market_creator="quickstart"
|
| 485 |
)
|
| 486 |
with gr.Row():
|
tabs/tool_accuracy.py
CHANGED
|
@@ -65,25 +65,6 @@ def compute_weighted_accuracy(tools_accuracy: pd.DataFrame):
|
|
| 65 |
return tools_accuracy
|
| 66 |
|
| 67 |
|
| 68 |
-
def plot_tools_accuracy_graph(tools_accuracy_info: pd.DataFrame):
|
| 69 |
-
tools_accuracy_info = tools_accuracy_info.sort_values(
|
| 70 |
-
by="tool_accuracy", ascending=False
|
| 71 |
-
)
|
| 72 |
-
plt.figure(figsize=(25, 10))
|
| 73 |
-
plot = sns.barplot(
|
| 74 |
-
tools_accuracy_info,
|
| 75 |
-
x="tool_accuracy",
|
| 76 |
-
y="tool",
|
| 77 |
-
hue="tool",
|
| 78 |
-
dodge=False,
|
| 79 |
-
palette=tools_palette,
|
| 80 |
-
)
|
| 81 |
-
plt.xlabel("Mech tool_accuracy (%)", fontsize=20)
|
| 82 |
-
plt.ylabel("tool", fontsize=20)
|
| 83 |
-
plt.tick_params(axis="y", labelsize=12)
|
| 84 |
-
return gr.Plot(value=plot.get_figure())
|
| 85 |
-
|
| 86 |
-
|
| 87 |
def plot_tools_accuracy_rotated_graph(tools_accuracy_info: pd.DataFrame):
|
| 88 |
tools_accuracy_info = tools_accuracy_info.sort_values(
|
| 89 |
by="tool_accuracy", ascending=False
|
|
|
|
| 65 |
return tools_accuracy
|
| 66 |
|
| 67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
def plot_tools_accuracy_rotated_graph(tools_accuracy_info: pd.DataFrame):
|
| 69 |
tools_accuracy_info = tools_accuracy_info.sort_values(
|
| 70 |
by="tool_accuracy", ascending=False
|
tabs/tool_win.py
CHANGED
|
@@ -175,6 +175,7 @@ def get_daily_mech_requests(
|
|
| 175 |
daily_mech_req_per_tool = daily_mech_req_per_tool[
|
| 176 |
["request_date", "tool", "total_mech_requests"]
|
| 177 |
]
|
|
|
|
| 178 |
pivoted = daily_mech_req_per_tool.pivot(
|
| 179 |
index="request_date", columns="tool", values="total_mech_requests"
|
| 180 |
)
|
|
@@ -211,3 +212,45 @@ def get_daily_mech_requests(
|
|
| 211 |
)
|
| 212 |
fig.update_layout(width=WIDTH, height=HEIGHT)
|
| 213 |
return gr.Plot(value=fig)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 175 |
daily_mech_req_per_tool = daily_mech_req_per_tool[
|
| 176 |
["request_date", "tool", "total_mech_requests"]
|
| 177 |
]
|
| 178 |
+
# Add this before pivoting to check total requests per tool
|
| 179 |
pivoted = daily_mech_req_per_tool.pivot(
|
| 180 |
index="request_date", columns="tool", values="total_mech_requests"
|
| 181 |
)
|
|
|
|
| 212 |
)
|
| 213 |
fig.update_layout(width=WIDTH, height=HEIGHT)
|
| 214 |
return gr.Plot(value=fig)
|
| 215 |
+
|
| 216 |
+
|
| 217 |
+
def get_daily_mech_requests2(
|
| 218 |
+
daily_mech_req_df: pd.DataFrame, market_creator: str
|
| 219 |
+
) -> gr.Plot:
|
| 220 |
+
if market_creator == "pearl":
|
| 221 |
+
daily_mech_req_per_tool = daily_mech_req_df.loc[
|
| 222 |
+
daily_mech_req_df["market_creator"] == "pearl"
|
| 223 |
+
]
|
| 224 |
+
else: # quickstart
|
| 225 |
+
daily_mech_req_per_tool = daily_mech_req_df.loc[
|
| 226 |
+
daily_mech_req_df["market_creator"] == "quickstart"
|
| 227 |
+
]
|
| 228 |
+
|
| 229 |
+
daily_mech_req_per_tool = daily_mech_req_per_tool[
|
| 230 |
+
["request_date", "tool", "total_mech_requests"]
|
| 231 |
+
]
|
| 232 |
+
|
| 233 |
+
result = []
|
| 234 |
+
for date, group in daily_mech_req_per_tool.groupby("request_date"):
|
| 235 |
+
# Sort this day's tools by request count (descending)
|
| 236 |
+
sorted_group = group.sort_values("total_mech_requests", ascending=False)
|
| 237 |
+
result.append(sorted_group)
|
| 238 |
+
|
| 239 |
+
# Combine all sorted groups
|
| 240 |
+
sorted_daily_mech_req = pd.concat(result)
|
| 241 |
+
|
| 242 |
+
# Create the plot
|
| 243 |
+
fig = px.bar(
|
| 244 |
+
sorted_daily_mech_req,
|
| 245 |
+
x="request_date",
|
| 246 |
+
y="total_mech_requests",
|
| 247 |
+
color="tool",
|
| 248 |
+
color_discrete_map=tools_palette,
|
| 249 |
+
)
|
| 250 |
+
fig.update_layout(
|
| 251 |
+
xaxis_title="Day of the request",
|
| 252 |
+
yaxis_title="Total daily mech requests",
|
| 253 |
+
# legend=dict(yanchor="top", y=0.5),
|
| 254 |
+
)
|
| 255 |
+
fig.update_layout(width=WIDTH, height=HEIGHT)
|
| 256 |
+
return gr.Plot(value=fig)
|