cyberosa
commited on
Commit
·
348d031
1
Parent(s):
d8fe1ce
adding tools accuracy info
Browse files- notebooks/analysis.ipynb +458 -4
- scripts/profitability.py +2 -4
- scripts/pull_data.py +13 -0
- scripts/tools.py +36 -14
notebooks/analysis.ipynb
CHANGED
|
@@ -16,9 +16,463 @@
|
|
| 16 |
"metadata": {},
|
| 17 |
"outputs": [],
|
| 18 |
"source": [
|
| 19 |
-
"fpmms = pd.read_parquet('
|
| 20 |
-
"tools = pd.read_parquet('
|
| 21 |
-
"trades = pd.read_parquet('
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
| 2049 |
"nbconvert_exporter": "python",
|
| 2050 |
"pygments_lexer": "ipython3",
|
| 2051 |
-
"version": "3.
|
| 2052 |
}
|
| 2053 |
},
|
| 2054 |
"nbformat": 4,
|
|
|
|
| 16 |
"metadata": {},
|
| 17 |
"outputs": [],
|
| 18 |
"source": [
|
| 19 |
+
"fpmms = pd.read_parquet('../data/fpmms.parquet')\n",
|
| 20 |
+
"tools = pd.read_parquet('../data/tools.parquet')\n",
|
| 21 |
+
"trades = pd.read_parquet('../data/all_trades_profitability.parquet')"
|
| 22 |
+
]
|
| 23 |
+
},
|
| 24 |
+
{
|
| 25 |
+
"cell_type": "code",
|
| 26 |
+
"execution_count": 3,
|
| 27 |
+
"metadata": {},
|
| 28 |
+
"outputs": [],
|
| 29 |
+
"source": [
|
| 30 |
+
"INC_TOOLS = [\n",
|
| 31 |
+
" \"prediction-online\",\n",
|
| 32 |
+
" \"prediction-offline\",\n",
|
| 33 |
+
" \"claude-prediction-online\",\n",
|
| 34 |
+
" \"claude-prediction-offline\",\n",
|
| 35 |
+
" \"prediction-offline-sme\",\n",
|
| 36 |
+
" \"prediction-online-sme\",\n",
|
| 37 |
+
" \"prediction-request-rag\",\n",
|
| 38 |
+
" \"prediction-request-reasoning\",\n",
|
| 39 |
+
" \"prediction-url-cot-claude\",\n",
|
| 40 |
+
" \"prediction-request-rag-claude\",\n",
|
| 41 |
+
" \"prediction-request-reasoning-claude\",\n",
|
| 42 |
+
"]"
|
| 43 |
+
]
|
| 44 |
+
},
|
| 45 |
+
{
|
| 46 |
+
"cell_type": "code",
|
| 47 |
+
"execution_count": 4,
|
| 48 |
+
"metadata": {},
|
| 49 |
+
"outputs": [
|
| 50 |
+
{
|
| 51 |
+
"data": {
|
| 52 |
+
"text/html": [
|
| 53 |
+
"<div>\n",
|
| 54 |
+
"<style scoped>\n",
|
| 55 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
| 56 |
+
" vertical-align: middle;\n",
|
| 57 |
+
" }\n",
|
| 58 |
+
"\n",
|
| 59 |
+
" .dataframe tbody tr th {\n",
|
| 60 |
+
" vertical-align: top;\n",
|
| 61 |
+
" }\n",
|
| 62 |
+
"\n",
|
| 63 |
+
" .dataframe thead th {\n",
|
| 64 |
+
" text-align: right;\n",
|
| 65 |
+
" }\n",
|
| 66 |
+
"</style>\n",
|
| 67 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
| 68 |
+
" <thead>\n",
|
| 69 |
+
" <tr style=\"text-align: right;\">\n",
|
| 70 |
+
" <th>win</th>\n",
|
| 71 |
+
" <th>tool</th>\n",
|
| 72 |
+
" <th>tool_accuracy</th>\n",
|
| 73 |
+
" <th>total_requests</th>\n",
|
| 74 |
+
" </tr>\n",
|
| 75 |
+
" </thead>\n",
|
| 76 |
+
" <tbody>\n",
|
| 77 |
+
" <tr>\n",
|
| 78 |
+
" <th>0</th>\n",
|
| 79 |
+
" <td>claude-prediction-offline</td>\n",
|
| 80 |
+
" <td>66.308244</td>\n",
|
| 81 |
+
" <td>279</td>\n",
|
| 82 |
+
" </tr>\n",
|
| 83 |
+
" <tr>\n",
|
| 84 |
+
" <th>1</th>\n",
|
| 85 |
+
" <td>claude-prediction-online</td>\n",
|
| 86 |
+
" <td>58.914027</td>\n",
|
| 87 |
+
" <td>1105</td>\n",
|
| 88 |
+
" </tr>\n",
|
| 89 |
+
" <tr>\n",
|
| 90 |
+
" <th>2</th>\n",
|
| 91 |
+
" <td>prediction-offline</td>\n",
|
| 92 |
+
" <td>67.717915</td>\n",
|
| 93 |
+
" <td>2283</td>\n",
|
| 94 |
+
" </tr>\n",
|
| 95 |
+
" <tr>\n",
|
| 96 |
+
" <th>3</th>\n",
|
| 97 |
+
" <td>prediction-offline-sme</td>\n",
|
| 98 |
+
" <td>55.555556</td>\n",
|
| 99 |
+
" <td>18</td>\n",
|
| 100 |
+
" </tr>\n",
|
| 101 |
+
" <tr>\n",
|
| 102 |
+
" <th>4</th>\n",
|
| 103 |
+
" <td>prediction-online</td>\n",
|
| 104 |
+
" <td>65.459066</td>\n",
|
| 105 |
+
" <td>5631</td>\n",
|
| 106 |
+
" </tr>\n",
|
| 107 |
+
" <tr>\n",
|
| 108 |
+
" <th>5</th>\n",
|
| 109 |
+
" <td>prediction-online-sme</td>\n",
|
| 110 |
+
" <td>67.417656</td>\n",
|
| 111 |
+
" <td>8167</td>\n",
|
| 112 |
+
" </tr>\n",
|
| 113 |
+
" <tr>\n",
|
| 114 |
+
" <th>6</th>\n",
|
| 115 |
+
" <td>prediction-request-rag</td>\n",
|
| 116 |
+
" <td>64.217072</td>\n",
|
| 117 |
+
" <td>1769</td>\n",
|
| 118 |
+
" </tr>\n",
|
| 119 |
+
" <tr>\n",
|
| 120 |
+
" <th>7</th>\n",
|
| 121 |
+
" <td>prediction-request-rag-claude</td>\n",
|
| 122 |
+
" <td>69.554566</td>\n",
|
| 123 |
+
" <td>4490</td>\n",
|
| 124 |
+
" </tr>\n",
|
| 125 |
+
" <tr>\n",
|
| 126 |
+
" <th>8</th>\n",
|
| 127 |
+
" <td>prediction-request-reasoning</td>\n",
|
| 128 |
+
" <td>68.813594</td>\n",
|
| 129 |
+
" <td>9828</td>\n",
|
| 130 |
+
" </tr>\n",
|
| 131 |
+
" <tr>\n",
|
| 132 |
+
" <th>9</th>\n",
|
| 133 |
+
" <td>prediction-request-reasoning-claude</td>\n",
|
| 134 |
+
" <td>68.910256</td>\n",
|
| 135 |
+
" <td>2184</td>\n",
|
| 136 |
+
" </tr>\n",
|
| 137 |
+
" <tr>\n",
|
| 138 |
+
" <th>10</th>\n",
|
| 139 |
+
" <td>prediction-url-cot-claude</td>\n",
|
| 140 |
+
" <td>64.584980</td>\n",
|
| 141 |
+
" <td>1265</td>\n",
|
| 142 |
+
" </tr>\n",
|
| 143 |
+
" </tbody>\n",
|
| 144 |
+
"</table>\n",
|
| 145 |
+
"</div>"
|
| 146 |
+
],
|
| 147 |
+
"text/plain": [
|
| 148 |
+
"win tool tool_accuracy total_requests\n",
|
| 149 |
+
"0 claude-prediction-offline 66.308244 279\n",
|
| 150 |
+
"1 claude-prediction-online 58.914027 1105\n",
|
| 151 |
+
"2 prediction-offline 67.717915 2283\n",
|
| 152 |
+
"3 prediction-offline-sme 55.555556 18\n",
|
| 153 |
+
"4 prediction-online 65.459066 5631\n",
|
| 154 |
+
"5 prediction-online-sme 67.417656 8167\n",
|
| 155 |
+
"6 prediction-request-rag 64.217072 1769\n",
|
| 156 |
+
"7 prediction-request-rag-claude 69.554566 4490\n",
|
| 157 |
+
"8 prediction-request-reasoning 68.813594 9828\n",
|
| 158 |
+
"9 prediction-request-reasoning-claude 68.910256 2184\n",
|
| 159 |
+
"10 prediction-url-cot-claude 64.584980 1265"
|
| 160 |
+
]
|
| 161 |
+
},
|
| 162 |
+
"execution_count": 4,
|
| 163 |
+
"metadata": {},
|
| 164 |
+
"output_type": "execute_result"
|
| 165 |
+
}
|
| 166 |
+
],
|
| 167 |
+
"source": [
|
| 168 |
+
"tools_inc = tools[tools['tool'].isin(INC_TOOLS)]\n",
|
| 169 |
+
"# filtering errors\n",
|
| 170 |
+
"tools_non_error = tools_inc[tools_inc['error'] != 1]\n",
|
| 171 |
+
"tools_non_error.loc[:, 'currentAnswer'] = tools_non_error['currentAnswer'].replace({'no': 'No', 'yes': 'Yes'})\n",
|
| 172 |
+
"tools_non_error = tools_non_error[tools_non_error['currentAnswer'].isin(['Yes', 'No'])]\n",
|
| 173 |
+
"tools_non_error = tools_non_error[tools_non_error['vote'].isin(['Yes', 'No'])]\n",
|
| 174 |
+
"tools_non_error['win'] = (tools_non_error['currentAnswer'] == tools_non_error['vote']).astype(int)\n",
|
| 175 |
+
"tools_non_error.columns = tools_non_error.columns.astype(str)\n",
|
| 176 |
+
"wins = tools_non_error.groupby(['tool', 'win']).size().unstack().fillna(0)\n",
|
| 177 |
+
"wins['tool_accuracy'] = (wins[1] / (wins[0] + wins[1])) * 100\n",
|
| 178 |
+
"wins.reset_index(inplace=True)\n",
|
| 179 |
+
"wins['total_requests'] = wins[0] + wins[1]\n",
|
| 180 |
+
"wins.columns = wins.columns.astype(str)\n",
|
| 181 |
+
"wins = wins[[\"tool\", \"tool_accuracy\", \"total_requests\"]]\n",
|
| 182 |
+
"wins"
|
| 183 |
+
]
|
| 184 |
+
},
|
| 185 |
+
{
|
| 186 |
+
"cell_type": "code",
|
| 187 |
+
"execution_count": 8,
|
| 188 |
+
"metadata": {},
|
| 189 |
+
"outputs": [
|
| 190 |
+
{
|
| 191 |
+
"data": {
|
| 192 |
+
"text/html": [
|
| 193 |
+
"<div>\n",
|
| 194 |
+
"<style scoped>\n",
|
| 195 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
| 196 |
+
" vertical-align: middle;\n",
|
| 197 |
+
" }\n",
|
| 198 |
+
"\n",
|
| 199 |
+
" .dataframe tbody tr th {\n",
|
| 200 |
+
" vertical-align: top;\n",
|
| 201 |
+
" }\n",
|
| 202 |
+
"\n",
|
| 203 |
+
" .dataframe thead th {\n",
|
| 204 |
+
" text-align: right;\n",
|
| 205 |
+
" }\n",
|
| 206 |
+
"</style>\n",
|
| 207 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
| 208 |
+
" <thead>\n",
|
| 209 |
+
" <tr style=\"text-align: right;\">\n",
|
| 210 |
+
" <th></th>\n",
|
| 211 |
+
" <th>min</th>\n",
|
| 212 |
+
" <th>max</th>\n",
|
| 213 |
+
" </tr>\n",
|
| 214 |
+
" <tr>\n",
|
| 215 |
+
" <th>tool</th>\n",
|
| 216 |
+
" <th></th>\n",
|
| 217 |
+
" <th></th>\n",
|
| 218 |
+
" </tr>\n",
|
| 219 |
+
" </thead>\n",
|
| 220 |
+
" <tbody>\n",
|
| 221 |
+
" <tr>\n",
|
| 222 |
+
" <th>claude-prediction-offline</th>\n",
|
| 223 |
+
" <td>2024-04-23 13:09:30</td>\n",
|
| 224 |
+
" <td>2024-06-10 00:31:30</td>\n",
|
| 225 |
+
" </tr>\n",
|
| 226 |
+
" <tr>\n",
|
| 227 |
+
" <th>claude-prediction-online</th>\n",
|
| 228 |
+
" <td>2024-04-12 12:24:20</td>\n",
|
| 229 |
+
" <td>2024-06-09 21:41:20</td>\n",
|
| 230 |
+
" </tr>\n",
|
| 231 |
+
" <tr>\n",
|
| 232 |
+
" <th>prediction-offline</th>\n",
|
| 233 |
+
" <td>2024-04-12 12:20:10</td>\n",
|
| 234 |
+
" <td>2024-06-08 23:45:00</td>\n",
|
| 235 |
+
" </tr>\n",
|
| 236 |
+
" <tr>\n",
|
| 237 |
+
" <th>prediction-offline-sme</th>\n",
|
| 238 |
+
" <td>2024-04-16 07:58:45</td>\n",
|
| 239 |
+
" <td>2024-04-29 20:45:15</td>\n",
|
| 240 |
+
" </tr>\n",
|
| 241 |
+
" <tr>\n",
|
| 242 |
+
" <th>prediction-online</th>\n",
|
| 243 |
+
" <td>2024-04-16 05:52:40</td>\n",
|
| 244 |
+
" <td>2024-06-09 21:47:20</td>\n",
|
| 245 |
+
" </tr>\n",
|
| 246 |
+
" <tr>\n",
|
| 247 |
+
" <th>prediction-online-sme</th>\n",
|
| 248 |
+
" <td>2024-04-12 11:51:30</td>\n",
|
| 249 |
+
" <td>2024-06-10 00:06:00</td>\n",
|
| 250 |
+
" </tr>\n",
|
| 251 |
+
" <tr>\n",
|
| 252 |
+
" <th>prediction-request-rag</th>\n",
|
| 253 |
+
" <td>2024-04-12 11:39:40</td>\n",
|
| 254 |
+
" <td>2024-06-09 21:17:45</td>\n",
|
| 255 |
+
" </tr>\n",
|
| 256 |
+
" <tr>\n",
|
| 257 |
+
" <th>prediction-request-rag-claude</th>\n",
|
| 258 |
+
" <td>2024-04-12 11:14:30</td>\n",
|
| 259 |
+
" <td>2024-06-07 11:42:30</td>\n",
|
| 260 |
+
" </tr>\n",
|
| 261 |
+
" <tr>\n",
|
| 262 |
+
" <th>prediction-request-reasoning</th>\n",
|
| 263 |
+
" <td>2024-04-12 11:57:05</td>\n",
|
| 264 |
+
" <td>2024-06-09 21:50:45</td>\n",
|
| 265 |
+
" </tr>\n",
|
| 266 |
+
" <tr>\n",
|
| 267 |
+
" <th>prediction-request-reasoning-claude</th>\n",
|
| 268 |
+
" <td>2024-04-12 11:53:55</td>\n",
|
| 269 |
+
" <td>2024-06-05 05:00:10</td>\n",
|
| 270 |
+
" </tr>\n",
|
| 271 |
+
" <tr>\n",
|
| 272 |
+
" <th>prediction-url-cot-claude</th>\n",
|
| 273 |
+
" <td>2024-04-12 11:37:15</td>\n",
|
| 274 |
+
" <td>2024-06-05 05:21:10</td>\n",
|
| 275 |
+
" </tr>\n",
|
| 276 |
+
" </tbody>\n",
|
| 277 |
+
"</table>\n",
|
| 278 |
+
"</div>"
|
| 279 |
+
],
|
| 280 |
+
"text/plain": [
|
| 281 |
+
" min max\n",
|
| 282 |
+
"tool \n",
|
| 283 |
+
"claude-prediction-offline 2024-04-23 13:09:30 2024-06-10 00:31:30\n",
|
| 284 |
+
"claude-prediction-online 2024-04-12 12:24:20 2024-06-09 21:41:20\n",
|
| 285 |
+
"prediction-offline 2024-04-12 12:20:10 2024-06-08 23:45:00\n",
|
| 286 |
+
"prediction-offline-sme 2024-04-16 07:58:45 2024-04-29 20:45:15\n",
|
| 287 |
+
"prediction-online 2024-04-16 05:52:40 2024-06-09 21:47:20\n",
|
| 288 |
+
"prediction-online-sme 2024-04-12 11:51:30 2024-06-10 00:06:00\n",
|
| 289 |
+
"prediction-request-rag 2024-04-12 11:39:40 2024-06-09 21:17:45\n",
|
| 290 |
+
"prediction-request-rag-claude 2024-04-12 11:14:30 2024-06-07 11:42:30\n",
|
| 291 |
+
"prediction-request-reasoning 2024-04-12 11:57:05 2024-06-09 21:50:45\n",
|
| 292 |
+
"prediction-request-reasoning-claude 2024-04-12 11:53:55 2024-06-05 05:00:10\n",
|
| 293 |
+
"prediction-url-cot-claude 2024-04-12 11:37:15 2024-06-05 05:21:10"
|
| 294 |
+
]
|
| 295 |
+
},
|
| 296 |
+
"execution_count": 8,
|
| 297 |
+
"metadata": {},
|
| 298 |
+
"output_type": "execute_result"
|
| 299 |
+
}
|
| 300 |
+
],
|
| 301 |
+
"source": [
|
| 302 |
+
"tools_inc = tools[tools['tool'].isin(INC_TOOLS)]\n",
|
| 303 |
+
"# filtering errors\n",
|
| 304 |
+
"tools_non_error = tools_inc[tools_inc['error'] != 1]\n",
|
| 305 |
+
"tools_non_error.loc[:, 'currentAnswer'] = tools_non_error['currentAnswer'].replace({'no': 'No', 'yes': 'Yes'})\n",
|
| 306 |
+
"tools_non_error = tools_non_error[tools_non_error['currentAnswer'].isin(['Yes', 'No'])]\n",
|
| 307 |
+
"tools_non_error = tools_non_error[tools_non_error['vote'].isin(['Yes', 'No'])]\n",
|
| 308 |
+
"tools_non_error['win'] = (tools_non_error['currentAnswer'] == tools_non_error['vote']).astype(int)\n",
|
| 309 |
+
"tools_non_error.columns = tools_non_error.columns.astype(str)\n",
|
| 310 |
+
"timeline = tools_non_error.groupby(['tool'])[\"request_time\"].agg([\"min\",\"max\"])\n",
|
| 311 |
+
"timeline"
|
| 312 |
+
]
|
| 313 |
+
},
|
| 314 |
+
{
|
| 315 |
+
"cell_type": "code",
|
| 316 |
+
"execution_count": 10,
|
| 317 |
+
"metadata": {},
|
| 318 |
+
"outputs": [
|
| 319 |
+
{
|
| 320 |
+
"data": {
|
| 321 |
+
"text/html": [
|
| 322 |
+
"<div>\n",
|
| 323 |
+
"<style scoped>\n",
|
| 324 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
| 325 |
+
" vertical-align: middle;\n",
|
| 326 |
+
" }\n",
|
| 327 |
+
"\n",
|
| 328 |
+
" .dataframe tbody tr th {\n",
|
| 329 |
+
" vertical-align: top;\n",
|
| 330 |
+
" }\n",
|
| 331 |
+
"\n",
|
| 332 |
+
" .dataframe thead th {\n",
|
| 333 |
+
" text-align: right;\n",
|
| 334 |
+
" }\n",
|
| 335 |
+
"</style>\n",
|
| 336 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
| 337 |
+
" <thead>\n",
|
| 338 |
+
" <tr style=\"text-align: right;\">\n",
|
| 339 |
+
" <th></th>\n",
|
| 340 |
+
" <th>tool</th>\n",
|
| 341 |
+
" <th>tool_accuracy</th>\n",
|
| 342 |
+
" <th>total_requests</th>\n",
|
| 343 |
+
" <th>min</th>\n",
|
| 344 |
+
" <th>max</th>\n",
|
| 345 |
+
" </tr>\n",
|
| 346 |
+
" </thead>\n",
|
| 347 |
+
" <tbody>\n",
|
| 348 |
+
" <tr>\n",
|
| 349 |
+
" <th>0</th>\n",
|
| 350 |
+
" <td>claude-prediction-offline</td>\n",
|
| 351 |
+
" <td>66.308244</td>\n",
|
| 352 |
+
" <td>279</td>\n",
|
| 353 |
+
" <td>2024-04-23 13:09:30</td>\n",
|
| 354 |
+
" <td>2024-06-10 00:31:30</td>\n",
|
| 355 |
+
" </tr>\n",
|
| 356 |
+
" <tr>\n",
|
| 357 |
+
" <th>1</th>\n",
|
| 358 |
+
" <td>claude-prediction-online</td>\n",
|
| 359 |
+
" <td>58.914027</td>\n",
|
| 360 |
+
" <td>1105</td>\n",
|
| 361 |
+
" <td>2024-04-12 12:24:20</td>\n",
|
| 362 |
+
" <td>2024-06-09 21:41:20</td>\n",
|
| 363 |
+
" </tr>\n",
|
| 364 |
+
" <tr>\n",
|
| 365 |
+
" <th>2</th>\n",
|
| 366 |
+
" <td>prediction-offline</td>\n",
|
| 367 |
+
" <td>67.717915</td>\n",
|
| 368 |
+
" <td>2283</td>\n",
|
| 369 |
+
" <td>2024-04-12 12:20:10</td>\n",
|
| 370 |
+
" <td>2024-06-08 23:45:00</td>\n",
|
| 371 |
+
" </tr>\n",
|
| 372 |
+
" <tr>\n",
|
| 373 |
+
" <th>3</th>\n",
|
| 374 |
+
" <td>prediction-offline-sme</td>\n",
|
| 375 |
+
" <td>55.555556</td>\n",
|
| 376 |
+
" <td>18</td>\n",
|
| 377 |
+
" <td>2024-04-16 07:58:45</td>\n",
|
| 378 |
+
" <td>2024-04-29 20:45:15</td>\n",
|
| 379 |
+
" </tr>\n",
|
| 380 |
+
" <tr>\n",
|
| 381 |
+
" <th>4</th>\n",
|
| 382 |
+
" <td>prediction-online</td>\n",
|
| 383 |
+
" <td>65.459066</td>\n",
|
| 384 |
+
" <td>5631</td>\n",
|
| 385 |
+
" <td>2024-04-16 05:52:40</td>\n",
|
| 386 |
+
" <td>2024-06-09 21:47:20</td>\n",
|
| 387 |
+
" </tr>\n",
|
| 388 |
+
" <tr>\n",
|
| 389 |
+
" <th>5</th>\n",
|
| 390 |
+
" <td>prediction-online-sme</td>\n",
|
| 391 |
+
" <td>67.417656</td>\n",
|
| 392 |
+
" <td>8167</td>\n",
|
| 393 |
+
" <td>2024-04-12 11:51:30</td>\n",
|
| 394 |
+
" <td>2024-06-10 00:06:00</td>\n",
|
| 395 |
+
" </tr>\n",
|
| 396 |
+
" <tr>\n",
|
| 397 |
+
" <th>6</th>\n",
|
| 398 |
+
" <td>prediction-request-rag</td>\n",
|
| 399 |
+
" <td>64.217072</td>\n",
|
| 400 |
+
" <td>1769</td>\n",
|
| 401 |
+
" <td>2024-04-12 11:39:40</td>\n",
|
| 402 |
+
" <td>2024-06-09 21:17:45</td>\n",
|
| 403 |
+
" </tr>\n",
|
| 404 |
+
" <tr>\n",
|
| 405 |
+
" <th>7</th>\n",
|
| 406 |
+
" <td>prediction-request-rag-claude</td>\n",
|
| 407 |
+
" <td>69.554566</td>\n",
|
| 408 |
+
" <td>4490</td>\n",
|
| 409 |
+
" <td>2024-04-12 11:14:30</td>\n",
|
| 410 |
+
" <td>2024-06-07 11:42:30</td>\n",
|
| 411 |
+
" </tr>\n",
|
| 412 |
+
" <tr>\n",
|
| 413 |
+
" <th>8</th>\n",
|
| 414 |
+
" <td>prediction-request-reasoning</td>\n",
|
| 415 |
+
" <td>68.813594</td>\n",
|
| 416 |
+
" <td>9828</td>\n",
|
| 417 |
+
" <td>2024-04-12 11:57:05</td>\n",
|
| 418 |
+
" <td>2024-06-09 21:50:45</td>\n",
|
| 419 |
+
" </tr>\n",
|
| 420 |
+
" <tr>\n",
|
| 421 |
+
" <th>9</th>\n",
|
| 422 |
+
" <td>prediction-request-reasoning-claude</td>\n",
|
| 423 |
+
" <td>68.910256</td>\n",
|
| 424 |
+
" <td>2184</td>\n",
|
| 425 |
+
" <td>2024-04-12 11:53:55</td>\n",
|
| 426 |
+
" <td>2024-06-05 05:00:10</td>\n",
|
| 427 |
+
" </tr>\n",
|
| 428 |
+
" <tr>\n",
|
| 429 |
+
" <th>10</th>\n",
|
| 430 |
+
" <td>prediction-url-cot-claude</td>\n",
|
| 431 |
+
" <td>64.584980</td>\n",
|
| 432 |
+
" <td>1265</td>\n",
|
| 433 |
+
" <td>2024-04-12 11:37:15</td>\n",
|
| 434 |
+
" <td>2024-06-05 05:21:10</td>\n",
|
| 435 |
+
" </tr>\n",
|
| 436 |
+
" </tbody>\n",
|
| 437 |
+
"</table>\n",
|
| 438 |
+
"</div>"
|
| 439 |
+
],
|
| 440 |
+
"text/plain": [
|
| 441 |
+
" tool tool_accuracy total_requests \\\n",
|
| 442 |
+
"0 claude-prediction-offline 66.308244 279 \n",
|
| 443 |
+
"1 claude-prediction-online 58.914027 1105 \n",
|
| 444 |
+
"2 prediction-offline 67.717915 2283 \n",
|
| 445 |
+
"3 prediction-offline-sme 55.555556 18 \n",
|
| 446 |
+
"4 prediction-online 65.459066 5631 \n",
|
| 447 |
+
"5 prediction-online-sme 67.417656 8167 \n",
|
| 448 |
+
"6 prediction-request-rag 64.217072 1769 \n",
|
| 449 |
+
"7 prediction-request-rag-claude 69.554566 4490 \n",
|
| 450 |
+
"8 prediction-request-reasoning 68.813594 9828 \n",
|
| 451 |
+
"9 prediction-request-reasoning-claude 68.910256 2184 \n",
|
| 452 |
+
"10 prediction-url-cot-claude 64.584980 1265 \n",
|
| 453 |
+
"\n",
|
| 454 |
+
" min max \n",
|
| 455 |
+
"0 2024-04-23 13:09:30 2024-06-10 00:31:30 \n",
|
| 456 |
+
"1 2024-04-12 12:24:20 2024-06-09 21:41:20 \n",
|
| 457 |
+
"2 2024-04-12 12:20:10 2024-06-08 23:45:00 \n",
|
| 458 |
+
"3 2024-04-16 07:58:45 2024-04-29 20:45:15 \n",
|
| 459 |
+
"4 2024-04-16 05:52:40 2024-06-09 21:47:20 \n",
|
| 460 |
+
"5 2024-04-12 11:51:30 2024-06-10 00:06:00 \n",
|
| 461 |
+
"6 2024-04-12 11:39:40 2024-06-09 21:17:45 \n",
|
| 462 |
+
"7 2024-04-12 11:14:30 2024-06-07 11:42:30 \n",
|
| 463 |
+
"8 2024-04-12 11:57:05 2024-06-09 21:50:45 \n",
|
| 464 |
+
"9 2024-04-12 11:53:55 2024-06-05 05:00:10 \n",
|
| 465 |
+
"10 2024-04-12 11:37:15 2024-06-05 05:21:10 "
|
| 466 |
+
]
|
| 467 |
+
},
|
| 468 |
+
"execution_count": 10,
|
| 469 |
+
"metadata": {},
|
| 470 |
+
"output_type": "execute_result"
|
| 471 |
+
}
|
| 472 |
+
],
|
| 473 |
+
"source": [
|
| 474 |
+
"total = wins.merge(timeline,how=\"left\", on=\"tool\")\n",
|
| 475 |
+
"total"
|
| 476 |
]
|
| 477 |
},
|
| 478 |
{
|
|
|
|
| 2502 |
"name": "python",
|
| 2503 |
"nbconvert_exporter": "python",
|
| 2504 |
"pygments_lexer": "ipython3",
|
| 2505 |
+
"version": "3.12.3"
|
| 2506 |
}
|
| 2507 |
},
|
| 2508 |
"nbformat": 4,
|
scripts/profitability.py
CHANGED
|
@@ -419,8 +419,6 @@ def prepare_profitalibity_data(rpc: str):
|
|
| 419 |
timestamp_60_days_ago = (DATETIME_60_DAYS_AGO).timestamp()
|
| 420 |
fpmmTrades = create_fpmmTrades(rpc, from_timestamp=timestamp_60_days_ago)
|
| 421 |
fpmmTrades.to_parquet(DATA_DIR / "fpmmTrades.parquet", index=False)
|
| 422 |
-
# This is not needed
|
| 423 |
-
# fpmmTrades = pd.read_parquet(DATA_DIR / "fpmmTrades.parquet")
|
| 424 |
|
| 425 |
# make sure trader_address is in the columns
|
| 426 |
assert "trader_address" in fpmmTrades.columns, "trader_address column not found"
|
|
@@ -610,7 +608,7 @@ def summary_analyse(df):
|
|
| 610 |
def run_profitability_analysis(rpc):
|
| 611 |
"""Create all trades analysis."""
|
| 612 |
|
| 613 |
-
# load dfs from
|
| 614 |
print("Preparing data...")
|
| 615 |
fpmmTrades, tools = prepare_profitalibity_data(rpc)
|
| 616 |
tools["trader_address"] = tools["trader_address"].str.lower()
|
|
@@ -623,7 +621,7 @@ def run_profitability_analysis(rpc):
|
|
| 623 |
print("Summarising trades...")
|
| 624 |
summary_df = summary_analyse(all_trades_df)
|
| 625 |
|
| 626 |
-
# save to
|
| 627 |
all_trades_df.to_parquet(DATA_DIR / "all_trades_profitability.parquet", index=False)
|
| 628 |
summary_df.to_parquet(DATA_DIR / "summary_profitability.parquet", index=False)
|
| 629 |
|
|
|
|
| 419 |
timestamp_60_days_ago = (DATETIME_60_DAYS_AGO).timestamp()
|
| 420 |
fpmmTrades = create_fpmmTrades(rpc, from_timestamp=timestamp_60_days_ago)
|
| 421 |
fpmmTrades.to_parquet(DATA_DIR / "fpmmTrades.parquet", index=False)
|
|
|
|
|
|
|
| 422 |
|
| 423 |
# make sure trader_address is in the columns
|
| 424 |
assert "trader_address" in fpmmTrades.columns, "trader_address column not found"
|
|
|
|
| 608 |
def run_profitability_analysis(rpc):
|
| 609 |
"""Create all trades analysis."""
|
| 610 |
|
| 611 |
+
# load dfs from data folder for analysis
|
| 612 |
print("Preparing data...")
|
| 613 |
fpmmTrades, tools = prepare_profitalibity_data(rpc)
|
| 614 |
tools["trader_address"] = tools["trader_address"].str.lower()
|
|
|
|
| 621 |
print("Summarising trades...")
|
| 622 |
summary_df = summary_analyse(all_trades_df)
|
| 623 |
|
| 624 |
+
# save to parquet
|
| 625 |
all_trades_df.to_parquet(DATA_DIR / "all_trades_profitability.parquet", index=False)
|
| 626 |
summary_df.to_parquet(DATA_DIR / "summary_profitability.parquet", index=False)
|
| 627 |
|
scripts/pull_data.py
CHANGED
|
@@ -17,7 +17,9 @@ from markets import (
|
|
| 17 |
from tools import (
|
| 18 |
etl as tools_etl,
|
| 19 |
DEFAULT_FILENAME as TOOLS_FILENAME,
|
|
|
|
| 20 |
)
|
|
|
|
| 21 |
from profitability import run_profitability_analysis
|
| 22 |
|
| 23 |
import gc
|
|
@@ -27,6 +29,7 @@ logging.basicConfig(level=logging.INFO)
|
|
| 27 |
SCRIPTS_DIR = Path(__file__).parent
|
| 28 |
ROOT_DIR = SCRIPTS_DIR.parent
|
| 29 |
DATA_DIR = ROOT_DIR / "data"
|
|
|
|
| 30 |
|
| 31 |
|
| 32 |
def get_question(text: str) -> str:
|
|
@@ -149,6 +152,16 @@ def weekly_analysis():
|
|
| 149 |
|
| 150 |
with open(DATA_DIR / "t_map.pkl", "wb") as f:
|
| 151 |
pickle.dump(t_map, f)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 152 |
# clean and release all memory
|
| 153 |
del tools
|
| 154 |
del fpmms
|
|
|
|
| 17 |
from tools import (
|
| 18 |
etl as tools_etl,
|
| 19 |
DEFAULT_FILENAME as TOOLS_FILENAME,
|
| 20 |
+
update_tools_accuracy,
|
| 21 |
)
|
| 22 |
+
from app import INC_TOOLS
|
| 23 |
from profitability import run_profitability_analysis
|
| 24 |
|
| 25 |
import gc
|
|
|
|
| 29 |
SCRIPTS_DIR = Path(__file__).parent
|
| 30 |
ROOT_DIR = SCRIPTS_DIR.parent
|
| 31 |
DATA_DIR = ROOT_DIR / "data"
|
| 32 |
+
ACCURACY_FILENAME = "tools_accuracy.csv"
|
| 33 |
|
| 34 |
|
| 35 |
def get_question(text: str) -> str:
|
|
|
|
| 152 |
|
| 153 |
with open(DATA_DIR / "t_map.pkl", "wb") as f:
|
| 154 |
pickle.dump(t_map, f)
|
| 155 |
+
|
| 156 |
+
# Computing tools accuracy information
|
| 157 |
+
print("Computing tool accuracy information")
|
| 158 |
+
# Check if the file exists
|
| 159 |
+
acc_data = None
|
| 160 |
+
if os.path.exists(DATA_DIR / ACCURACY_FILENAME):
|
| 161 |
+
acc_data = pd.read_csv(DATA_DIR / ACCURACY_FILENAME)
|
| 162 |
+
update_tools_accuracy(acc_data, tools, INC_TOOLS)
|
| 163 |
+
# TODO save acc_data into a CSV file
|
| 164 |
+
|
| 165 |
# clean and release all memory
|
| 166 |
del tools
|
| 167 |
del fpmms
|
scripts/tools.py
CHANGED
|
@@ -470,20 +470,6 @@ def etl(
|
|
| 470 |
|
| 471 |
transformed = transformer(contents)
|
| 472 |
|
| 473 |
-
# Remove appending data, always new files
|
| 474 |
-
# if os.path.exists(DATA_DIR / events_filename):
|
| 475 |
-
# old = pd.read_parquet(DATA_DIR / events_filename)
|
| 476 |
-
|
| 477 |
-
# # Reset index to avoid index conflicts
|
| 478 |
-
# old.reset_index(drop=True, inplace=True)
|
| 479 |
-
# transformed.reset_index(drop=True, inplace=True)
|
| 480 |
-
|
| 481 |
-
# # Concatenate DataFrames
|
| 482 |
-
# transformed = pd.concat([old, transformed], ignore_index=True)
|
| 483 |
-
|
| 484 |
-
# # Drop duplicates if necessary
|
| 485 |
-
# transformed.drop_duplicates(subset=REQUEST_ID_FIELD, inplace=True)
|
| 486 |
-
|
| 487 |
event_to_contents[event_name] = transformed.copy()
|
| 488 |
|
| 489 |
# Store progress
|
|
@@ -495,6 +481,42 @@ def etl(
|
|
| 495 |
return tools
|
| 496 |
|
| 497 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 498 |
if __name__ == "__main__":
|
| 499 |
RPCs = [
|
| 500 |
"https://lb.nodies.app/v1/406d8dcc043f4cb3959ed7d6673d311a",
|
|
|
|
| 470 |
|
| 471 |
transformed = transformer(contents)
|
| 472 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 473 |
event_to_contents[event_name] = transformed.copy()
|
| 474 |
|
| 475 |
# Store progress
|
|
|
|
| 481 |
return tools
|
| 482 |
|
| 483 |
|
| 484 |
+
def update_tools_accuracy(
|
| 485 |
+
tools_acc: pd.DataFrame, tools_df: pd.DataFrame, inc_tools: List[str]
|
| 486 |
+
) -> pd.DataFrame:
|
| 487 |
+
"""To compute/update the latest accuracy information for the different mech tools"""
|
| 488 |
+
|
| 489 |
+
# computation of the accuracy information
|
| 490 |
+
tools_inc = tools_df[tools_df["tool"].isin(inc_tools)]
|
| 491 |
+
# filtering errors
|
| 492 |
+
tools_non_error = tools_inc[tools_inc["error"] != 1]
|
| 493 |
+
tools_non_error.loc[:, "currentAnswer"] = tools_non_error["currentAnswer"].replace(
|
| 494 |
+
{"no": "No", "yes": "Yes"}
|
| 495 |
+
)
|
| 496 |
+
tools_non_error = tools_non_error[
|
| 497 |
+
tools_non_error["currentAnswer"].isin(["Yes", "No"])
|
| 498 |
+
]
|
| 499 |
+
tools_non_error = tools_non_error[tools_non_error["vote"].isin(["Yes", "No"])]
|
| 500 |
+
tools_non_error["win"] = (
|
| 501 |
+
tools_non_error["currentAnswer"] == tools_non_error["vote"]
|
| 502 |
+
).astype(int)
|
| 503 |
+
tools_non_error.columns = tools_non_error.columns.astype(str)
|
| 504 |
+
wins = tools_non_error.groupby(["tool", "win"]).size().unstack().fillna(0)
|
| 505 |
+
wins["tool_accuracy"] = (wins[1] / (wins[0] + wins[1])) * 100
|
| 506 |
+
wins.reset_index(inplace=True)
|
| 507 |
+
wins["total_requests"] = wins[0] + wins[1]
|
| 508 |
+
wins.columns = wins.columns.astype(str)
|
| 509 |
+
wins = wins[["tool", "tool_accuracy", "total_requests"]]
|
| 510 |
+
timeline = tools_non_error.groupby(["tool"])["request_time"].agg(["min", "max"])
|
| 511 |
+
acc_info = wins.merge(timeline, how="left", on="tool")
|
| 512 |
+
|
| 513 |
+
if tools_acc is None:
|
| 514 |
+
print("Creating accuracy file for the first time")
|
| 515 |
+
return acc_info
|
| 516 |
+
|
| 517 |
+
# TODO update the old information
|
| 518 |
+
|
| 519 |
+
|
| 520 |
if __name__ == "__main__":
|
| 521 |
RPCs = [
|
| 522 |
"https://lb.nodies.app/v1/406d8dcc043f4cb3959ed7d6673d311a",
|