|
11 | 11 | }, |
12 | 12 | { |
13 | 13 | "cell_type": "code", |
14 | | - "execution_count": 11, |
| 14 | + "execution_count": 1, |
15 | 15 | "metadata": {}, |
16 | | - "outputs": [], |
| 16 | + "outputs": [ |
| 17 | + { |
| 18 | + "name": "stdout", |
| 19 | + "output_type": "stream", |
| 20 | + "text": [ |
| 21 | + "No module named 'tensorflow.python.tools'\n", |
| 22 | + "proceeding without savelouts , this will only work if no data is being generated\n" |
| 23 | + ] |
| 24 | + } |
| 25 | + ], |
17 | 26 | "source": [ |
18 | 27 | "from sklearn.metrics import r2_score, mean_squared_error\n", |
19 | 28 | "from sklearn.model_selection import train_test_split\n", |
|
23 | 32 | "import pickle, os, argparse\n", |
24 | 33 | "import multiprocessing as mp\n", |
25 | 34 | "import h5py\n", |
| 35 | + "import matplotlib\n", |
26 | 36 | "from sklearn.metrics import roc_auc_score\n", |
27 | 37 | "from sklearn.preprocessing import label_binarize\n", |
28 | 38 | "from sklearn.svm import LinearSVC\n", |
29 | 39 | "from sklearn.multiclass import OneVsRestClassifier\n", |
30 | | - "from controls_main import RunInfo\n", |
31 | | - "from rowwise_neuron_curves_controls import compute_metrics, lstring, get_binidx, get_centers, unit_vector, \\\n", |
| 40 | + "from rowwise_neuron_curves import lstring, read_layer_reps\n", |
| 41 | + "from main import RunInfo\n", |
| 42 | + "from rowwise_neuron_curves import compute_metrics, lstring, get_binidx, get_centers, unit_vector, \\\n", |
32 | 43 | " angle_xaxis, get_polar, linreg, feature_set, X_data\n", |
33 | 44 | "\n", |
34 | 45 | "# GLOBAL PARS\n", |
|
47 | 58 | }, |
48 | 59 | { |
49 | 60 | "cell_type": "code", |
50 | | - "execution_count": 12, |
| 61 | + "execution_count": 13, |
51 | 62 | "metadata": {}, |
52 | 63 | "outputs": [], |
53 | 64 | "source": [ |
54 | 65 | "modelinfo = dict({'type': 'S',\n", |
55 | | - " 'base': 'spatial_temporal_4_8-16-16-32_64-64-64-64_5272',\n", |
56 | | - " 'name': 'spatial_temporal_4_8-16-16-32_64-64-64-64_5272_1',\n", |
57 | | - " 'shortbase': 'Spatial-Temporal',\n", |
58 | | - " 'shortname': 'Spatial-Temporal_1',\n", |
59 | | - " 'nlayers': 8,\n", |
60 | | - " 'max_act': 14,\n", |
61 | | - " 'control': False,\n", |
62 | | - " 'cmap': 'Blues_r',\n", |
63 | | - " 'color': 'C0',\n", |
64 | | - " 'control_cmap': 'Purples_r'})\n", |
| 66 | + " 'typename': 'spatial_temporal',\n", |
| 67 | + " 'base': 'spatial_temporal_4_8-16-16-32_32-32-64-64_7293',\n", |
| 68 | + " 'name': 'spatial_temporal_4_8-16-16-32_32-32-64-64_7293_1',\n", |
| 69 | + " 'base_regression': 'spatial_temporal_r_4_8-16-16-32_32-32-64-64_7293',\n", |
| 70 | + " 'nlayers': 8,\n", |
| 71 | + " 'max_nlayers': 8,\n", |
| 72 | + " 'max_act': 14, #this can be manually adjusted as the maximum in the preferred direction histogram\n", |
| 73 | + " 'control': False,\n", |
| 74 | + " 'cmap': matplotlib.colors.ListedColormap(['midnightblue']),\n", |
| 75 | + " 'color': 'midnightblue',\n", |
| 76 | + " 'regression_color': 'darkturquoise',\n", |
| 77 | + " 'control_cmap': 'Greys_r',\n", |
| 78 | + " 'regression_cmap': matplotlib.colors.ListedColormap(['darkturquoise']),\n", |
| 79 | + " 's_stride': 2,\n", |
| 80 | + " 't_stride': 3,\n", |
| 81 | + " 'regression_task': False,\n", |
| 82 | + " 'model_path': None,\n", |
| 83 | + " 'exp_id': None,})\n", |
65 | 84 | "\n", |
66 | | - "runinfo = RunInfo({'expid': 102, #internal experiment id\n", |
67 | | - " 'datafraction': 0.5,\n", |
| 85 | + "runinfo = RunInfo({'expid': 402, #internal experiment id\n", |
| 86 | + " 'datafraction': 'auto', #fraction (0,1] or 'auto' (i.e. if you want to run a new analysis but keep the old results that it would otherwise overwrite, increment by 1)\n", |
68 | 87 | " 'randomseed': 2000,\n", |
69 | 88 | " 'randomseed_traintest': 42,\n", |
70 | 89 | " 'dirr2threshold': 0.2,\n", |
71 | | - " 'verbose': 0,\n", |
72 | | - " 'model_experiment_id': 4, #as per Pranav's model generation\n", |
73 | | - " 'basefolder' : '/home/kai/Dropbox/DeepDrawData/analysis-data/', #point to analysis-data folder\n", |
74 | | - " #in DeepDrawData folder from Dropbox, include trailing slash\n", |
75 | | - " 'orientation' : 'hor',\n", |
76 | | - " 'height' : 'all'\n", |
| 90 | + " 'verbose': 2, #0 (least), 1, 2 (most)\n", |
| 91 | + " 'model_experiment_id': 22, #used in model training, int or 'auto'\n", |
| 92 | + " 'basefolder': '/media/data/DeepDraw/revisions/analysis-data/', ## change this folder to redirect to where the data is saved locally\n", |
| 93 | + " 'batchsize': 100, #for layer representation generation\n", |
| 94 | + " 'default_run': True, #only variable that is 'trial'-dependent,\n", |
| 95 | + " #ie should be changed when rerunning stuff in same folder\n", |
| 96 | + " #not semantically important for run info\n", |
| 97 | + " 'dpi': 500,\n", |
| 98 | + " 'orientation': 'hor',\n", |
| 99 | + " 'height': 'all',\n", |
77 | 100 | " })" |
78 | 101 | ] |
79 | 102 | }, |
|
86 | 109 | }, |
87 | 110 | { |
88 | 111 | "cell_type": "code", |
89 | | - "execution_count": 59, |
| 112 | + "execution_count": 14, |
90 | 113 | "metadata": {}, |
91 | 114 | "outputs": [], |
92 | 115 | "source": [ |
|
103 | 126 | }, |
104 | 127 | { |
105 | 128 | "cell_type": "code", |
106 | | - "execution_count": 60, |
| 129 | + "execution_count": 15, |
107 | 130 | "metadata": {}, |
108 | 131 | "outputs": [], |
109 | 132 | "source": [ |
|
116 | 139 | }, |
117 | 140 | { |
118 | 141 | "cell_type": "code", |
119 | | - "execution_count": 61, |
| 142 | + "execution_count": 16, |
120 | 143 | "metadata": {}, |
121 | 144 | "outputs": [ |
122 | 145 | { |
123 | 146 | "name": "stdout", |
124 | 147 | "output_type": "stream", |
125 | 148 | "text": [ |
126 | | - "/mnt/data/random_controls/exp102/data/spatial_temporal_4_8-16-16-32_64-64-64-64_5272/spatial_temporal_4_8-16-16-32_64-64-64-64_5272_1\n", |
127 | | - "using alternate method for accessing kinvars files by directly accessing needed arrays (pandas causes error)\n" |
| 149 | + "/media/data/DeepDraw/revisions/analysis-data/exp402/data/spatial_temporal_4_8-16-16-32_32-32-64-64_7293/spatial_temporal_4_8-16-16-32_32-32-64-64_7293_1\n", |
| 150 | + "using alternate method for accessing kinvars files by directly accessing needed arrays (pandas causes error)\n", |
| 151 | + "1256960\n", |
| 152 | + "(1964, 2, 320)\n" |
128 | 153 | ] |
129 | 154 | } |
130 | 155 | ], |
|
141 | 166 | }, |
142 | 167 | { |
143 | 168 | "cell_type": "code", |
144 | | - "execution_count": 62, |
| 169 | + "execution_count": 17, |
145 | 170 | "metadata": {}, |
146 | | - "outputs": [], |
| 171 | + "outputs": [ |
| 172 | + { |
| 173 | + "name": "stdout", |
| 174 | + "output_type": "stream", |
| 175 | + "text": [ |
| 176 | + "read layer represenations. shape: (4000, 4, 320, 16)\n" |
| 177 | + ] |
| 178 | + } |
| 179 | + ], |
147 | 180 | "source": [ |
148 | | - "lo = pickle.load(open(os.path.join(runinfo.datafolder(modelinfo), layer + '.pkl'), 'rb'))\n", |
| 181 | + "lo = read_layer_reps(ilayer, runinfo, modelinfo)\n", |
149 | 182 | "lo = lo[xyplmvt]\n", |
150 | 183 | "\n", |
151 | | - "centers = get_centers(lo.shape[2])\n", |
| 184 | + "centers = get_centers(lo.shape[2], ilayer, modelinfo)\n", |
152 | 185 | "\n", |
153 | | - "if (fset == 'vel' or fset == 'acc' or fset == 'eepolar' or fset == 'ang' or fset=='angvel' or fset=='ee'):\n", |
| 186 | + "if (fset == 'vel' or fset == 'acc' or fset == 'eepolar' or fset == 'ang' or fset=='angvel' or fset=='ee' or fset == 'dir'):\n", |
154 | 187 | " nmods = 4\n", |
155 | 188 | " nmets = 6\n", |
156 | 189 | "elif (fset == 'labels'):\n", |
157 | 190 | " nmods = 1\n", |
158 | | - " nmets = 1" |
| 191 | + " nmets = 1\n", |
| 192 | + "else:\n", |
| 193 | + " assert False, 'invalid f_set'" |
159 | 194 | ] |
160 | 195 | }, |
161 | 196 | { |
162 | 197 | "cell_type": "code", |
163 | | - "execution_count": 63, |
| 198 | + "execution_count": 18, |
164 | 199 | "metadata": {}, |
165 | 200 | "outputs": [], |
166 | 201 | "source": [ |
|
172 | 207 | }, |
173 | 208 | { |
174 | 209 | "cell_type": "code", |
175 | | - "execution_count": 64, |
| 210 | + "execution_count": 19, |
176 | 211 | "metadata": {}, |
177 | 212 | "outputs": [], |
178 | 213 | "source": [ |
|
185 | 220 | }, |
186 | 221 | { |
187 | 222 | "cell_type": "code", |
188 | | - "execution_count": 65, |
| 223 | + "execution_count": 20, |
189 | 224 | "metadata": {}, |
190 | 225 | "outputs": [], |
191 | 226 | "source": [ |
|
323 | 358 | }, |
324 | 359 | { |
325 | 360 | "cell_type": "code", |
326 | | - "execution_count": 66, |
| 361 | + "execution_count": 21, |
327 | 362 | "metadata": { |
328 | 363 | "scrolled": true |
329 | 364 | }, |
|
442 | 477 | }, |
443 | 478 | { |
444 | 479 | "cell_type": "code", |
445 | | - "execution_count": 67, |
| 480 | + "execution_count": 22, |
446 | 481 | "metadata": {}, |
447 | 482 | "outputs": [], |
448 | 483 | "source": [ |
|
465 | 500 | }, |
466 | 501 | { |
467 | 502 | "cell_type": "code", |
468 | | - "execution_count": 69, |
| 503 | + "execution_count": 23, |
469 | 504 | "metadata": {}, |
470 | 505 | "outputs": [ |
471 | 506 | { |
472 | 507 | "name": "stdout", |
473 | 508 | "output_type": "stream", |
474 | 509 | "text": [ |
475 | | - "spatial_temporal_4_8-16-16-32_64-64-64-64_5272_1 Layer 3: \n", |
| 510 | + "spatial_temporal_4_8-16-16-32_32-32-64-64_7293_1 Layer 3: \n", |
476 | 511 | "\n", |
477 | 512 | "RMSE: \n", |
478 | | - "Min: -0.0085\n", |
479 | | - "Max: 0.0389\n", |
480 | | - "Mean: 0.0097\n", |
481 | | - "25pc Quantile: 0.0046\n", |
482 | | - "Median: 0.0093\n", |
483 | | - "75pc Quantile: 0.0127\n", |
| 513 | + "Min: nan\n", |
| 514 | + "Max: nan\n", |
| 515 | + "Mean: nan\n", |
| 516 | + "25pc Quantile: nan\n", |
| 517 | + "Median: nan\n", |
| 518 | + "75pc Quantile: nan\n", |
484 | 519 | "\n", |
485 | 520 | "\n", |
486 | | - "R2: \n" |
487 | | - ] |
488 | | - }, |
489 | | - { |
490 | | - "ename": "IndexError", |
491 | | - "evalue": "index 1 is out of bounds for axis 1 with size 1", |
492 | | - "output_type": "error", |
493 | | - "traceback": [ |
494 | | - "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", |
495 | | - "\u001b[0;31mIndexError\u001b[0m Traceback (most recent call last)", |
496 | | - "\u001b[0;32m<ipython-input-69-fcb51a5e9d9b>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 6\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"\\n\\nR2: \"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 7\u001b[0;31m \u001b[0mprint_statistics\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtestevals\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 8\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 9\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"\\n\\nPCC: \"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", |
497 | | - "\u001b[0;31mIndexError\u001b[0m: index 1 is out of bounds for axis 1 with size 1" |
| 521 | + "R2: \n", |
| 522 | + "Min: 0.0000\n", |
| 523 | + "Max: 2382973486990906079431681999784995771544749166977351114241131154861388307168959570808358856727180433693371174601667748650793646381061578975953292557346001152289641613754368.0000\n", |
| 524 | + "Mean: 6205660122372151248520005207773426488397784289003518526669612382451532049919165548980101189393699046076487433858509762111441787450681195249878366034755211334087608369152.0000\n", |
| 525 | + "25pc Quantile: 0.0000\n", |
| 526 | + "Median: 0.0000\n", |
| 527 | + "75pc Quantile: 0.0000\n", |
| 528 | + "\n", |
| 529 | + "\n", |
| 530 | + "PCC: \n", |
| 531 | + "Min: 0.0000\n", |
| 532 | + "Max: 0.0000\n", |
| 533 | + "Mean: 0.0000\n", |
| 534 | + "25pc Quantile: 0.0000\n", |
| 535 | + "Median: 0.0000\n", |
| 536 | + "75pc Quantile: 0.0000\n" |
498 | 537 | ] |
499 | 538 | } |
500 | 539 | ], |
|
538 | 577 | "name": "python", |
539 | 578 | "nbconvert_exporter": "python", |
540 | 579 | "pygments_lexer": "ipython3", |
541 | | - "version": "3.7.1" |
| 580 | + "version": "3.8.5" |
542 | 581 | } |
543 | 582 | }, |
544 | 583 | "nbformat": 4, |
|
0 commit comments