cyberosa
commited on
Commit
·
e3d589e
1
Parent(s):
617003a
daily mech requests per market graphs
Browse files- app.py +27 -1
- tabs/tool_win.py +70 -2
app.py
CHANGED
|
@@ -27,6 +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 |
from tabs.tool_accuracy import (
|
|
@@ -144,7 +145,16 @@ def load_all_data():
|
|
| 144 |
)
|
| 145 |
|
| 146 |
df6 = pd.read_parquet(winning_df)
|
| 147 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
|
| 149 |
|
| 150 |
def prepare_data():
|
|
@@ -158,6 +168,7 @@ def prepare_data():
|
|
| 158 |
invalid_trades,
|
| 159 |
unknown_trades,
|
| 160 |
winning_df,
|
|
|
|
| 161 |
) = load_all_data()
|
| 162 |
print(trades_df.info())
|
| 163 |
|
|
@@ -186,6 +197,7 @@ def prepare_data():
|
|
| 186 |
invalid_trades,
|
| 187 |
unknown_trades,
|
| 188 |
winning_df,
|
|
|
|
| 189 |
)
|
| 190 |
|
| 191 |
|
|
@@ -196,6 +208,7 @@ def prepare_data():
|
|
| 196 |
invalid_trades,
|
| 197 |
unknown_trades,
|
| 198 |
winning_df,
|
|
|
|
| 199 |
) = prepare_data()
|
| 200 |
trades_df = trades_df.sort_values(by="creation_timestamp", ascending=True)
|
| 201 |
unknown_trades = unknown_trades.sort_values(by="creation_timestamp", ascending=True)
|
|
@@ -440,7 +453,20 @@ with demo:
|
|
| 440 |
winning_selector
|
| 441 |
with gr.Row():
|
| 442 |
winning_plot
|
|
|
|
|
|
|
| 443 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 444 |
with gr.Row():
|
| 445 |
gr.Markdown("# Winning performance by each tool")
|
| 446 |
|
|
|
|
| 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_requests,
|
| 31 |
)
|
| 32 |
|
| 33 |
from tabs.tool_accuracy import (
|
|
|
|
| 145 |
)
|
| 146 |
|
| 147 |
df6 = pd.read_parquet(winning_df)
|
| 148 |
+
|
| 149 |
+
# daily_mech_requests.parquet
|
| 150 |
+
daily_mech_req_df = hf_hub_download(
|
| 151 |
+
repo_id="valory/Olas-predict-dataset",
|
| 152 |
+
filename="daily_mech_requests.parquet",
|
| 153 |
+
repo_type="dataset",
|
| 154 |
+
)
|
| 155 |
+
|
| 156 |
+
df7 = pd.read_parquet(daily_mech_req_df)
|
| 157 |
+
return df1, df2, df3, df4, df5, df6, df7
|
| 158 |
|
| 159 |
|
| 160 |
def prepare_data():
|
|
|
|
| 168 |
invalid_trades,
|
| 169 |
unknown_trades,
|
| 170 |
winning_df,
|
| 171 |
+
daily_mech_requests,
|
| 172 |
) = load_all_data()
|
| 173 |
print(trades_df.info())
|
| 174 |
|
|
|
|
| 197 |
invalid_trades,
|
| 198 |
unknown_trades,
|
| 199 |
winning_df,
|
| 200 |
+
daily_mech_requests,
|
| 201 |
)
|
| 202 |
|
| 203 |
|
|
|
|
| 208 |
invalid_trades,
|
| 209 |
unknown_trades,
|
| 210 |
winning_df,
|
| 211 |
+
daily_mech_requests,
|
| 212 |
) = prepare_data()
|
| 213 |
trades_df = trades_df.sort_values(by="creation_timestamp", ascending=True)
|
| 214 |
unknown_trades = unknown_trades.sort_values(by="creation_timestamp", ascending=True)
|
|
|
|
| 453 |
winning_selector
|
| 454 |
with gr.Row():
|
| 455 |
winning_plot
|
| 456 |
+
with gr.Row():
|
| 457 |
+
gr.Markdown("# Daily mech requests by each tool in Pearl markets")
|
| 458 |
|
| 459 |
+
with gr.Row():
|
| 460 |
+
daily_pearl_requests_plot = get_daily_mech_requests(
|
| 461 |
+
daily_mech_req_df=daily_mech_requests, market_creator="pearl"
|
| 462 |
+
)
|
| 463 |
+
with gr.Row():
|
| 464 |
+
gr.Markdown("# Daily mech requests by each tool in Quickstart markets")
|
| 465 |
+
|
| 466 |
+
with gr.Row():
|
| 467 |
+
daily_qs_requests_plot = get_daily_mech_requests(
|
| 468 |
+
daily_mech_req_df=daily_mech_requests, market_creator="quickstart"
|
| 469 |
+
)
|
| 470 |
with gr.Row():
|
| 471 |
gr.Markdown("# Winning performance by each tool")
|
| 472 |
|
tabs/tool_win.py
CHANGED
|
@@ -1,16 +1,30 @@
|
|
| 1 |
import pandas as pd
|
| 2 |
import gradio as gr
|
| 3 |
-
|
| 4 |
from tabs.metrics import tool_metric_choices
|
| 5 |
import plotly.express as px
|
| 6 |
|
| 7 |
|
| 8 |
HEIGHT = 600
|
| 9 |
WIDTH = 1000
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
|
| 12 |
def prepare_tools(tools: pd.DataFrame) -> pd.DataFrame:
|
| 13 |
-
tools["request_time"] = pd.to_datetime(tools["request_time"])
|
|
|
|
| 14 |
tools = tools.sort_values(by="request_time", ascending=True)
|
| 15 |
|
| 16 |
tools["request_month_year_week"] = (
|
|
@@ -143,3 +157,57 @@ def integrated_tool_winnings_by_tool_per_market(
|
|
| 143 |
fig.update_layout(width=WIDTH, height=HEIGHT)
|
| 144 |
fig.update_xaxes(tickformat="%b %d\n%Y")
|
| 145 |
return gr.Plot(value=fig)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import pandas as pd
|
| 2 |
import gradio as gr
|
| 3 |
+
import numpy as np
|
| 4 |
from tabs.metrics import tool_metric_choices
|
| 5 |
import plotly.express as px
|
| 6 |
|
| 7 |
|
| 8 |
HEIGHT = 600
|
| 9 |
WIDTH = 1000
|
| 10 |
+
tools_palette = {
|
| 11 |
+
"prediction-request-reasoning": "darkorchid",
|
| 12 |
+
"claude-prediction-offline": "rebeccapurple",
|
| 13 |
+
"prediction-request-reasoning-claude": "slateblue",
|
| 14 |
+
"prediction-request-rag-claude": "steelblue",
|
| 15 |
+
"prediction-online": "darkcyan",
|
| 16 |
+
"prediction-offline": "mediumaquamarine",
|
| 17 |
+
"claude-prediction-online": "mediumseagreen",
|
| 18 |
+
"prediction-online-sme": "yellowgreen",
|
| 19 |
+
"prediction-url-cot-claude": "gold",
|
| 20 |
+
"prediction-offline-sme": "orange",
|
| 21 |
+
"prediction-request-rag": "chocolate",
|
| 22 |
+
}
|
| 23 |
|
| 24 |
|
| 25 |
def prepare_tools(tools: pd.DataFrame) -> pd.DataFrame:
|
| 26 |
+
tools["request_time"] = pd.to_datetime(tools["request_time"], utc=True)
|
| 27 |
+
tools["request_date"] = tools["request_time"].dt.date
|
| 28 |
tools = tools.sort_values(by="request_time", ascending=True)
|
| 29 |
|
| 30 |
tools["request_month_year_week"] = (
|
|
|
|
| 157 |
fig.update_layout(width=WIDTH, height=HEIGHT)
|
| 158 |
fig.update_xaxes(tickformat="%b %d\n%Y")
|
| 159 |
return gr.Plot(value=fig)
|
| 160 |
+
|
| 161 |
+
|
| 162 |
+
def get_daily_mech_requests(
|
| 163 |
+
daily_mech_req_df: pd.DataFrame, market_creator: str
|
| 164 |
+
) -> gr.Plot:
|
| 165 |
+
|
| 166 |
+
if market_creator == "pearl":
|
| 167 |
+
daily_mech_req_per_tool = daily_mech_req_df.loc[
|
| 168 |
+
daily_mech_req_df["market_creator"] == "pearl"
|
| 169 |
+
]
|
| 170 |
+
else: # quickstart
|
| 171 |
+
daily_mech_req_per_tool = daily_mech_req_df.loc[
|
| 172 |
+
daily_mech_req_df["market_creator"] == "quickstart"
|
| 173 |
+
]
|
| 174 |
+
|
| 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 |
+
)
|
| 181 |
+
|
| 182 |
+
# Sort the columns for each row independently
|
| 183 |
+
sorted_values = np.sort(pivoted.values, axis=1)[
|
| 184 |
+
:, ::-1
|
| 185 |
+
] # sort and reverse (descending)
|
| 186 |
+
sorted_columns = np.argsort(pivoted.values, axis=1)[:, ::-1] # get sorting indices
|
| 187 |
+
|
| 188 |
+
sorted_df = pd.DataFrame(
|
| 189 |
+
sorted_values,
|
| 190 |
+
index=pivoted.index,
|
| 191 |
+
columns=[
|
| 192 |
+
pivoted.columns[i] for i in sorted_columns[0]
|
| 193 |
+
], # use first row's order
|
| 194 |
+
)
|
| 195 |
+
|
| 196 |
+
sorted_long = sorted_df.reset_index().melt(
|
| 197 |
+
id_vars=["request_date"], var_name="tool", value_name="total_mech_requests"
|
| 198 |
+
)
|
| 199 |
+
|
| 200 |
+
fig = px.bar(
|
| 201 |
+
sorted_long,
|
| 202 |
+
x="request_date",
|
| 203 |
+
y="total_mech_requests",
|
| 204 |
+
color="tool",
|
| 205 |
+
color_discrete_map=tools_palette,
|
| 206 |
+
)
|
| 207 |
+
fig.update_layout(
|
| 208 |
+
xaxis_title="Day of the request",
|
| 209 |
+
yaxis_title="Total daily mech requests",
|
| 210 |
+
# legend=dict(yanchor="top", y=0.5),
|
| 211 |
+
)
|
| 212 |
+
fig.update_layout(width=WIDTH, height=HEIGHT)
|
| 213 |
+
return gr.Plot(value=fig)
|