cyberosa
commited on
Commit
·
f632617
1
Parent(s):
a75d7e4
fixing update of tool accuracy file
Browse files- data/tools_accuracy.csv +2 -2
- notebooks/markets_analysis.ipynb +1372 -0
- scripts/tools.py +9 -8
- tabs/tool_win.py +48 -35
data/tools_accuracy.csv
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:8103fd33f62fd3080293e6b7677dde31efe71a5a9719fbdcf960d7323726e2c2
|
3 |
+
size 1010
|
notebooks/markets_analysis.ipynb
ADDED
@@ -0,0 +1,1372 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 1,
|
6 |
+
"metadata": {},
|
7 |
+
"outputs": [],
|
8 |
+
"source": [
|
9 |
+
"import pandas as pd\n",
|
10 |
+
"import matplotlib.pyplot as plt\n",
|
11 |
+
"import seaborn as sns\n",
|
12 |
+
"import gc\n",
|
13 |
+
"sns.set_style(\"darkgrid\")"
|
14 |
+
]
|
15 |
+
},
|
16 |
+
{
|
17 |
+
"cell_type": "code",
|
18 |
+
"execution_count": 7,
|
19 |
+
"metadata": {},
|
20 |
+
"outputs": [],
|
21 |
+
"source": [
|
22 |
+
"fpmms = pd.read_parquet('../data/fpmms.parquet')"
|
23 |
+
]
|
24 |
+
},
|
25 |
+
{
|
26 |
+
"cell_type": "code",
|
27 |
+
"execution_count": 3,
|
28 |
+
"metadata": {},
|
29 |
+
"outputs": [
|
30 |
+
{
|
31 |
+
"data": {
|
32 |
+
"text/html": [
|
33 |
+
"<div>\n",
|
34 |
+
"<style scoped>\n",
|
35 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
36 |
+
" vertical-align: middle;\n",
|
37 |
+
" }\n",
|
38 |
+
"\n",
|
39 |
+
" .dataframe tbody tr th {\n",
|
40 |
+
" vertical-align: top;\n",
|
41 |
+
" }\n",
|
42 |
+
"\n",
|
43 |
+
" .dataframe thead th {\n",
|
44 |
+
" text-align: right;\n",
|
45 |
+
" }\n",
|
46 |
+
"</style>\n",
|
47 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
48 |
+
" <thead>\n",
|
49 |
+
" <tr style=\"text-align: right;\">\n",
|
50 |
+
" <th></th>\n",
|
51 |
+
" <th>id</th>\n",
|
52 |
+
" <th>currentAnswer</th>\n",
|
53 |
+
" <th>title</th>\n",
|
54 |
+
" </tr>\n",
|
55 |
+
" </thead>\n",
|
56 |
+
" <tbody>\n",
|
57 |
+
" <tr>\n",
|
58 |
+
" <th>0</th>\n",
|
59 |
+
" <td>0x0020d13c89140b47e10db54cbd53852b90bc1391</td>\n",
|
60 |
+
" <td>No</td>\n",
|
61 |
+
" <td>Will the Francis Scott Key Bridge in Baltimore...</td>\n",
|
62 |
+
" </tr>\n",
|
63 |
+
" <tr>\n",
|
64 |
+
" <th>1</th>\n",
|
65 |
+
" <td>0x003ae5e007cc38b3f86b0ed7c82f938a1285ac07</td>\n",
|
66 |
+
" <td>No</td>\n",
|
67 |
+
" <td>Will FC Saarbrucken reach the final of the Ger...</td>\n",
|
68 |
+
" </tr>\n",
|
69 |
+
" <tr>\n",
|
70 |
+
" <th>2</th>\n",
|
71 |
+
" <td>0x004c8d4c619dc6b9caa940f5ea7ef699ae85359c</td>\n",
|
72 |
+
" <td>Yes</td>\n",
|
73 |
+
" <td>Will the pro-life activists convicted for 'con...</td>\n",
|
74 |
+
" </tr>\n",
|
75 |
+
" <tr>\n",
|
76 |
+
" <th>3</th>\n",
|
77 |
+
" <td>0x005e3f7a90585acbec807425a750fbba1d0c2b5c</td>\n",
|
78 |
+
" <td>Yes</td>\n",
|
79 |
+
" <td>Will Apple announce the release of a new M4 ch...</td>\n",
|
80 |
+
" </tr>\n",
|
81 |
+
" <tr>\n",
|
82 |
+
" <th>4</th>\n",
|
83 |
+
" <td>0x0094fa304017d5c2b355790e2976f769ea600492</td>\n",
|
84 |
+
" <td>No</td>\n",
|
85 |
+
" <td>Will the Hisense U8K be considered a top-tier ...</td>\n",
|
86 |
+
" </tr>\n",
|
87 |
+
" </tbody>\n",
|
88 |
+
"</table>\n",
|
89 |
+
"</div>"
|
90 |
+
],
|
91 |
+
"text/plain": [
|
92 |
+
" id currentAnswer \\\n",
|
93 |
+
"0 0x0020d13c89140b47e10db54cbd53852b90bc1391 No \n",
|
94 |
+
"1 0x003ae5e007cc38b3f86b0ed7c82f938a1285ac07 No \n",
|
95 |
+
"2 0x004c8d4c619dc6b9caa940f5ea7ef699ae85359c Yes \n",
|
96 |
+
"3 0x005e3f7a90585acbec807425a750fbba1d0c2b5c Yes \n",
|
97 |
+
"4 0x0094fa304017d5c2b355790e2976f769ea600492 No \n",
|
98 |
+
"\n",
|
99 |
+
" title \n",
|
100 |
+
"0 Will the Francis Scott Key Bridge in Baltimore... \n",
|
101 |
+
"1 Will FC Saarbrucken reach the final of the Ger... \n",
|
102 |
+
"2 Will the pro-life activists convicted for 'con... \n",
|
103 |
+
"3 Will Apple announce the release of a new M4 ch... \n",
|
104 |
+
"4 Will the Hisense U8K be considered a top-tier ... "
|
105 |
+
]
|
106 |
+
},
|
107 |
+
"execution_count": 3,
|
108 |
+
"metadata": {},
|
109 |
+
"output_type": "execute_result"
|
110 |
+
}
|
111 |
+
],
|
112 |
+
"source": [
|
113 |
+
"fpmms.head()"
|
114 |
+
]
|
115 |
+
},
|
116 |
+
{
|
117 |
+
"cell_type": "code",
|
118 |
+
"execution_count": 4,
|
119 |
+
"metadata": {},
|
120 |
+
"outputs": [
|
121 |
+
{
|
122 |
+
"data": {
|
123 |
+
"text/plain": [
|
124 |
+
"currentAnswer\n",
|
125 |
+
"No 2170\n",
|
126 |
+
"Yes 1500\n",
|
127 |
+
"no 1\n",
|
128 |
+
"False 1\n",
|
129 |
+
"IND 1\n",
|
130 |
+
"Name: count, dtype: int64"
|
131 |
+
]
|
132 |
+
},
|
133 |
+
"execution_count": 4,
|
134 |
+
"metadata": {},
|
135 |
+
"output_type": "execute_result"
|
136 |
+
}
|
137 |
+
],
|
138 |
+
"source": [
|
139 |
+
"fpmms.currentAnswer.value_counts()"
|
140 |
+
]
|
141 |
+
},
|
142 |
+
{
|
143 |
+
"cell_type": "code",
|
144 |
+
"execution_count": 5,
|
145 |
+
"metadata": {},
|
146 |
+
"outputs": [
|
147 |
+
{
|
148 |
+
"name": "stdout",
|
149 |
+
"output_type": "stream",
|
150 |
+
"text": [
|
151 |
+
"<class 'pandas.core.frame.DataFrame'>\n",
|
152 |
+
"RangeIndex: 3673 entries, 0 to 3672\n",
|
153 |
+
"Data columns (total 3 columns):\n",
|
154 |
+
" # Column Non-Null Count Dtype \n",
|
155 |
+
"--- ------ -------------- ----- \n",
|
156 |
+
" 0 id 3673 non-null object\n",
|
157 |
+
" 1 currentAnswer 3673 non-null object\n",
|
158 |
+
" 2 title 3673 non-null object\n",
|
159 |
+
"dtypes: object(3)\n",
|
160 |
+
"memory usage: 86.2+ KB\n"
|
161 |
+
]
|
162 |
+
}
|
163 |
+
],
|
164 |
+
"source": [
|
165 |
+
"fpmms.info()"
|
166 |
+
]
|
167 |
+
},
|
168 |
+
{
|
169 |
+
"cell_type": "code",
|
170 |
+
"execution_count": 8,
|
171 |
+
"metadata": {},
|
172 |
+
"outputs": [],
|
173 |
+
"source": [
|
174 |
+
"all_trades = pd.read_parquet('../data/all_trades_profitability.parquet')"
|
175 |
+
]
|
176 |
+
},
|
177 |
+
{
|
178 |
+
"cell_type": "code",
|
179 |
+
"execution_count": 33,
|
180 |
+
"metadata": {},
|
181 |
+
"outputs": [
|
182 |
+
{
|
183 |
+
"data": {
|
184 |
+
"text/plain": [
|
185 |
+
"27707"
|
186 |
+
]
|
187 |
+
},
|
188 |
+
"execution_count": 33,
|
189 |
+
"metadata": {},
|
190 |
+
"output_type": "execute_result"
|
191 |
+
}
|
192 |
+
],
|
193 |
+
"source": [
|
194 |
+
"len(all_trades)"
|
195 |
+
]
|
196 |
+
},
|
197 |
+
{
|
198 |
+
"cell_type": "code",
|
199 |
+
"execution_count": 34,
|
200 |
+
"metadata": {},
|
201 |
+
"outputs": [
|
202 |
+
{
|
203 |
+
"data": {
|
204 |
+
"text/plain": [
|
205 |
+
"127674"
|
206 |
+
]
|
207 |
+
},
|
208 |
+
"execution_count": 34,
|
209 |
+
"metadata": {},
|
210 |
+
"output_type": "execute_result"
|
211 |
+
}
|
212 |
+
],
|
213 |
+
"source": [
|
214 |
+
"len(tools)"
|
215 |
+
]
|
216 |
+
},
|
217 |
+
{
|
218 |
+
"cell_type": "code",
|
219 |
+
"execution_count": 9,
|
220 |
+
"metadata": {},
|
221 |
+
"outputs": [
|
222 |
+
{
|
223 |
+
"data": {
|
224 |
+
"text/html": [
|
225 |
+
"<div>\n",
|
226 |
+
"<style scoped>\n",
|
227 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
228 |
+
" vertical-align: middle;\n",
|
229 |
+
" }\n",
|
230 |
+
"\n",
|
231 |
+
" .dataframe tbody tr th {\n",
|
232 |
+
" vertical-align: top;\n",
|
233 |
+
" }\n",
|
234 |
+
"\n",
|
235 |
+
" .dataframe thead th {\n",
|
236 |
+
" text-align: right;\n",
|
237 |
+
" }\n",
|
238 |
+
"</style>\n",
|
239 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
240 |
+
" <thead>\n",
|
241 |
+
" <tr style=\"text-align: right;\">\n",
|
242 |
+
" <th></th>\n",
|
243 |
+
" <th>trader_address</th>\n",
|
244 |
+
" <th>trade_id</th>\n",
|
245 |
+
" <th>creation_timestamp</th>\n",
|
246 |
+
" <th>title</th>\n",
|
247 |
+
" <th>market_status</th>\n",
|
248 |
+
" <th>collateral_amount</th>\n",
|
249 |
+
" <th>outcome_index</th>\n",
|
250 |
+
" <th>trade_fee_amount</th>\n",
|
251 |
+
" <th>outcomes_tokens_traded</th>\n",
|
252 |
+
" <th>current_answer</th>\n",
|
253 |
+
" <th>is_invalid</th>\n",
|
254 |
+
" <th>winning_trade</th>\n",
|
255 |
+
" <th>earnings</th>\n",
|
256 |
+
" <th>redeemed</th>\n",
|
257 |
+
" <th>redeemed_amount</th>\n",
|
258 |
+
" <th>num_mech_calls</th>\n",
|
259 |
+
" <th>mech_fee_amount</th>\n",
|
260 |
+
" <th>net_earnings</th>\n",
|
261 |
+
" <th>roi</th>\n",
|
262 |
+
" </tr>\n",
|
263 |
+
" </thead>\n",
|
264 |
+
" <tbody>\n",
|
265 |
+
" <tr>\n",
|
266 |
+
" <th>0</th>\n",
|
267 |
+
" <td>0x034c4ad84f7ac6638bf19300d5bbe7d9b981e736</td>\n",
|
268 |
+
" <td>0x005e3f7a90585acbec807425a750fbba1d0c2b5c0x03...</td>\n",
|
269 |
+
" <td>2024-05-12 04:26:35+00:00</td>\n",
|
270 |
+
" <td>Will Apple announce the release of a new M4 ch...</td>\n",
|
271 |
+
" <td>CLOSED</td>\n",
|
272 |
+
" <td>0.682360</td>\n",
|
273 |
+
" <td>0</td>\n",
|
274 |
+
" <td>0.013647</td>\n",
|
275 |
+
" <td>0.889368</td>\n",
|
276 |
+
" <td>0</td>\n",
|
277 |
+
" <td>False</td>\n",
|
278 |
+
" <td>True</td>\n",
|
279 |
+
" <td>0.889368</td>\n",
|
280 |
+
" <td>True</td>\n",
|
281 |
+
" <td>0.889368</td>\n",
|
282 |
+
" <td>0</td>\n",
|
283 |
+
" <td>0.0</td>\n",
|
284 |
+
" <td>0.193360</td>\n",
|
285 |
+
" <td>0.277813</td>\n",
|
286 |
+
" </tr>\n",
|
287 |
+
" <tr>\n",
|
288 |
+
" <th>1</th>\n",
|
289 |
+
" <td>0x034c4ad84f7ac6638bf19300d5bbe7d9b981e736</td>\n",
|
290 |
+
" <td>0x017947579ab51313c31fe1cc562c0f1726ec09c90x03...</td>\n",
|
291 |
+
" <td>2024-05-21 04:26:40+00:00</td>\n",
|
292 |
+
" <td>Will Google's Pixel 9 lineup be officially rel...</td>\n",
|
293 |
+
" <td>CLOSED</td>\n",
|
294 |
+
" <td>0.732158</td>\n",
|
295 |
+
" <td>1</td>\n",
|
296 |
+
" <td>0.014643</td>\n",
|
297 |
+
" <td>1.120798</td>\n",
|
298 |
+
" <td>1</td>\n",
|
299 |
+
" <td>False</td>\n",
|
300 |
+
" <td>True</td>\n",
|
301 |
+
" <td>1.120798</td>\n",
|
302 |
+
" <td>True</td>\n",
|
303 |
+
" <td>1.120798</td>\n",
|
304 |
+
" <td>0</td>\n",
|
305 |
+
" <td>0.0</td>\n",
|
306 |
+
" <td>0.373997</td>\n",
|
307 |
+
" <td>0.500799</td>\n",
|
308 |
+
" </tr>\n",
|
309 |
+
" <tr>\n",
|
310 |
+
" <th>2</th>\n",
|
311 |
+
" <td>0x034c4ad84f7ac6638bf19300d5bbe7d9b981e736</td>\n",
|
312 |
+
" <td>0x0290d432108f22fdc91e6677b1436e7bc702bced0x03...</td>\n",
|
313 |
+
" <td>2024-05-09 08:26:30+00:00</td>\n",
|
314 |
+
" <td>Will the ICC take legal action against Israel ...</td>\n",
|
315 |
+
" <td>CLOSED</td>\n",
|
316 |
+
" <td>1.246551</td>\n",
|
317 |
+
" <td>0</td>\n",
|
318 |
+
" <td>0.024931</td>\n",
|
319 |
+
" <td>2.505972</td>\n",
|
320 |
+
" <td>0</td>\n",
|
321 |
+
" <td>False</td>\n",
|
322 |
+
" <td>True</td>\n",
|
323 |
+
" <td>2.505972</td>\n",
|
324 |
+
" <td>True</td>\n",
|
325 |
+
" <td>2.505972</td>\n",
|
326 |
+
" <td>0</td>\n",
|
327 |
+
" <td>0.0</td>\n",
|
328 |
+
" <td>1.234490</td>\n",
|
329 |
+
" <td>0.970906</td>\n",
|
330 |
+
" </tr>\n",
|
331 |
+
" <tr>\n",
|
332 |
+
" <th>3</th>\n",
|
333 |
+
" <td>0x034c4ad84f7ac6638bf19300d5bbe7d9b981e736</td>\n",
|
334 |
+
" <td>0x02c244eef143b16254f3d6a444c2e44d35a175590x03...</td>\n",
|
335 |
+
" <td>2024-05-04 04:24:20+00:00</td>\n",
|
336 |
+
" <td>Will Trent Staggs win the Senatorial race to r...</td>\n",
|
337 |
+
" <td>CLOSED</td>\n",
|
338 |
+
" <td>1.219659</td>\n",
|
339 |
+
" <td>0</td>\n",
|
340 |
+
" <td>0.024393</td>\n",
|
341 |
+
" <td>2.948666</td>\n",
|
342 |
+
" <td>1</td>\n",
|
343 |
+
" <td>False</td>\n",
|
344 |
+
" <td>False</td>\n",
|
345 |
+
" <td>0.000000</td>\n",
|
346 |
+
" <td>True</td>\n",
|
347 |
+
" <td>0.000000</td>\n",
|
348 |
+
" <td>0</td>\n",
|
349 |
+
" <td>0.0</td>\n",
|
350 |
+
" <td>-1.244052</td>\n",
|
351 |
+
" <td>-1.000000</td>\n",
|
352 |
+
" </tr>\n",
|
353 |
+
" <tr>\n",
|
354 |
+
" <th>4</th>\n",
|
355 |
+
" <td>0x034c4ad84f7ac6638bf19300d5bbe7d9b981e736</td>\n",
|
356 |
+
" <td>0x0518764fb0684f3156c200ae78d4214d19d8b9530x03...</td>\n",
|
357 |
+
" <td>2024-05-19 04:22:50+00:00</td>\n",
|
358 |
+
" <td>Will OpenAI release another model update by 20...</td>\n",
|
359 |
+
" <td>CLOSED</td>\n",
|
360 |
+
" <td>1.203097</td>\n",
|
361 |
+
" <td>1</td>\n",
|
362 |
+
" <td>0.024062</td>\n",
|
363 |
+
" <td>3.143667</td>\n",
|
364 |
+
" <td>0</td>\n",
|
365 |
+
" <td>False</td>\n",
|
366 |
+
" <td>False</td>\n",
|
367 |
+
" <td>0.000000</td>\n",
|
368 |
+
" <td>True</td>\n",
|
369 |
+
" <td>0.000000</td>\n",
|
370 |
+
" <td>0</td>\n",
|
371 |
+
" <td>0.0</td>\n",
|
372 |
+
" <td>-1.227159</td>\n",
|
373 |
+
" <td>-1.000000</td>\n",
|
374 |
+
" </tr>\n",
|
375 |
+
" </tbody>\n",
|
376 |
+
"</table>\n",
|
377 |
+
"</div>"
|
378 |
+
],
|
379 |
+
"text/plain": [
|
380 |
+
" trader_address \\\n",
|
381 |
+
"0 0x034c4ad84f7ac6638bf19300d5bbe7d9b981e736 \n",
|
382 |
+
"1 0x034c4ad84f7ac6638bf19300d5bbe7d9b981e736 \n",
|
383 |
+
"2 0x034c4ad84f7ac6638bf19300d5bbe7d9b981e736 \n",
|
384 |
+
"3 0x034c4ad84f7ac6638bf19300d5bbe7d9b981e736 \n",
|
385 |
+
"4 0x034c4ad84f7ac6638bf19300d5bbe7d9b981e736 \n",
|
386 |
+
"\n",
|
387 |
+
" trade_id \\\n",
|
388 |
+
"0 0x005e3f7a90585acbec807425a750fbba1d0c2b5c0x03... \n",
|
389 |
+
"1 0x017947579ab51313c31fe1cc562c0f1726ec09c90x03... \n",
|
390 |
+
"2 0x0290d432108f22fdc91e6677b1436e7bc702bced0x03... \n",
|
391 |
+
"3 0x02c244eef143b16254f3d6a444c2e44d35a175590x03... \n",
|
392 |
+
"4 0x0518764fb0684f3156c200ae78d4214d19d8b9530x03... \n",
|
393 |
+
"\n",
|
394 |
+
" creation_timestamp \\\n",
|
395 |
+
"0 2024-05-12 04:26:35+00:00 \n",
|
396 |
+
"1 2024-05-21 04:26:40+00:00 \n",
|
397 |
+
"2 2024-05-09 08:26:30+00:00 \n",
|
398 |
+
"3 2024-05-04 04:24:20+00:00 \n",
|
399 |
+
"4 2024-05-19 04:22:50+00:00 \n",
|
400 |
+
"\n",
|
401 |
+
" title market_status \\\n",
|
402 |
+
"0 Will Apple announce the release of a new M4 ch... CLOSED \n",
|
403 |
+
"1 Will Google's Pixel 9 lineup be officially rel... CLOSED \n",
|
404 |
+
"2 Will the ICC take legal action against Israel ... CLOSED \n",
|
405 |
+
"3 Will Trent Staggs win the Senatorial race to r... CLOSED \n",
|
406 |
+
"4 Will OpenAI release another model update by 20... CLOSED \n",
|
407 |
+
"\n",
|
408 |
+
" collateral_amount outcome_index trade_fee_amount outcomes_tokens_traded \\\n",
|
409 |
+
"0 0.682360 0 0.013647 0.889368 \n",
|
410 |
+
"1 0.732158 1 0.014643 1.120798 \n",
|
411 |
+
"2 1.246551 0 0.024931 2.505972 \n",
|
412 |
+
"3 1.219659 0 0.024393 2.948666 \n",
|
413 |
+
"4 1.203097 1 0.024062 3.143667 \n",
|
414 |
+
"\n",
|
415 |
+
" current_answer is_invalid winning_trade earnings redeemed \\\n",
|
416 |
+
"0 0 False True 0.889368 True \n",
|
417 |
+
"1 1 False True 1.120798 True \n",
|
418 |
+
"2 0 False True 2.505972 True \n",
|
419 |
+
"3 1 False False 0.000000 True \n",
|
420 |
+
"4 0 False False 0.000000 True \n",
|
421 |
+
"\n",
|
422 |
+
" redeemed_amount num_mech_calls mech_fee_amount net_earnings roi \n",
|
423 |
+
"0 0.889368 0 0.0 0.193360 0.277813 \n",
|
424 |
+
"1 1.120798 0 0.0 0.373997 0.500799 \n",
|
425 |
+
"2 2.505972 0 0.0 1.234490 0.970906 \n",
|
426 |
+
"3 0.000000 0 0.0 -1.244052 -1.000000 \n",
|
427 |
+
"4 0.000000 0 0.0 -1.227159 -1.000000 "
|
428 |
+
]
|
429 |
+
},
|
430 |
+
"execution_count": 9,
|
431 |
+
"metadata": {},
|
432 |
+
"output_type": "execute_result"
|
433 |
+
}
|
434 |
+
],
|
435 |
+
"source": [
|
436 |
+
"all_trades.head()"
|
437 |
+
]
|
438 |
+
},
|
439 |
+
{
|
440 |
+
"cell_type": "code",
|
441 |
+
"execution_count": 10,
|
442 |
+
"metadata": {},
|
443 |
+
"outputs": [
|
444 |
+
{
|
445 |
+
"data": {
|
446 |
+
"text/plain": [
|
447 |
+
"winning_trade\n",
|
448 |
+
"False 14574\n",
|
449 |
+
"True 13133\n",
|
450 |
+
"Name: count, dtype: int64"
|
451 |
+
]
|
452 |
+
},
|
453 |
+
"execution_count": 10,
|
454 |
+
"metadata": {},
|
455 |
+
"output_type": "execute_result"
|
456 |
+
}
|
457 |
+
],
|
458 |
+
"source": [
|
459 |
+
"all_trades.winning_trade.value_counts()"
|
460 |
+
]
|
461 |
+
},
|
462 |
+
{
|
463 |
+
"cell_type": "code",
|
464 |
+
"execution_count": 12,
|
465 |
+
"metadata": {},
|
466 |
+
"outputs": [],
|
467 |
+
"source": [
|
468 |
+
"all_trades[\"creation_timestamp\"] = pd.to_datetime(all_trades[\"creation_timestamp\"])"
|
469 |
+
]
|
470 |
+
},
|
471 |
+
{
|
472 |
+
"cell_type": "code",
|
473 |
+
"execution_count": 23,
|
474 |
+
"metadata": {},
|
475 |
+
"outputs": [
|
476 |
+
{
|
477 |
+
"data": {
|
478 |
+
"text/plain": [
|
479 |
+
"current_answer\n",
|
480 |
+
" 1 13016\n",
|
481 |
+
" 0 10814\n",
|
482 |
+
"-1 3877\n",
|
483 |
+
"Name: count, dtype: int64"
|
484 |
+
]
|
485 |
+
},
|
486 |
+
"execution_count": 23,
|
487 |
+
"metadata": {},
|
488 |
+
"output_type": "execute_result"
|
489 |
+
}
|
490 |
+
],
|
491 |
+
"source": [
|
492 |
+
"all_trades.current_answer.value_counts()"
|
493 |
+
]
|
494 |
+
},
|
495 |
+
{
|
496 |
+
"cell_type": "code",
|
497 |
+
"execution_count": 38,
|
498 |
+
"metadata": {},
|
499 |
+
"outputs": [
|
500 |
+
{
|
501 |
+
"data": {
|
502 |
+
"text/plain": [
|
503 |
+
"203"
|
504 |
+
]
|
505 |
+
},
|
506 |
+
"execution_count": 38,
|
507 |
+
"metadata": {},
|
508 |
+
"output_type": "execute_result"
|
509 |
+
}
|
510 |
+
],
|
511 |
+
"source": [
|
512 |
+
"len(list(all_trades.trader_address.unique()))"
|
513 |
+
]
|
514 |
+
},
|
515 |
+
{
|
516 |
+
"cell_type": "code",
|
517 |
+
"execution_count": 25,
|
518 |
+
"metadata": {},
|
519 |
+
"outputs": [
|
520 |
+
{
|
521 |
+
"data": {
|
522 |
+
"text/plain": [
|
523 |
+
"27707"
|
524 |
+
]
|
525 |
+
},
|
526 |
+
"execution_count": 25,
|
527 |
+
"metadata": {},
|
528 |
+
"output_type": "execute_result"
|
529 |
+
}
|
530 |
+
],
|
531 |
+
"source": [
|
532 |
+
"len(all_trades)"
|
533 |
+
]
|
534 |
+
},
|
535 |
+
{
|
536 |
+
"cell_type": "code",
|
537 |
+
"execution_count": 13,
|
538 |
+
"metadata": {},
|
539 |
+
"outputs": [
|
540 |
+
{
|
541 |
+
"name": "stderr",
|
542 |
+
"output_type": "stream",
|
543 |
+
"text": [
|
544 |
+
"/var/folders/gp/02mb1d514ng739czlxw1lhh00000gn/T/ipykernel_70112/183699308.py:1: UserWarning: Converting to PeriodArray/Index representation will drop timezone information.\n",
|
545 |
+
" all_trades['month_year'] = all_trades['creation_timestamp'].dt.to_period('M').astype(str)\n",
|
546 |
+
"/var/folders/gp/02mb1d514ng739czlxw1lhh00000gn/T/ipykernel_70112/183699308.py:2: UserWarning: Converting to PeriodArray/Index representation will drop timezone information.\n",
|
547 |
+
" all_trades['month_year_week'] = all_trades['creation_timestamp'].dt.to_period('W').astype(str)\n"
|
548 |
+
]
|
549 |
+
},
|
550 |
+
{
|
551 |
+
"data": {
|
552 |
+
"text/plain": [
|
553 |
+
"winning_trade\n",
|
554 |
+
"0 14574\n",
|
555 |
+
"1 13133\n",
|
556 |
+
"Name: count, dtype: int64"
|
557 |
+
]
|
558 |
+
},
|
559 |
+
"execution_count": 13,
|
560 |
+
"metadata": {},
|
561 |
+
"output_type": "execute_result"
|
562 |
+
}
|
563 |
+
],
|
564 |
+
"source": [
|
565 |
+
"all_trades['month_year'] = all_trades['creation_timestamp'].dt.to_period('M').astype(str)\n",
|
566 |
+
"all_trades['month_year_week'] = all_trades['creation_timestamp'].dt.to_period('W').astype(str)\n",
|
567 |
+
"all_trades['winning_trade'] = all_trades['winning_trade'].astype(int)\n",
|
568 |
+
"all_trades.winning_trade.value_counts()"
|
569 |
+
]
|
570 |
+
},
|
571 |
+
{
|
572 |
+
"cell_type": "code",
|
573 |
+
"execution_count": 14,
|
574 |
+
"metadata": {},
|
575 |
+
"outputs": [
|
576 |
+
{
|
577 |
+
"data": {
|
578 |
+
"text/html": [
|
579 |
+
"<div>\n",
|
580 |
+
"<style scoped>\n",
|
581 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
582 |
+
" vertical-align: middle;\n",
|
583 |
+
" }\n",
|
584 |
+
"\n",
|
585 |
+
" .dataframe tbody tr th {\n",
|
586 |
+
" vertical-align: top;\n",
|
587 |
+
" }\n",
|
588 |
+
"\n",
|
589 |
+
" .dataframe thead th {\n",
|
590 |
+
" text-align: right;\n",
|
591 |
+
" }\n",
|
592 |
+
"</style>\n",
|
593 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
594 |
+
" <thead>\n",
|
595 |
+
" <tr style=\"text-align: right;\">\n",
|
596 |
+
" <th></th>\n",
|
597 |
+
" <th>month_year_week</th>\n",
|
598 |
+
" <th>winning_trade</th>\n",
|
599 |
+
" </tr>\n",
|
600 |
+
" </thead>\n",
|
601 |
+
" <tbody>\n",
|
602 |
+
" <tr>\n",
|
603 |
+
" <th>0</th>\n",
|
604 |
+
" <td>2024-04-22/2024-04-28</td>\n",
|
605 |
+
" <td>60.465116</td>\n",
|
606 |
+
" </tr>\n",
|
607 |
+
" <tr>\n",
|
608 |
+
" <th>1</th>\n",
|
609 |
+
" <td>2024-04-29/2024-05-05</td>\n",
|
610 |
+
" <td>53.887043</td>\n",
|
611 |
+
" </tr>\n",
|
612 |
+
" <tr>\n",
|
613 |
+
" <th>2</th>\n",
|
614 |
+
" <td>2024-05-06/2024-05-12</td>\n",
|
615 |
+
" <td>49.626201</td>\n",
|
616 |
+
" </tr>\n",
|
617 |
+
" <tr>\n",
|
618 |
+
" <th>3</th>\n",
|
619 |
+
" <td>2024-05-13/2024-05-19</td>\n",
|
620 |
+
" <td>47.931617</td>\n",
|
621 |
+
" </tr>\n",
|
622 |
+
" <tr>\n",
|
623 |
+
" <th>4</th>\n",
|
624 |
+
" <td>2024-05-20/2024-05-26</td>\n",
|
625 |
+
" <td>46.209810</td>\n",
|
626 |
+
" </tr>\n",
|
627 |
+
" <tr>\n",
|
628 |
+
" <th>5</th>\n",
|
629 |
+
" <td>2024-05-27/2024-06-02</td>\n",
|
630 |
+
" <td>41.855369</td>\n",
|
631 |
+
" </tr>\n",
|
632 |
+
" <tr>\n",
|
633 |
+
" <th>6</th>\n",
|
634 |
+
" <td>2024-06-03/2024-06-09</td>\n",
|
635 |
+
" <td>43.714888</td>\n",
|
636 |
+
" </tr>\n",
|
637 |
+
" <tr>\n",
|
638 |
+
" <th>7</th>\n",
|
639 |
+
" <td>2024-06-10/2024-06-16</td>\n",
|
640 |
+
" <td>46.697039</td>\n",
|
641 |
+
" </tr>\n",
|
642 |
+
" <tr>\n",
|
643 |
+
" <th>8</th>\n",
|
644 |
+
" <td>2024-06-17/2024-06-23</td>\n",
|
645 |
+
" <td>52.762120</td>\n",
|
646 |
+
" </tr>\n",
|
647 |
+
" </tbody>\n",
|
648 |
+
"</table>\n",
|
649 |
+
"</div>"
|
650 |
+
],
|
651 |
+
"text/plain": [
|
652 |
+
" month_year_week winning_trade\n",
|
653 |
+
"0 2024-04-22/2024-04-28 60.465116\n",
|
654 |
+
"1 2024-04-29/2024-05-05 53.887043\n",
|
655 |
+
"2 2024-05-06/2024-05-12 49.626201\n",
|
656 |
+
"3 2024-05-13/2024-05-19 47.931617\n",
|
657 |
+
"4 2024-05-20/2024-05-26 46.209810\n",
|
658 |
+
"5 2024-05-27/2024-06-02 41.855369\n",
|
659 |
+
"6 2024-06-03/2024-06-09 43.714888\n",
|
660 |
+
"7 2024-06-10/2024-06-16 46.697039\n",
|
661 |
+
"8 2024-06-17/2024-06-23 52.762120"
|
662 |
+
]
|
663 |
+
},
|
664 |
+
"execution_count": 14,
|
665 |
+
"metadata": {},
|
666 |
+
"output_type": "execute_result"
|
667 |
+
}
|
668 |
+
],
|
669 |
+
"source": [
|
670 |
+
"winning_trades = all_trades.groupby(['month_year_week'])['winning_trade'].sum() / all_trades.groupby(['month_year_week'])['winning_trade'].count() * 100\n",
|
671 |
+
"# winning_trades is a series, give it a dataframe\n",
|
672 |
+
"winning_trades = winning_trades.reset_index()\n",
|
673 |
+
"winning_trades.columns = winning_trades.columns.astype(str)\n",
|
674 |
+
"winning_trades.columns = ['month_year_week', 'winning_trade']\n",
|
675 |
+
"winning_trades"
|
676 |
+
]
|
677 |
+
},
|
678 |
+
{
|
679 |
+
"cell_type": "code",
|
680 |
+
"execution_count": 28,
|
681 |
+
"metadata": {},
|
682 |
+
"outputs": [
|
683 |
+
{
|
684 |
+
"data": {
|
685 |
+
"text/html": [
|
686 |
+
"<div>\n",
|
687 |
+
"<style scoped>\n",
|
688 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
689 |
+
" vertical-align: middle;\n",
|
690 |
+
" }\n",
|
691 |
+
"\n",
|
692 |
+
" .dataframe tbody tr th {\n",
|
693 |
+
" vertical-align: top;\n",
|
694 |
+
" }\n",
|
695 |
+
"\n",
|
696 |
+
" .dataframe thead th {\n",
|
697 |
+
" text-align: right;\n",
|
698 |
+
" }\n",
|
699 |
+
"</style>\n",
|
700 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
701 |
+
" <thead>\n",
|
702 |
+
" <tr style=\"text-align: right;\">\n",
|
703 |
+
" <th></th>\n",
|
704 |
+
" <th>month_year_week</th>\n",
|
705 |
+
" <th>winning_trade</th>\n",
|
706 |
+
" </tr>\n",
|
707 |
+
" </thead>\n",
|
708 |
+
" <tbody>\n",
|
709 |
+
" <tr>\n",
|
710 |
+
" <th>6</th>\n",
|
711 |
+
" <td>2024-06-03/2024-06-09</td>\n",
|
712 |
+
" <td>43.714888</td>\n",
|
713 |
+
" </tr>\n",
|
714 |
+
" </tbody>\n",
|
715 |
+
"</table>\n",
|
716 |
+
"</div>"
|
717 |
+
],
|
718 |
+
"text/plain": [
|
719 |
+
" month_year_week winning_trade\n",
|
720 |
+
"6 2024-06-03/2024-06-09 43.714888"
|
721 |
+
]
|
722 |
+
},
|
723 |
+
"execution_count": 28,
|
724 |
+
"metadata": {},
|
725 |
+
"output_type": "execute_result"
|
726 |
+
}
|
727 |
+
],
|
728 |
+
"source": [
|
729 |
+
"that_week = winning_trades[winning_trades[\"month_year_week\"]==\"2024-06-03/2024-06-09\"]\n",
|
730 |
+
"that_week"
|
731 |
+
]
|
732 |
+
},
|
733 |
+
{
|
734 |
+
"cell_type": "code",
|
735 |
+
"execution_count": 15,
|
736 |
+
"metadata": {},
|
737 |
+
"outputs": [
|
738 |
+
{
|
739 |
+
"data": {
|
740 |
+
"text/html": [
|
741 |
+
"<div>\n",
|
742 |
+
"<style scoped>\n",
|
743 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
744 |
+
" vertical-align: middle;\n",
|
745 |
+
" }\n",
|
746 |
+
"\n",
|
747 |
+
" .dataframe tbody tr th {\n",
|
748 |
+
" vertical-align: top;\n",
|
749 |
+
" }\n",
|
750 |
+
"\n",
|
751 |
+
" .dataframe thead th {\n",
|
752 |
+
" text-align: right;\n",
|
753 |
+
" }\n",
|
754 |
+
"</style>\n",
|
755 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
756 |
+
" <thead>\n",
|
757 |
+
" <tr style=\"text-align: right;\">\n",
|
758 |
+
" <th></th>\n",
|
759 |
+
" <th>month_year_week</th>\n",
|
760 |
+
" <th>sum</th>\n",
|
761 |
+
" <th>count</th>\n",
|
762 |
+
" </tr>\n",
|
763 |
+
" </thead>\n",
|
764 |
+
" <tbody>\n",
|
765 |
+
" <tr>\n",
|
766 |
+
" <th>0</th>\n",
|
767 |
+
" <td>2024-04-22/2024-04-28</td>\n",
|
768 |
+
" <td>26</td>\n",
|
769 |
+
" <td>43</td>\n",
|
770 |
+
" </tr>\n",
|
771 |
+
" <tr>\n",
|
772 |
+
" <th>1</th>\n",
|
773 |
+
" <td>2024-04-29/2024-05-05</td>\n",
|
774 |
+
" <td>1622</td>\n",
|
775 |
+
" <td>3010</td>\n",
|
776 |
+
" </tr>\n",
|
777 |
+
" <tr>\n",
|
778 |
+
" <th>2</th>\n",
|
779 |
+
" <td>2024-05-06/2024-05-12</td>\n",
|
780 |
+
" <td>2788</td>\n",
|
781 |
+
" <td>5618</td>\n",
|
782 |
+
" </tr>\n",
|
783 |
+
" <tr>\n",
|
784 |
+
" <th>3</th>\n",
|
785 |
+
" <td>2024-05-13/2024-05-19</td>\n",
|
786 |
+
" <td>2271</td>\n",
|
787 |
+
" <td>4738</td>\n",
|
788 |
+
" </tr>\n",
|
789 |
+
" <tr>\n",
|
790 |
+
" <th>4</th>\n",
|
791 |
+
" <td>2024-05-20/2024-05-26</td>\n",
|
792 |
+
" <td>1969</td>\n",
|
793 |
+
" <td>4261</td>\n",
|
794 |
+
" </tr>\n",
|
795 |
+
" <tr>\n",
|
796 |
+
" <th>5</th>\n",
|
797 |
+
" <td>2024-05-27/2024-06-02</td>\n",
|
798 |
+
" <td>1719</td>\n",
|
799 |
+
" <td>4107</td>\n",
|
800 |
+
" </tr>\n",
|
801 |
+
" <tr>\n",
|
802 |
+
" <th>6</th>\n",
|
803 |
+
" <td>2024-06-03/2024-06-09</td>\n",
|
804 |
+
" <td>1245</td>\n",
|
805 |
+
" <td>2848</td>\n",
|
806 |
+
" </tr>\n",
|
807 |
+
" <tr>\n",
|
808 |
+
" <th>7</th>\n",
|
809 |
+
" <td>2024-06-10/2024-06-16</td>\n",
|
810 |
+
" <td>1025</td>\n",
|
811 |
+
" <td>2195</td>\n",
|
812 |
+
" </tr>\n",
|
813 |
+
" <tr>\n",
|
814 |
+
" <th>8</th>\n",
|
815 |
+
" <td>2024-06-17/2024-06-23</td>\n",
|
816 |
+
" <td>468</td>\n",
|
817 |
+
" <td>887</td>\n",
|
818 |
+
" </tr>\n",
|
819 |
+
" </tbody>\n",
|
820 |
+
"</table>\n",
|
821 |
+
"</div>"
|
822 |
+
],
|
823 |
+
"text/plain": [
|
824 |
+
" month_year_week sum count\n",
|
825 |
+
"0 2024-04-22/2024-04-28 26 43\n",
|
826 |
+
"1 2024-04-29/2024-05-05 1622 3010\n",
|
827 |
+
"2 2024-05-06/2024-05-12 2788 5618\n",
|
828 |
+
"3 2024-05-13/2024-05-19 2271 4738\n",
|
829 |
+
"4 2024-05-20/2024-05-26 1969 4261\n",
|
830 |
+
"5 2024-05-27/2024-06-02 1719 4107\n",
|
831 |
+
"6 2024-06-03/2024-06-09 1245 2848\n",
|
832 |
+
"7 2024-06-10/2024-06-16 1025 2195\n",
|
833 |
+
"8 2024-06-17/2024-06-23 468 887"
|
834 |
+
]
|
835 |
+
},
|
836 |
+
"execution_count": 15,
|
837 |
+
"metadata": {},
|
838 |
+
"output_type": "execute_result"
|
839 |
+
}
|
840 |
+
],
|
841 |
+
"source": [
|
842 |
+
"winning_trades2 = all_trades.groupby(['month_year_week'])['winning_trade'].agg([\"sum\",\"count\"]).reset_index()\n",
|
843 |
+
"winning_trades2"
|
844 |
+
]
|
845 |
+
},
|
846 |
+
{
|
847 |
+
"cell_type": "code",
|
848 |
+
"execution_count": 29,
|
849 |
+
"metadata": {},
|
850 |
+
"outputs": [
|
851 |
+
{
|
852 |
+
"data": {
|
853 |
+
"text/html": [
|
854 |
+
"<div>\n",
|
855 |
+
"<style scoped>\n",
|
856 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
857 |
+
" vertical-align: middle;\n",
|
858 |
+
" }\n",
|
859 |
+
"\n",
|
860 |
+
" .dataframe tbody tr th {\n",
|
861 |
+
" vertical-align: top;\n",
|
862 |
+
" }\n",
|
863 |
+
"\n",
|
864 |
+
" .dataframe thead th {\n",
|
865 |
+
" text-align: right;\n",
|
866 |
+
" }\n",
|
867 |
+
"</style>\n",
|
868 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
869 |
+
" <thead>\n",
|
870 |
+
" <tr style=\"text-align: right;\">\n",
|
871 |
+
" <th></th>\n",
|
872 |
+
" <th>month_year_week</th>\n",
|
873 |
+
" <th>sum</th>\n",
|
874 |
+
" <th>count</th>\n",
|
875 |
+
" <th>winning_trade</th>\n",
|
876 |
+
" </tr>\n",
|
877 |
+
" </thead>\n",
|
878 |
+
" <tbody>\n",
|
879 |
+
" <tr>\n",
|
880 |
+
" <th>6</th>\n",
|
881 |
+
" <td>2024-06-03/2024-06-09</td>\n",
|
882 |
+
" <td>1245</td>\n",
|
883 |
+
" <td>2848</td>\n",
|
884 |
+
" <td>43.714888</td>\n",
|
885 |
+
" </tr>\n",
|
886 |
+
" </tbody>\n",
|
887 |
+
"</table>\n",
|
888 |
+
"</div>"
|
889 |
+
],
|
890 |
+
"text/plain": [
|
891 |
+
" month_year_week sum count winning_trade\n",
|
892 |
+
"6 2024-06-03/2024-06-09 1245 2848 43.714888"
|
893 |
+
]
|
894 |
+
},
|
895 |
+
"execution_count": 29,
|
896 |
+
"metadata": {},
|
897 |
+
"output_type": "execute_result"
|
898 |
+
}
|
899 |
+
],
|
900 |
+
"source": [
|
901 |
+
"that_week = winning_trades2[winning_trades2[\"month_year_week\"]==\"2024-06-03/2024-06-09\"]\n",
|
902 |
+
"that_week"
|
903 |
+
]
|
904 |
+
},
|
905 |
+
{
|
906 |
+
"cell_type": "code",
|
907 |
+
"execution_count": 18,
|
908 |
+
"metadata": {},
|
909 |
+
"outputs": [],
|
910 |
+
"source": [
|
911 |
+
"INC_TOOLS = [\n",
|
912 |
+
" \"prediction-online\",\n",
|
913 |
+
" \"prediction-offline\",\n",
|
914 |
+
" \"claude-prediction-online\",\n",
|
915 |
+
" \"claude-prediction-offline\",\n",
|
916 |
+
" \"prediction-offline-sme\",\n",
|
917 |
+
" \"prediction-online-sme\",\n",
|
918 |
+
" \"prediction-request-rag\",\n",
|
919 |
+
" \"prediction-request-reasoning\",\n",
|
920 |
+
" \"prediction-url-cot-claude\",\n",
|
921 |
+
" \"prediction-request-rag-claude\",\n",
|
922 |
+
" \"prediction-request-reasoning-claude\",\n",
|
923 |
+
"]"
|
924 |
+
]
|
925 |
+
},
|
926 |
+
{
|
927 |
+
"cell_type": "code",
|
928 |
+
"execution_count": 60,
|
929 |
+
"metadata": {},
|
930 |
+
"outputs": [],
|
931 |
+
"source": [
|
932 |
+
"tools = pd.read_parquet('../data/tools.parquet')"
|
933 |
+
]
|
934 |
+
},
|
935 |
+
{
|
936 |
+
"cell_type": "code",
|
937 |
+
"execution_count": 61,
|
938 |
+
"metadata": {},
|
939 |
+
"outputs": [
|
940 |
+
{
|
941 |
+
"name": "stdout",
|
942 |
+
"output_type": "stream",
|
943 |
+
"text": [
|
944 |
+
"<class 'pandas.core.frame.DataFrame'>\n",
|
945 |
+
"RangeIndex: 127674 entries, 0 to 127673\n",
|
946 |
+
"Data columns (total 22 columns):\n",
|
947 |
+
" # Column Non-Null Count Dtype \n",
|
948 |
+
"--- ------ -------------- ----- \n",
|
949 |
+
" 0 request_id 127674 non-null object \n",
|
950 |
+
" 1 request_block 127674 non-null int64 \n",
|
951 |
+
" 2 prompt_request 127674 non-null object \n",
|
952 |
+
" 3 tool 127674 non-null object \n",
|
953 |
+
" 4 nonce 127674 non-null object \n",
|
954 |
+
" 5 trader_address 127674 non-null object \n",
|
955 |
+
" 6 deliver_block 127674 non-null int64 \n",
|
956 |
+
" 7 error 127668 non-null float64\n",
|
957 |
+
" 8 error_message 19534 non-null object \n",
|
958 |
+
" 9 prompt_response 120607 non-null object \n",
|
959 |
+
" 10 mech_address 127674 non-null object \n",
|
960 |
+
" 11 p_yes 108134 non-null float64\n",
|
961 |
+
" 12 p_no 108134 non-null float64\n",
|
962 |
+
" 13 confidence 108134 non-null float64\n",
|
963 |
+
" 14 info_utility 108134 non-null float64\n",
|
964 |
+
" 15 vote 94137 non-null object \n",
|
965 |
+
" 16 win_probability 108134 non-null float64\n",
|
966 |
+
" 17 title 118074 non-null object \n",
|
967 |
+
" 18 currentAnswer 88330 non-null object \n",
|
968 |
+
" 19 request_time 127674 non-null object \n",
|
969 |
+
" 20 request_month_year 127674 non-null object \n",
|
970 |
+
" 21 request_month_year_week 127674 non-null object \n",
|
971 |
+
"dtypes: float64(6), int64(2), object(14)\n",
|
972 |
+
"memory usage: 21.4+ MB\n"
|
973 |
+
]
|
974 |
+
}
|
975 |
+
],
|
976 |
+
"source": [
|
977 |
+
"tools.info()"
|
978 |
+
]
|
979 |
+
},
|
980 |
+
{
|
981 |
+
"cell_type": "code",
|
982 |
+
"execution_count": 62,
|
983 |
+
"metadata": {},
|
984 |
+
"outputs": [
|
985 |
+
{
|
986 |
+
"data": {
|
987 |
+
"text/plain": [
|
988 |
+
"currentAnswer\n",
|
989 |
+
"No 51140\n",
|
990 |
+
"Yes 37190\n",
|
991 |
+
"Name: count, dtype: int64"
|
992 |
+
]
|
993 |
+
},
|
994 |
+
"execution_count": 62,
|
995 |
+
"metadata": {},
|
996 |
+
"output_type": "execute_result"
|
997 |
+
}
|
998 |
+
],
|
999 |
+
"source": [
|
1000 |
+
"tools.currentAnswer.value_counts()"
|
1001 |
+
]
|
1002 |
+
},
|
1003 |
+
{
|
1004 |
+
"cell_type": "code",
|
1005 |
+
"execution_count": 26,
|
1006 |
+
"metadata": {},
|
1007 |
+
"outputs": [
|
1008 |
+
{
|
1009 |
+
"data": {
|
1010 |
+
"text/plain": [
|
1011 |
+
"127674"
|
1012 |
+
]
|
1013 |
+
},
|
1014 |
+
"execution_count": 26,
|
1015 |
+
"metadata": {},
|
1016 |
+
"output_type": "execute_result"
|
1017 |
+
}
|
1018 |
+
],
|
1019 |
+
"source": [
|
1020 |
+
"len(tools)"
|
1021 |
+
]
|
1022 |
+
},
|
1023 |
+
{
|
1024 |
+
"cell_type": "code",
|
1025 |
+
"execution_count": 31,
|
1026 |
+
"metadata": {},
|
1027 |
+
"outputs": [],
|
1028 |
+
"source": [
|
1029 |
+
"tools_inc = tools[tools['tool'].isin(INC_TOOLS)]\n",
|
1030 |
+
"tools_non_error = tools_inc[tools_inc['error'] != 1]\n",
|
1031 |
+
"tools_non_error.loc[:, 'currentAnswer'] = tools_non_error['currentAnswer'].replace({'no': 'No', 'yes': 'Yes'})\n",
|
1032 |
+
"tools_non_error = tools_non_error[tools_non_error['currentAnswer'].isin(['Yes', 'No'])]\n",
|
1033 |
+
"tools_non_error = tools_non_error[tools_non_error['vote'].isin(['Yes', 'No'])]\n",
|
1034 |
+
"tools_non_error['win'] = (tools_non_error['currentAnswer'] == tools_non_error['vote']).astype(int)\n",
|
1035 |
+
"tools_non_error.columns = tools_non_error.columns.astype(str)\n",
|
1036 |
+
"wins = tools_non_error.groupby(['tool', 'request_month_year_week', 'win']).size().unstack().fillna(0)"
|
1037 |
+
]
|
1038 |
+
},
|
1039 |
+
{
|
1040 |
+
"cell_type": "code",
|
1041 |
+
"execution_count": 63,
|
1042 |
+
"metadata": {},
|
1043 |
+
"outputs": [
|
1044 |
+
{
|
1045 |
+
"data": {
|
1046 |
+
"text/html": [
|
1047 |
+
"<div>\n",
|
1048 |
+
"<style scoped>\n",
|
1049 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
1050 |
+
" vertical-align: middle;\n",
|
1051 |
+
" }\n",
|
1052 |
+
"\n",
|
1053 |
+
" .dataframe tbody tr th {\n",
|
1054 |
+
" vertical-align: top;\n",
|
1055 |
+
" }\n",
|
1056 |
+
"\n",
|
1057 |
+
" .dataframe thead th {\n",
|
1058 |
+
" text-align: right;\n",
|
1059 |
+
" }\n",
|
1060 |
+
"</style>\n",
|
1061 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
1062 |
+
" <thead>\n",
|
1063 |
+
" <tr style=\"text-align: right;\">\n",
|
1064 |
+
" <th></th>\n",
|
1065 |
+
" <th>win</th>\n",
|
1066 |
+
" <th>0</th>\n",
|
1067 |
+
" <th>1</th>\n",
|
1068 |
+
" </tr>\n",
|
1069 |
+
" <tr>\n",
|
1070 |
+
" <th>tool</th>\n",
|
1071 |
+
" <th>request_month_year_week</th>\n",
|
1072 |
+
" <th></th>\n",
|
1073 |
+
" <th></th>\n",
|
1074 |
+
" </tr>\n",
|
1075 |
+
" </thead>\n",
|
1076 |
+
" <tbody>\n",
|
1077 |
+
" <tr>\n",
|
1078 |
+
" <th rowspan=\"5\" valign=\"top\">claude-prediction-offline</th>\n",
|
1079 |
+
" <th>2024-04-22/2024-04-28</th>\n",
|
1080 |
+
" <td>14.0</td>\n",
|
1081 |
+
" <td>23.0</td>\n",
|
1082 |
+
" </tr>\n",
|
1083 |
+
" <tr>\n",
|
1084 |
+
" <th>2024-04-29/2024-05-05</th>\n",
|
1085 |
+
" <td>34.0</td>\n",
|
1086 |
+
" <td>99.0</td>\n",
|
1087 |
+
" </tr>\n",
|
1088 |
+
" <tr>\n",
|
1089 |
+
" <th>2024-05-06/2024-05-12</th>\n",
|
1090 |
+
" <td>22.0</td>\n",
|
1091 |
+
" <td>34.0</td>\n",
|
1092 |
+
" </tr>\n",
|
1093 |
+
" <tr>\n",
|
1094 |
+
" <th>2024-05-13/2024-05-19</th>\n",
|
1095 |
+
" <td>40.0</td>\n",
|
1096 |
+
" <td>52.0</td>\n",
|
1097 |
+
" </tr>\n",
|
1098 |
+
" <tr>\n",
|
1099 |
+
" <th>2024-05-20/2024-05-26</th>\n",
|
1100 |
+
" <td>18.0</td>\n",
|
1101 |
+
" <td>52.0</td>\n",
|
1102 |
+
" </tr>\n",
|
1103 |
+
" <tr>\n",
|
1104 |
+
" <th>...</th>\n",
|
1105 |
+
" <th>...</th>\n",
|
1106 |
+
" <td>...</td>\n",
|
1107 |
+
" <td>...</td>\n",
|
1108 |
+
" </tr>\n",
|
1109 |
+
" <tr>\n",
|
1110 |
+
" <th rowspan=\"5\" valign=\"top\">prediction-url-cot-claude</th>\n",
|
1111 |
+
" <th>2024-05-06/2024-05-12</th>\n",
|
1112 |
+
" <td>67.0</td>\n",
|
1113 |
+
" <td>91.0</td>\n",
|
1114 |
+
" </tr>\n",
|
1115 |
+
" <tr>\n",
|
1116 |
+
" <th>2024-05-13/2024-05-19</th>\n",
|
1117 |
+
" <td>28.0</td>\n",
|
1118 |
+
" <td>43.0</td>\n",
|
1119 |
+
" </tr>\n",
|
1120 |
+
" <tr>\n",
|
1121 |
+
" <th>2024-05-20/2024-05-26</th>\n",
|
1122 |
+
" <td>64.0</td>\n",
|
1123 |
+
" <td>145.0</td>\n",
|
1124 |
+
" </tr>\n",
|
1125 |
+
" <tr>\n",
|
1126 |
+
" <th>2024-05-27/2024-06-02</th>\n",
|
1127 |
+
" <td>81.0</td>\n",
|
1128 |
+
" <td>112.0</td>\n",
|
1129 |
+
" </tr>\n",
|
1130 |
+
" <tr>\n",
|
1131 |
+
" <th>2024-06-03/2024-06-09</th>\n",
|
1132 |
+
" <td>7.0</td>\n",
|
1133 |
+
" <td>41.0</td>\n",
|
1134 |
+
" </tr>\n",
|
1135 |
+
" </tbody>\n",
|
1136 |
+
"</table>\n",
|
1137 |
+
"<p>91 rows × 2 columns</p>\n",
|
1138 |
+
"</div>"
|
1139 |
+
],
|
1140 |
+
"text/plain": [
|
1141 |
+
"win 0 1\n",
|
1142 |
+
"tool request_month_year_week \n",
|
1143 |
+
"claude-prediction-offline 2024-04-22/2024-04-28 14.0 23.0\n",
|
1144 |
+
" 2024-04-29/2024-05-05 34.0 99.0\n",
|
1145 |
+
" 2024-05-06/2024-05-12 22.0 34.0\n",
|
1146 |
+
" 2024-05-13/2024-05-19 40.0 52.0\n",
|
1147 |
+
" 2024-05-20/2024-05-26 18.0 52.0\n",
|
1148 |
+
"... ... ...\n",
|
1149 |
+
"prediction-url-cot-claude 2024-05-06/2024-05-12 67.0 91.0\n",
|
1150 |
+
" 2024-05-13/2024-05-19 28.0 43.0\n",
|
1151 |
+
" 2024-05-20/2024-05-26 64.0 145.0\n",
|
1152 |
+
" 2024-05-27/2024-06-02 81.0 112.0\n",
|
1153 |
+
" 2024-06-03/2024-06-09 7.0 41.0\n",
|
1154 |
+
"\n",
|
1155 |
+
"[91 rows x 2 columns]"
|
1156 |
+
]
|
1157 |
+
},
|
1158 |
+
"execution_count": 63,
|
1159 |
+
"metadata": {},
|
1160 |
+
"output_type": "execute_result"
|
1161 |
+
}
|
1162 |
+
],
|
1163 |
+
"source": [
|
1164 |
+
"wins"
|
1165 |
+
]
|
1166 |
+
},
|
1167 |
+
{
|
1168 |
+
"cell_type": "code",
|
1169 |
+
"execution_count": 56,
|
1170 |
+
"metadata": {},
|
1171 |
+
"outputs": [
|
1172 |
+
{
|
1173 |
+
"data": {
|
1174 |
+
"text/plain": [
|
1175 |
+
"186"
|
1176 |
+
]
|
1177 |
+
},
|
1178 |
+
"execution_count": 56,
|
1179 |
+
"metadata": {},
|
1180 |
+
"output_type": "execute_result"
|
1181 |
+
}
|
1182 |
+
],
|
1183 |
+
"source": [
|
1184 |
+
"selected_traders = list(tools.trader_address.unique())\n",
|
1185 |
+
"len(selected_traders)"
|
1186 |
+
]
|
1187 |
+
},
|
1188 |
+
{
|
1189 |
+
"cell_type": "code",
|
1190 |
+
"execution_count": 59,
|
1191 |
+
"metadata": {},
|
1192 |
+
"outputs": [
|
1193 |
+
{
|
1194 |
+
"data": {
|
1195 |
+
"text/plain": [
|
1196 |
+
"182"
|
1197 |
+
]
|
1198 |
+
},
|
1199 |
+
"execution_count": 59,
|
1200 |
+
"metadata": {},
|
1201 |
+
"output_type": "execute_result"
|
1202 |
+
}
|
1203 |
+
],
|
1204 |
+
"source": [
|
1205 |
+
"len(list(tools_non_error.trader_address.unique()))"
|
1206 |
+
]
|
1207 |
+
},
|
1208 |
+
{
|
1209 |
+
"cell_type": "code",
|
1210 |
+
"execution_count": 36,
|
1211 |
+
"metadata": {},
|
1212 |
+
"outputs": [
|
1213 |
+
{
|
1214 |
+
"data": {
|
1215 |
+
"text/plain": [
|
1216 |
+
"10817"
|
1217 |
+
]
|
1218 |
+
},
|
1219 |
+
"execution_count": 36,
|
1220 |
+
"metadata": {},
|
1221 |
+
"output_type": "execute_result"
|
1222 |
+
}
|
1223 |
+
],
|
1224 |
+
"source": [
|
1225 |
+
"len(tools)-len(tools_inc)"
|
1226 |
+
]
|
1227 |
+
},
|
1228 |
+
{
|
1229 |
+
"cell_type": "code",
|
1230 |
+
"execution_count": 32,
|
1231 |
+
"metadata": {},
|
1232 |
+
"outputs": [
|
1233 |
+
{
|
1234 |
+
"data": {
|
1235 |
+
"text/plain": [
|
1236 |
+
"11778"
|
1237 |
+
]
|
1238 |
+
},
|
1239 |
+
"execution_count": 32,
|
1240 |
+
"metadata": {},
|
1241 |
+
"output_type": "execute_result"
|
1242 |
+
}
|
1243 |
+
],
|
1244 |
+
"source": [
|
1245 |
+
"tools_week = tools_non_error[tools_non_error[\"request_month_year_week\"]==\"2024-06-03/2024-06-09\"]\n",
|
1246 |
+
"len(tools_week)"
|
1247 |
+
]
|
1248 |
+
},
|
1249 |
+
{
|
1250 |
+
"cell_type": "code",
|
1251 |
+
"execution_count": 44,
|
1252 |
+
"metadata": {},
|
1253 |
+
"outputs": [
|
1254 |
+
{
|
1255 |
+
"data": {
|
1256 |
+
"text/plain": [
|
1257 |
+
"0"
|
1258 |
+
]
|
1259 |
+
},
|
1260 |
+
"execution_count": 44,
|
1261 |
+
"metadata": {},
|
1262 |
+
"output_type": "execute_result"
|
1263 |
+
}
|
1264 |
+
],
|
1265 |
+
"source": [
|
1266 |
+
"filtered_trades = all_trades.loc[all_trades[\"trader_address\"].isin(selected_traders)]\n",
|
1267 |
+
"len(filtered_trades)"
|
1268 |
+
]
|
1269 |
+
},
|
1270 |
+
{
|
1271 |
+
"cell_type": "code",
|
1272 |
+
"execution_count": 45,
|
1273 |
+
"metadata": {},
|
1274 |
+
"outputs": [],
|
1275 |
+
"source": [
|
1276 |
+
"all_addresses = list(all_trades.trader_address.unique())"
|
1277 |
+
]
|
1278 |
+
},
|
1279 |
+
{
|
1280 |
+
"cell_type": "code",
|
1281 |
+
"execution_count": 58,
|
1282 |
+
"metadata": {},
|
1283 |
+
"outputs": [],
|
1284 |
+
"source": [
|
1285 |
+
"for a in all_addresses:\n",
|
1286 |
+
" if a in selected_traders:\n",
|
1287 |
+
" print(\"found\")"
|
1288 |
+
]
|
1289 |
+
},
|
1290 |
+
{
|
1291 |
+
"cell_type": "code",
|
1292 |
+
"execution_count": 57,
|
1293 |
+
"metadata": {},
|
1294 |
+
"outputs": [],
|
1295 |
+
"source": [
|
1296 |
+
"for a in selected_traders:\n",
|
1297 |
+
" if a in all_addresses:\n",
|
1298 |
+
" print(\"found\")"
|
1299 |
+
]
|
1300 |
+
},
|
1301 |
+
{
|
1302 |
+
"cell_type": "code",
|
1303 |
+
"execution_count": 46,
|
1304 |
+
"metadata": {},
|
1305 |
+
"outputs": [
|
1306 |
+
{
|
1307 |
+
"data": {
|
1308 |
+
"text/plain": [
|
1309 |
+
"0"
|
1310 |
+
]
|
1311 |
+
},
|
1312 |
+
"execution_count": 46,
|
1313 |
+
"metadata": {},
|
1314 |
+
"output_type": "execute_result"
|
1315 |
+
}
|
1316 |
+
],
|
1317 |
+
"source": [
|
1318 |
+
"filtered_tools = tools[tools[\"trader_address\"].isin(all_addresses)]\n",
|
1319 |
+
"len(filtered_tools)"
|
1320 |
+
]
|
1321 |
+
},
|
1322 |
+
{
|
1323 |
+
"cell_type": "code",
|
1324 |
+
"execution_count": 55,
|
1325 |
+
"metadata": {},
|
1326 |
+
"outputs": [
|
1327 |
+
{
|
1328 |
+
"data": {
|
1329 |
+
"text/plain": [
|
1330 |
+
"count 27707.000000\n",
|
1331 |
+
"mean 3.912224\n",
|
1332 |
+
"std 4.622220\n",
|
1333 |
+
"min 0.000000\n",
|
1334 |
+
"25% 1.000000\n",
|
1335 |
+
"50% 2.000000\n",
|
1336 |
+
"75% 5.000000\n",
|
1337 |
+
"max 66.000000\n",
|
1338 |
+
"Name: num_mech_calls, dtype: float64"
|
1339 |
+
]
|
1340 |
+
},
|
1341 |
+
"execution_count": 55,
|
1342 |
+
"metadata": {},
|
1343 |
+
"output_type": "execute_result"
|
1344 |
+
}
|
1345 |
+
],
|
1346 |
+
"source": [
|
1347 |
+
"all_trades.num_mech_calls.describe()"
|
1348 |
+
]
|
1349 |
+
}
|
1350 |
+
],
|
1351 |
+
"metadata": {
|
1352 |
+
"kernelspec": {
|
1353 |
+
"display_name": "market_creator",
|
1354 |
+
"language": "python",
|
1355 |
+
"name": "python3"
|
1356 |
+
},
|
1357 |
+
"language_info": {
|
1358 |
+
"codemirror_mode": {
|
1359 |
+
"name": "ipython",
|
1360 |
+
"version": 3
|
1361 |
+
},
|
1362 |
+
"file_extension": ".py",
|
1363 |
+
"mimetype": "text/x-python",
|
1364 |
+
"name": "python",
|
1365 |
+
"nbconvert_exporter": "python",
|
1366 |
+
"pygments_lexer": "ipython3",
|
1367 |
+
"version": "3.12.3"
|
1368 |
+
}
|
1369 |
+
},
|
1370 |
+
"nbformat": 4,
|
1371 |
+
"nbformat_minor": 2
|
1372 |
+
}
|
scripts/tools.py
CHANGED
@@ -529,14 +529,15 @@ def update_tools_accuracy(
|
|
529 |
existing_tools = list(tools_acc["tool"].values)
|
530 |
for tool in tools_to_update:
|
531 |
if tool in existing_tools:
|
532 |
-
new_accuracy = acc_info[acc_info["tool"] == tool
|
533 |
-
new_volume = acc_info[acc_info["tool"] == tool
|
534 |
-
new_min_timeline = acc_info[acc_info["tool"] == tool
|
535 |
-
new_max_timeline = acc_info[acc_info["tool"] == tool
|
536 |
-
tools_acc[tools_acc["tool"] == tool, "tool_accuracy"] = new_accuracy
|
537 |
-
tools_acc[tools_acc["tool"] == tool, "total_requests"] = new_volume
|
538 |
-
tools_acc[tools_acc["tool"] == tool, "min"] = new_min_timeline
|
539 |
-
tools_acc[tools_acc["tool"] == tool, "max"] = new_max_timeline
|
|
|
540 |
return tools_acc
|
541 |
|
542 |
|
|
|
529 |
existing_tools = list(tools_acc["tool"].values)
|
530 |
for tool in tools_to_update:
|
531 |
if tool in existing_tools:
|
532 |
+
new_accuracy = acc_info[acc_info["tool"] == tool]["tool_accuracy"].values[0]
|
533 |
+
new_volume = acc_info[acc_info["tool"] == tool]["total_requests"].values[0]
|
534 |
+
new_min_timeline = acc_info[acc_info["tool"] == tool]["min"].values[0]
|
535 |
+
new_max_timeline = acc_info[acc_info["tool"] == tool]["max"].values[0]
|
536 |
+
tools_acc.loc[tools_acc["tool"] == tool, "tool_accuracy"] = new_accuracy
|
537 |
+
tools_acc.loc[tools_acc["tool"] == tool, "total_requests"] = new_volume
|
538 |
+
tools_acc.loc[tools_acc["tool"] == tool, "min"] = new_min_timeline
|
539 |
+
tools_acc.loc[tools_acc["tool"] == tool, "max"] = new_max_timeline
|
540 |
+
print(tools_acc)
|
541 |
return tools_acc
|
542 |
|
543 |
|
tabs/tool_win.py
CHANGED
@@ -3,46 +3,59 @@ import gradio as gr
|
|
3 |
from typing import List
|
4 |
|
5 |
|
6 |
-
HEIGHT=600
|
7 |
-
WIDTH=1000
|
8 |
|
9 |
|
10 |
def get_tool_winning_rate(tools_df: pd.DataFrame, inc_tools: List[str]) -> pd.DataFrame:
|
11 |
"""Gets the tool winning rate data for the given tools and calculates the winning percentage."""
|
12 |
-
tools_inc = tools_df[tools_df[
|
13 |
# tools_inc['error'] = tools_inc.apply(set_error, axis=1)
|
14 |
-
tools_non_error = tools_inc[tools_inc[
|
15 |
-
tools_non_error.loc[:,
|
16 |
-
|
17 |
-
|
18 |
-
tools_non_error
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
tools_non_error.columns = tools_non_error.columns.astype(str)
|
20 |
-
wins =
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
22 |
wins.reset_index(inplace=True)
|
23 |
-
wins[
|
24 |
wins.columns = wins.columns.astype(str)
|
25 |
# Convert request_month_year_week to string and explicitly set type for Altair
|
26 |
-
wins[
|
27 |
return wins
|
28 |
|
29 |
|
30 |
def get_overall_winning_rate(wins_df: pd.DataFrame) -> pd.DataFrame:
|
31 |
"""Gets the overall winning rate data for the given tools and calculates the winning percentage."""
|
32 |
-
overall_wins =
|
33 |
-
"
|
34 |
-
"1":
|
35 |
-
"
|
36 |
-
|
37 |
-
|
38 |
return overall_wins
|
39 |
|
40 |
|
41 |
-
def plot_tool_winnings_overall(
|
|
|
|
|
42 |
"""Plots the overall winning rate data for the given tools and calculates the winning percentage."""
|
43 |
return gr.BarPlot(
|
44 |
-
title="Winning Rate",
|
45 |
-
x_title="Date",
|
46 |
y_title=winning_selector,
|
47 |
show_label=True,
|
48 |
interactive=True,
|
@@ -52,23 +65,23 @@ def plot_tool_winnings_overall(wins_df: pd.DataFrame, winning_selector: str = "w
|
|
52 |
x="request_month_year_week",
|
53 |
y=winning_selector,
|
54 |
height=HEIGHT,
|
55 |
-
width=WIDTH
|
56 |
)
|
57 |
|
58 |
|
59 |
def plot_tool_winnings_by_tool(wins_df: pd.DataFrame, tool: str) -> gr.BarPlot:
|
60 |
"""Plots the winning rate data for the given tool."""
|
61 |
return gr.BarPlot(
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
|
|
3 |
from typing import List
|
4 |
|
5 |
|
6 |
+
HEIGHT = 600
|
7 |
+
WIDTH = 1000
|
8 |
|
9 |
|
10 |
def get_tool_winning_rate(tools_df: pd.DataFrame, inc_tools: List[str]) -> pd.DataFrame:
|
11 |
"""Gets the tool winning rate data for the given tools and calculates the winning percentage."""
|
12 |
+
tools_inc = tools_df[tools_df["tool"].isin(inc_tools)]
|
13 |
# tools_inc['error'] = tools_inc.apply(set_error, axis=1)
|
14 |
+
tools_non_error = tools_inc[tools_inc["error"] != 1]
|
15 |
+
tools_non_error.loc[:, "currentAnswer"] = tools_non_error["currentAnswer"].replace(
|
16 |
+
{"no": "No", "yes": "Yes"}
|
17 |
+
)
|
18 |
+
tools_non_error = tools_non_error[
|
19 |
+
tools_non_error["currentAnswer"].isin(["Yes", "No"])
|
20 |
+
]
|
21 |
+
tools_non_error = tools_non_error[tools_non_error["vote"].isin(["Yes", "No"])]
|
22 |
+
tools_non_error["win"] = (
|
23 |
+
tools_non_error["currentAnswer"] == tools_non_error["vote"]
|
24 |
+
).astype(int)
|
25 |
tools_non_error.columns = tools_non_error.columns.astype(str)
|
26 |
+
wins = (
|
27 |
+
tools_non_error.groupby(["tool", "request_month_year_week", "win"])
|
28 |
+
.size()
|
29 |
+
.unstack()
|
30 |
+
.fillna(0)
|
31 |
+
)
|
32 |
+
wins["win_perc"] = (wins[1] / (wins[0] + wins[1])) * 100
|
33 |
wins.reset_index(inplace=True)
|
34 |
+
wins["total_request"] = wins[0] + wins[1]
|
35 |
wins.columns = wins.columns.astype(str)
|
36 |
# Convert request_month_year_week to string and explicitly set type for Altair
|
37 |
+
wins["request_month_year_week"] = wins["request_month_year_week"].astype(str)
|
38 |
return wins
|
39 |
|
40 |
|
41 |
def get_overall_winning_rate(wins_df: pd.DataFrame) -> pd.DataFrame:
|
42 |
"""Gets the overall winning rate data for the given tools and calculates the winning percentage."""
|
43 |
+
overall_wins = (
|
44 |
+
wins_df.groupby("request_month_year_week")
|
45 |
+
.agg({"0": "sum", "1": "sum", "win_perc": "mean", "total_request": "sum"})
|
46 |
+
.rename(columns={"0": "losses", "1": "wins"})
|
47 |
+
.reset_index()
|
48 |
+
)
|
49 |
return overall_wins
|
50 |
|
51 |
|
52 |
+
def plot_tool_winnings_overall(
|
53 |
+
wins_df: pd.DataFrame, winning_selector: str = "win_perc"
|
54 |
+
) -> gr.BarPlot:
|
55 |
"""Plots the overall winning rate data for the given tools and calculates the winning percentage."""
|
56 |
return gr.BarPlot(
|
57 |
+
title="Winning Rate",
|
58 |
+
x_title="Date",
|
59 |
y_title=winning_selector,
|
60 |
show_label=True,
|
61 |
interactive=True,
|
|
|
65 |
x="request_month_year_week",
|
66 |
y=winning_selector,
|
67 |
height=HEIGHT,
|
68 |
+
width=WIDTH,
|
69 |
)
|
70 |
|
71 |
|
72 |
def plot_tool_winnings_by_tool(wins_df: pd.DataFrame, tool: str) -> gr.BarPlot:
|
73 |
"""Plots the winning rate data for the given tool."""
|
74 |
return gr.BarPlot(
|
75 |
+
title="Winning Rate",
|
76 |
+
x_title="Week",
|
77 |
+
y_title="Winning Rate",
|
78 |
+
x="request_month_year_week",
|
79 |
+
y="win_perc",
|
80 |
+
value=wins_df[wins_df["tool"] == tool],
|
81 |
+
show_label=True,
|
82 |
+
interactive=True,
|
83 |
+
show_actions_button=True,
|
84 |
+
tooltip=["request_month_year_week", "win_perc"],
|
85 |
+
height=HEIGHT,
|
86 |
+
width=WIDTH,
|
87 |
+
)
|