aboutsummaryrefslogtreecommitdiff
path: root/evaluation/adept_ablation/recon/evaluation_loci_looped_recon.ipynb
blob: a6422e03586fbc32fb16ade0abbe857fb845d061 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "import seaborn as sns\n",
    "import warnings\n",
    "import scipy.stats as stats\n",
    "import os\n",
    "\n",
    "warnings.simplefilter(action='ignore', category=FutureWarning)\n",
    "pd.options.mode.chained_assignment = None \n",
    "plt.style.use('ggplot')\n",
    "sns.color_palette(\"Paired\");\n",
    "sns.set_theme();"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Data Loading"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "# setting path to results folder\n",
    "root_path = '../../../out/pretrained/adept_ablations/recon'\n",
    "\n",
    "# list all folders in root path that don't stat with a dot\n",
    "nets = ['recon']\n",
    "\n",
    "# read pickle file\n",
    "tf = pd.DataFrame()\n",
    "sf = pd.DataFrame()\n",
    "af = pd.DataFrame()\n",
    "\n",
    "# load statistics files from nets\n",
    "for net in nets:\n",
    "    path = os.path.join(root_path, net, 'results')\n",
    "    with open(os.path.join(path, 'trialframe.csv'), 'rb') as f:\n",
    "        tf_temp = pd.read_csv(f, index_col=0)\n",
    "    tf_temp['net'] = net\n",
    "    tf = pd.concat([tf,tf_temp])\n",
    "\n",
    "    with open(os.path.join(path, 'slotframe.csv'), 'rb') as f:\n",
    "        sf_temp = pd.read_csv(f, index_col=0)\n",
    "    sf_temp['net'] = net\n",
    "    sf = pd.concat([sf,sf_temp])\n",
    "\n",
    "    with open(os.path.join(path, 'accframe.csv'), 'rb') as f:\n",
    "        af_temp = pd.read_csv(f, index_col=0)\n",
    "    af_temp['net'] = net\n",
    "    af = pd.concat([af,af_temp])\n",
    "\n",
    "# cast variables\n",
    "sf['visible'] = sf['visible'].astype(bool)\n",
    "sf['bound'] = sf['bound'].astype(bool)\n",
    "sf['occluder'] = sf['occluder'].astype(bool)\n",
    "sf['inimage'] = sf['inimage'].astype(bool)\n",
    "sf['vanishing'] = sf['vanishing'].astype(bool)\n",
    "sf['alpha_pos'] = 1-sf['alpha_pos']\n",
    "sf['alpha_ges'] = 1-sf['alpha_ges']\n",
    "\n",
    "# scale to percentage\n",
    "sf['TE'] = sf['TE'] * 100\n",
    "\n",
    "# add surprise as dummy code\n",
    "tf['control'] = [('control' in set) for set in tf['set']]\n",
    "sf['control'] = [('control' in set)  for set in sf['set']]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Calculate Tracking Error (TE)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Tracking Error when visible: M: 2.95 , STD: 4.8, Count: 1686\n",
      "Tracking Error when occluded: M: 2.54 , STD: 2.52, Count: 477\n"
     ]
    }
   ],
   "source": [
    "grouping = (sf.inimage & sf.bound & ~sf.occluder & sf.control)\n",
    "\n",
    "def get_stats(col):\n",
    "    return f' M: {col.mean():.3} , STD: {col.std():.3}, Count: {col.count()}'\n",
    "\n",
    "# When Visible\n",
    "temp = sf[grouping & sf.visible]\n",
    "print(f'Tracking Error when visible:' + get_stats(temp['TE']))\n",
    "\n",
    "# When Occluded\n",
    "temp = sf[grouping & ~sf.visible]\n",
    "print(f'Tracking Error when occluded:' + get_stats(temp['TE']))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Calculate Succesfull Trackings (TE)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>set</th>\n",
       "      <th>evalmode</th>\n",
       "      <th>tracked_pos</th>\n",
       "      <th>tracked_neg</th>\n",
       "      <th>tracked_pos_pro</th>\n",
       "      <th>tracked_neg_pro</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>control</td>\n",
       "      <td>open</td>\n",
       "      <td>37</td>\n",
       "      <td>9</td>\n",
       "      <td>0.804348</td>\n",
       "      <td>0.195652</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       set evalmode  tracked_pos  tracked_neg  tracked_pos_pro  \\\n",
       "0  control     open           37            9         0.804348   \n",
       "\n",
       "   tracked_neg_pro  \n",
       "0         0.195652  "
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# succesfull trackings: In the last visible moment of the target, the slot was less than 10% away from the target\n",
    "# determine last visible frame numeric\n",
    "grouping_factors = ['net','set','evalmode','scene','slot']\n",
    "ff = sf[sf.visible & sf.bound & sf.inimage].groupby(grouping_factors).max()\n",
    "ff.rename(columns = {'frame':'last_visible'}, inplace = True)\n",
    "sf = sf.merge(ff[['last_visible']], on=grouping_factors, how='left')\n",
    "\n",
    "# same for first bound frame\n",
    "ff = sf[sf.visible & sf.bound & sf.inimage].groupby(grouping_factors).min()\n",
    "ff.rename(columns = {'frame':'first_visible'}, inplace = True)\n",
    "sf = sf.merge(ff[['first_visible']], on=grouping_factors, how='left')\n",
    "\n",
    "# add dummy variable to sf\n",
    "sf['last_visible'] = (sf['last_visible'] == sf['frame'])\n",
    "\n",
    "# extract the trials where the target was last visible and threshold the TE\n",
    "ff = sf[sf['last_visible']] \n",
    "ff['tracked_pos'] = (ff['TE'] < 10)\n",
    "ff['tracked_neg'] = (ff['TE'] >= 10)\n",
    "\n",
    "# fill NaN with 0\n",
    "sf = sf.merge(ff[grouping_factors + ['tracked_pos', 'tracked_neg']], on=grouping_factors, how='left')\n",
    "sf['tracked_pos'].fillna(False, inplace=True)\n",
    "sf['tracked_neg'].fillna(False, inplace=True)\n",
    "\n",
    "# Aggreagte over all scenes\n",
    "temp = sf[(sf['frame']== 1) & ~sf.occluder & sf.control & (sf.first_visible < 20)]\n",
    "temp = temp.groupby(['set', 'evalmode']).sum()\n",
    "temp = temp[['tracked_pos', 'tracked_neg']]\n",
    "temp = temp.reset_index()\n",
    "\n",
    "temp['tracked_pos_pro'] = temp['tracked_pos'] / (temp['tracked_pos'] + temp['tracked_neg'])\n",
    "temp['tracked_neg_pro'] = temp['tracked_neg'] / (temp['tracked_pos'] + temp['tracked_neg'])\n",
    "\n",
    "temp"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Mostly Tracked stats"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXYAAAEmCAYAAAB20LuSAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAAsTAAALEwEAmpwYAAAioklEQVR4nO3dd3hUVf7H8fek0UsIoSoiCkdABUGKBVFkXeuqix10V0SKCy7KqvijN8FdUVAUFURBARfBLljoFqSJICoHBBsQIYagJBAgmfn9MQk7xEAmMOFmTj6v5+Fxbpl7v2YmHw7nnnuuLxAIICIi7ojxugAREYksBbuIiGMU7CIijlGwi4g4RsEuIuKYOI/PXwZoBaQAOR7XIiISLWKB2sBKYH/+jV4HeyvgY49rEBGJVu2AT/Kv9DrYUwDS0zPx+zWePhKSkiqSlpbhdRkif6DvZuTExPhITKwAuRman9fBngPg9wcU7BGkn6WUVPpuRlyBXdi6eCoi4hgFu4iIY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Yjks4TgvyJ9BO88/RXo7WlFpYRuUBKR4nIL8DRwBrCZ4KgtOQEU7CJSXMYDXwF/JTgk9xz0PN4TQsEuIsUlxlr7IXA1MMda+zPq/j0hFOwiUlz2GmP6EbzT9F1jzL0Enx0gxUzBLiLFpTPBqXo7WWvTgbrAbd6WVDpouKOIiGPUYhcRcYyCXUTEMQp2kSIwxpxqjJnjdR0iR6NgFymaUwg+OFykxNLFUynVjDEVgReBhgRve18N9ACuAgYCCQRvrvkXsAKwBEd3LLXW/tmLmkUKoxa7lHbXA5Wstc2BVrnrTgMeAa601p5DcM771wk+S7YbsFmhLiWZ7gKT0u4T4BFjzGLgI2Ac8CegNrDAmEO9Ln5AsxJKVFCLXUo1a+33BAN7NFAZmA/EAgustc3z/gBtgfWeFSpSBAp2KdWMMb0I9rF/aK19CPiA4EOYLzPGnJG7z5XAOqAckE3waUAiJZYunkqpZoypAEwBziZ4kfQnoCvQERhAcC7xbKCvtfZjY0w1YBGwH2hjrdUvkJQ4CnYREceoK0ZExDEKdhERxyjYRUQco2AXEXGMgl1ExDEKdhERxyjYRUQco2AXEXHM/wMWsHwldsBw8QAAAABJRU5ErkJggg==",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "temp = af[af.index == 'OVERALL']\n",
    "temp['mostly_tracked'] = temp['mostly_tracked'] / temp['num_unique_objects']\n",
    "temp['partially_tracked'] = temp['partially_tracked'] / temp['num_unique_objects']\n",
    "temp['mostly_lost'] = temp['mostly_lost'] / temp['num_unique_objects']\n",
    "g = temp[['mostly_tracked', 'partially_tracked', 'mostly_lost','set']].set_index(['set']).groupby(['set']).mean().plot(kind='bar', stacked=True);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# MOTA "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>idf1</th>\n",
       "      <th>idp</th>\n",
       "      <th>idr</th>\n",
       "      <th>recall</th>\n",
       "      <th>precision</th>\n",
       "      <th>num_unique_objects</th>\n",
       "      <th>mostly_tracked</th>\n",
       "      <th>partially_tracked</th>\n",
       "      <th>mostly_lost</th>\n",
       "      <th>num_false_positives</th>\n",
       "      <th>num_misses</th>\n",
       "      <th>num_switches</th>\n",
       "      <th>num_fragmentations</th>\n",
       "      <th>mota</th>\n",
       "      <th>motp</th>\n",
       "      <th>num_transfer</th>\n",
       "      <th>num_ascend</th>\n",
       "      <th>num_migrate</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>set</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>control</th>\n",
       "      <td>0.754576</td>\n",
       "      <td>0.919577</td>\n",
       "      <td>0.639779</td>\n",
       "      <td>0.662855</td>\n",
       "      <td>0.952744</td>\n",
       "      <td>86.0</td>\n",
       "      <td>38.0</td>\n",
       "      <td>18.0</td>\n",
       "      <td>30.0</td>\n",
       "      <td>161.0</td>\n",
       "      <td>1651.0</td>\n",
       "      <td>13.0</td>\n",
       "      <td>28.0</td>\n",
       "      <td>0.627323</td>\n",
       "      <td>0.037094</td>\n",
       "      <td>0.0</td>\n",
       "      <td>12.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>surprise</th>\n",
       "      <td>0.790401</td>\n",
       "      <td>0.968750</td>\n",
       "      <td>0.667511</td>\n",
       "      <td>0.667511</td>\n",
       "      <td>0.968750</td>\n",
       "      <td>33.0</td>\n",
       "      <td>13.0</td>\n",
       "      <td>8.0</td>\n",
       "      <td>12.0</td>\n",
       "      <td>34.0</td>\n",
       "      <td>525.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>11.0</td>\n",
       "      <td>0.645978</td>\n",
       "      <td>0.034979</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              idf1       idp       idr    recall  precision  \\\n",
       "set                                                           \n",
       "control   0.754576  0.919577  0.639779  0.662855   0.952744   \n",
       "surprise  0.790401  0.968750  0.667511  0.667511   0.968750   \n",
       "\n",
       "          num_unique_objects  mostly_tracked  partially_tracked  mostly_lost  \\\n",
       "set                                                                            \n",
       "control                 86.0            38.0               18.0         30.0   \n",
       "surprise                33.0            13.0                8.0         12.0   \n",
       "\n",
       "          num_false_positives  num_misses  num_switches  num_fragmentations  \\\n",
       "set                                                                           \n",
       "control                 161.0      1651.0          13.0                28.0   \n",
       "surprise                 34.0       525.0           0.0                11.0   \n",
       "\n",
       "              mota      motp  num_transfer  num_ascend  num_migrate  \n",
       "set                                                                  \n",
       "control   0.627323  0.037094           0.0        12.0          0.0  \n",
       "surprise  0.645978  0.034979           0.0         0.0          0.0  "
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "af[af.index == 'OVERALL'].groupby(['set']).mean()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Gate Openings"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Percept gate openings when visible: M: 0.223 , STD: 0.303, Count: 1686\n",
      "Percept gate openings when occluded: M: 0.00995 , STD: 0.0471, Count: 477\n"
     ]
    }
   ],
   "source": [
    "grouping = (sf.inimage & sf.bound & ~sf.occluder & sf.control)\n",
    "temp = sf[grouping & sf.visible]\n",
    "print(f'Percept gate openings when visible:' + get_stats(temp['alpha_pos'] + temp['alpha_ges']))\n",
    "temp = sf[grouping & ~sf.visible]\n",
    "print(f'Percept gate openings when occluded:' + get_stats(temp['alpha_pos'] + temp['alpha_ges']))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "loci23",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.16"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}