cyberosa commited on
Commit
2467f4b
·
1 Parent(s): fe854e6

fixing the mech requests from top three accurate tools

Browse files
Files changed (2) hide show
  1. app.py +8 -9
  2. tabs/tool_accuracy.py +3 -10
app.py CHANGED
@@ -165,13 +165,13 @@ def load_all_data():
165
  )
166
  df8 = pd.read_parquet(errors_by_mech)
167
 
168
- # Read pearl_agents.parquet
169
- pearl_agents_df = hf_hub_download(
170
  repo_id="valory/Olas-predict-dataset",
171
- filename="pearl_agents.parquet",
172
  repo_type="dataset",
173
  )
174
- df9 = pd.read_parquet(pearl_agents_df)
175
  return df1, df2, df3, df4, df5, df6, df7, df8, df9
176
 
177
 
@@ -188,7 +188,7 @@ def prepare_data():
188
  winning_df,
189
  daily_mech_requests,
190
  errors_by_mech,
191
- pearl_agents_df,
192
  ) = load_all_data()
193
  print(trades_df.info())
194
 
@@ -222,7 +222,7 @@ def prepare_data():
222
  winning_df,
223
  daily_mech_requests,
224
  errors_by_mech,
225
- pearl_agents_df,
226
  )
227
 
228
 
@@ -235,7 +235,7 @@ def prepare_data():
235
  winning_df,
236
  daily_mech_requests,
237
  errors_by_mech,
238
- pearl_agents_df,
239
  ) = prepare_data()
240
  trades_df = trades_df.sort_values(by="creation_timestamp", ascending=True)
241
  unknown_trades = unknown_trades.sort_values(by="creation_timestamp", ascending=True)
@@ -554,9 +554,8 @@ with demo:
554
  )
555
  with gr.Row():
556
  _ = plot_mech_requests_topthree_tools(
557
- daily_mech_requests=daily_mech_requests,
558
  tools_accuracy_info=tools_accuracy_info,
559
- pearl_agents=pearl_agents_df,
560
  top=3,
561
  )
562
 
 
165
  )
166
  df8 = pd.read_parquet(errors_by_mech)
167
 
168
+ # Read daily_mech_requests_by_pearl_agents.parquet
169
+ daily_mech_requests_by_pearl_agents = hf_hub_download(
170
  repo_id="valory/Olas-predict-dataset",
171
+ filename="daily_mech_requests_by_pearl_agents.parquet",
172
  repo_type="dataset",
173
  )
174
+ df9 = pd.read_parquet(daily_mech_requests_by_pearl_agents)
175
  return df1, df2, df3, df4, df5, df6, df7, df8, df9
176
 
177
 
 
188
  winning_df,
189
  daily_mech_requests,
190
  errors_by_mech,
191
+ daily_mech_requests_by_pearl_agents,
192
  ) = load_all_data()
193
  print(trades_df.info())
194
 
 
222
  winning_df,
223
  daily_mech_requests,
224
  errors_by_mech,
225
+ daily_mech_requests_by_pearl_agents,
226
  )
227
 
228
 
 
235
  winning_df,
236
  daily_mech_requests,
237
  errors_by_mech,
238
+ daily_mech_request_by_pearl_agents,
239
  ) = prepare_data()
240
  trades_df = trades_df.sort_values(by="creation_timestamp", ascending=True)
241
  unknown_trades = unknown_trades.sort_values(by="creation_timestamp", ascending=True)
 
554
  )
555
  with gr.Row():
556
  _ = plot_mech_requests_topthree_tools(
557
+ daily_mech_requests=daily_mech_requests_by_pearl_agents,
558
  tools_accuracy_info=tools_accuracy_info,
 
559
  top=3,
560
  )
561
 
tabs/tool_accuracy.py CHANGED
@@ -135,9 +135,8 @@ def plot_tools_weighted_accuracy_rotated_graph(
135
 
136
 
137
  def plot_mech_requests_topthree_tools(
138
- daily_mech_requests: pd.DataFrame,
139
  tools_accuracy_info: pd.DataFrame,
140
- pearl_agents: pd.DataFrame,
141
  top: int,
142
  ):
143
  """Function to plot the percentage of mech requests from the top three tools only for pearl agents"""
@@ -146,18 +145,12 @@ def plot_mech_requests_topthree_tools(
146
  by="tool_accuracy", ascending=False
147
  ).head(top)
148
  top_tools = top_tools.tool.tolist()
149
- # Get the list of unique addresses from the daa_pearl_df
150
- unique_addresses = pearl_agents["safe_address"].unique()
151
- # Filter the weekly_roi_df to include only those addresses
152
- daily_mech_requests_local_copy = daily_mech_requests[
153
- daily_mech_requests["trader_address"].isin(unique_addresses)
154
- ].copy()
155
 
156
  # Filter the daily mech requests for the top three tools
157
 
158
  # Get the daily total of mech requests no matter the tool
159
  total_daily_mech_requests = (
160
- daily_mech_requests_local_copy.groupby(["request_date"])
161
  .agg({"total_mech_requests": "sum"})
162
  .reset_index()
163
  )
@@ -168,7 +161,7 @@ def plot_mech_requests_topthree_tools(
168
  )
169
  # Merge the total daily mech requests with the daily mech requests
170
  daily_mech_requests_local_copy = pd.merge(
171
- daily_mech_requests_local_copy,
172
  total_daily_mech_requests,
173
  on="request_date",
174
  how="left",
 
135
 
136
 
137
  def plot_mech_requests_topthree_tools(
138
+ daily_mech_requests_by_pearl_agents: pd.DataFrame,
139
  tools_accuracy_info: pd.DataFrame,
 
140
  top: int,
141
  ):
142
  """Function to plot the percentage of mech requests from the top three tools only for pearl agents"""
 
145
  by="tool_accuracy", ascending=False
146
  ).head(top)
147
  top_tools = top_tools.tool.tolist()
 
 
 
 
 
 
148
 
149
  # Filter the daily mech requests for the top three tools
150
 
151
  # Get the daily total of mech requests no matter the tool
152
  total_daily_mech_requests = (
153
+ daily_mech_requests_by_pearl_agents.groupby(["request_date"])
154
  .agg({"total_mech_requests": "sum"})
155
  .reset_index()
156
  )
 
161
  )
162
  # Merge the total daily mech requests with the daily mech requests
163
  daily_mech_requests_local_copy = pd.merge(
164
+ daily_mech_requests_by_pearl_agents,
165
  total_daily_mech_requests,
166
  on="request_date",
167
  how="left",