cyberosa
commited on
Commit
·
f22dba5
1
Parent(s):
12c9b02
error distribution by mech address
Browse files- app.py +19 -1
- tabs/error.py +37 -0
app.py
CHANGED
|
@@ -47,6 +47,7 @@ from tabs.error import (
|
|
| 47 |
plot_error_data_by_market,
|
| 48 |
get_error_data_overall_by_market,
|
| 49 |
plot_tool_error_data_by_market,
|
|
|
|
| 50 |
)
|
| 51 |
|
| 52 |
from tabs.about import about_olas_predict, about_this_dashboard
|
|
@@ -154,7 +155,15 @@ def load_all_data():
|
|
| 154 |
)
|
| 155 |
|
| 156 |
df7 = pd.read_parquet(daily_mech_req_df)
|
| 157 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
|
| 159 |
|
| 160 |
def prepare_data():
|
|
@@ -169,6 +178,7 @@ def prepare_data():
|
|
| 169 |
unknown_trades,
|
| 170 |
winning_df,
|
| 171 |
daily_mech_requests,
|
|
|
|
| 172 |
) = load_all_data()
|
| 173 |
print(trades_df.info())
|
| 174 |
|
|
@@ -572,6 +582,14 @@ with demo:
|
|
| 572 |
with gr.Row():
|
| 573 |
tool_error_plot
|
| 574 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 575 |
with gr.Row():
|
| 576 |
gr.Markdown("# Tools distribution of errors per week")
|
| 577 |
|
|
|
|
| 47 |
plot_error_data_by_market,
|
| 48 |
get_error_data_overall_by_market,
|
| 49 |
plot_tool_error_data_by_market,
|
| 50 |
+
plot_weekly_errors_by_mech,
|
| 51 |
)
|
| 52 |
|
| 53 |
from tabs.about import about_olas_predict, about_this_dashboard
|
|
|
|
| 155 |
)
|
| 156 |
|
| 157 |
df7 = pd.read_parquet(daily_mech_req_df)
|
| 158 |
+
|
| 159 |
+
# errors by mech
|
| 160 |
+
errors_by_mech = hf_hub_download(
|
| 161 |
+
repo_id="valory/Olas-predict-dataset",
|
| 162 |
+
filename="errors_by_mech.parquet",
|
| 163 |
+
repo_type="dataset",
|
| 164 |
+
)
|
| 165 |
+
df8 = pd.read_parquet(errors_by_mech)
|
| 166 |
+
return df1, df2, df3, df4, df5, df6, df7, df8
|
| 167 |
|
| 168 |
|
| 169 |
def prepare_data():
|
|
|
|
| 178 |
unknown_trades,
|
| 179 |
winning_df,
|
| 180 |
daily_mech_requests,
|
| 181 |
+
errors_by_mech,
|
| 182 |
) = load_all_data()
|
| 183 |
print(trades_df.info())
|
| 184 |
|
|
|
|
| 582 |
with gr.Row():
|
| 583 |
tool_error_plot
|
| 584 |
|
| 585 |
+
with gr.Row():
|
| 586 |
+
gr.Markdown("# Weekly Error distribution per Mech address")
|
| 587 |
+
|
| 588 |
+
with gr.Row():
|
| 589 |
+
errors_by_mech = plot_weekly_errors_by_mech(
|
| 590 |
+
errors_by_mech=errors_by_mech
|
| 591 |
+
)
|
| 592 |
+
|
| 593 |
with gr.Row():
|
| 594 |
gr.Markdown("# Tools distribution of errors per week")
|
| 595 |
|
tabs/error.py
CHANGED
|
@@ -126,3 +126,40 @@ def plot_week_error_data_by_market(error_df: pd.DataFrame, week: str) -> gr.Plot
|
|
| 126 |
fig.update_layout(width=WIDTH, height=HEIGHT)
|
| 127 |
fig.update_xaxes(tickformat="%b %d\n%Y")
|
| 128 |
return gr.Plot(value=fig)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
fig.update_layout(width=WIDTH, height=HEIGHT)
|
| 127 |
fig.update_xaxes(tickformat="%b %d\n%Y")
|
| 128 |
return gr.Plot(value=fig)
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
def plot_weekly_errors_by_mech(errors_by_mech: pd.DataFrame) -> gr.Plot:
|
| 132 |
+
"""Function to plot the weekly errors by mech address"""
|
| 133 |
+
unique_mech_addresses = errors_by_mech["mech_address"].unique()
|
| 134 |
+
|
| 135 |
+
for mech_address in unique_mech_addresses:
|
| 136 |
+
# Filter the data for the current mech_address
|
| 137 |
+
filtered_data = errors_by_mech[errors_by_mech["mech_address"] == mech_address]
|
| 138 |
+
|
| 139 |
+
# Create the bar chart for the filtered data
|
| 140 |
+
fig = px.bar(
|
| 141 |
+
filtered_data,
|
| 142 |
+
x="request_month_year_week",
|
| 143 |
+
y="requests",
|
| 144 |
+
color="error_cat",
|
| 145 |
+
barmode="group",
|
| 146 |
+
color_discrete_sequence=["green", "orange"],
|
| 147 |
+
title=f"Error distribution for Mech Address: {mech_address}",
|
| 148 |
+
labels={
|
| 149 |
+
"requestmonthyearweek": "Month-Year-Week",
|
| 150 |
+
"requests": "Number of Requests",
|
| 151 |
+
"error_cat": "Error Category",
|
| 152 |
+
"errors_percentage": "Percentage",
|
| 153 |
+
},
|
| 154 |
+
text="errors_percentage",
|
| 155 |
+
height=HEIGHT,
|
| 156 |
+
width=WIDTH,
|
| 157 |
+
)
|
| 158 |
+
fig.update_traces(
|
| 159 |
+
texttemplate="%{y} (%{text:.2f}%)",
|
| 160 |
+
textposition="outside",
|
| 161 |
+
textangle=0,
|
| 162 |
+
cliponaxis=False,
|
| 163 |
+
)
|
| 164 |
+
fig.update_xaxes(tickformat="%b %d\n%Y")
|
| 165 |
+
return gr.Plot(value=fig)
|