Skip to content

Commit 580acdc

Browse files
committed
Save analysis
1 parent b73bb97 commit 580acdc

File tree

1 file changed

+44
-54
lines changed

1 file changed

+44
-54
lines changed

anal.ipynb

+44-54
Original file line numberDiff line numberDiff line change
@@ -37,28 +37,48 @@
3737
},
3838
{
3939
"cell_type": "code",
40-
"execution_count": 12,
40+
"execution_count": 4,
41+
"id": "9cf09f71-6bda-4ce8-af77-56ceb6807f98",
42+
"metadata": {},
43+
"outputs": [
44+
{
45+
"data": {
46+
"text/plain": [
47+
"Counter({'X:': 375, 'Y:': 369})"
48+
]
49+
},
50+
"execution_count": 4,
51+
"metadata": {},
52+
"output_type": "execute_result"
53+
}
54+
],
55+
"source": [
56+
"collections.Counter(result['answer'] for result in load_results(RESULTS_PATH))"
57+
]
58+
},
59+
{
60+
"cell_type": "code",
61+
"execution_count": 5,
4162
"id": "aaea1b19-acce-4476-b7e2-686fb90139c1",
4263
"metadata": {},
4364
"outputs": [
4465
{
4566
"data": {
4667
"text/plain": [
47-
"Counter({('A', False): 154,\n",
48-
" ('A', True): 102,\n",
49-
" ('B', True): 98,\n",
50-
" ('B', False): 47,\n",
51-
" (None, True): 1})"
68+
"Counter({('B', True): 341,\n",
69+
" ('A', False): 338,\n",
70+
" ('B', False): 34,\n",
71+
" ('A', True): 31})"
5272
]
5373
},
54-
"execution_count": 12,
74+
"execution_count": 5,
5575
"metadata": {},
5676
"output_type": "execute_result"
5777
}
5878
],
5979
"source": [
60-
"RE_ANSWER = re.compile(r'[AB12]')\n",
61-
"COALESCE = {'1': 'A', '2': 'B', 'A': 'A', 'B': 'B'}\n",
80+
"RE_ANSWER = re.compile(r'[ABXY12]')\n",
81+
"COALESCE = {'1': 'A', '2': 'B', 'A': 'A', 'B': 'B', 'Y': 'A', 'X': 'B'}\n",
6282
"\n",
6383
"def parse_answer(answer):\n",
6484
" matches = RE_ANSWER.findall(answer)\n",
@@ -75,24 +95,24 @@
7595
},
7696
{
7797
"cell_type": "code",
78-
"execution_count": 5,
98+
"execution_count": 6,
7999
"id": "97593984-1e89-4b4e-833f-268e6a3ea8d1",
80100
"metadata": {},
81101
"outputs": [
82102
{
83103
"data": {
84104
"text/plain": [
85-
"Counter({'A': 256, 'B': 145, None: 1})"
105+
"Counter({'B': 375, 'A': 369})"
86106
]
87107
},
88-
"execution_count": 5,
108+
"execution_count": 6,
89109
"metadata": {},
90110
"output_type": "execute_result"
91111
}
92112
],
93113
"source": [
94114
"collections.Counter(\n",
95-
" (parse_answer(result['answer']))\n",
115+
" parse_answer(result['answer'])\n",
96116
" for result in load_results(RESULTS_PATH)\n",
97117
")"
98118
]
@@ -119,14 +139,11 @@
119139
"metadata": {},
120140
"outputs": [
121141
{
122-
"data": {
123-
"text/plain": [
124-
"{'AB': 61, 'AA': 60, 'BA': 16, 'BB': 13, 'U': 0}"
125-
]
126-
},
127-
"execution_count": 8,
128-
"metadata": {},
129-
"output_type": "execute_result"
142+
"name": "stdout",
143+
"output_type": "stream",
144+
"text": [
145+
"Accuracy: 84% Breakdown: AB=179 AA=8 BA=11 BB=14 U=0\n"
146+
]
130147
}
131148
],
132149
"source": [
@@ -161,44 +178,25 @@
161178
" return score\n",
162179
"\n",
163180
"\n",
164-
"stable_score(aggregate_swapped_answers(load_results(RESULTS_PATH)))"
181+
"scores = stable_score(aggregate_swapped_answers(load_results(RESULTS_PATH)))\n",
182+
"acc = int(100 * scores['AB'] / sum(scores.values()))\n",
183+
"scores_fmt = ' '.join(f'{k}={v}' for k, v in scores.items())\n",
184+
"print(f'Accuracy: {acc}% Breakdown: {scores_fmt}')"
165185
]
166186
},
167187
{
168188
"cell_type": "code",
169189
"execution_count": 9,
170-
"id": "78dba699-28e8-497f-bd59-77fb4da48278",
171-
"metadata": {},
172-
"outputs": [
173-
{
174-
"data": {
175-
"text/plain": [
176-
"{\"'terrorist' and'd ** k' can also be included in messages.\": {True: None}}"
177-
]
178-
},
179-
"execution_count": 9,
180-
"metadata": {},
181-
"output_type": "execute_result"
182-
}
183-
],
184-
"source": [
185-
"results = [{'article_id': '6aa21c738f5c5c2fa7b1cad4f3dba97cc9634878', 'article_sent': \"'terrorist' and'd ** k' can also be included in messages.\", 'correct_sent': \"** k' can also be included in messages.\", 'correct_sent_id': '82-2', 'incorrect_sent': \"** k'' can also be included in messages.\", 'incorrect_sent_id': '68-2', 'answer': ':', 'swap': True}]\n",
186-
"aggregate_swapped_answers(results)"
187-
]
188-
},
189-
{
190-
"cell_type": "code",
191-
"execution_count": 10,
192190
"id": "da842095-9d47-49cf-80d3-facb795f097b",
193191
"metadata": {},
194192
"outputs": [
195193
{
196194
"data": {
197195
"text/plain": [
198-
"Counter({True: 252, False: 149, None: 1})"
196+
"Counter({True: 679, False: 65})"
199197
]
200198
},
201-
"execution_count": 10,
199+
"execution_count": 9,
202200
"metadata": {},
203201
"output_type": "execute_result"
204202
}
@@ -209,14 +207,6 @@
209207
" for result in load_results(RESULTS_PATH)\n",
210208
")"
211209
]
212-
},
213-
{
214-
"cell_type": "code",
215-
"execution_count": null,
216-
"id": "5c1f0345-1a13-42ee-b545-68f56fb70770",
217-
"metadata": {},
218-
"outputs": [],
219-
"source": []
220210
}
221211
],
222212
"metadata": {

0 commit comments

Comments
 (0)