|
a |
|
b/test_preds.ipynb |
|
|
1 |
{ |
|
|
2 |
"cells": [ |
|
|
3 |
{ |
|
|
4 |
"cell_type": "code", |
|
|
5 |
"execution_count": 1, |
|
|
6 |
"metadata": {}, |
|
|
7 |
"outputs": [ |
|
|
8 |
{ |
|
|
9 |
"name": "stdout", |
|
|
10 |
"output_type": "stream", |
|
|
11 |
"text": [ |
|
|
12 |
"Requirement already satisfied: efficientnet in /home/surya/anaconda3/lib/python3.6/site-packages (1.0.0)\n", |
|
|
13 |
"Requirement already satisfied: scikit-image in /home/surya/anaconda3/lib/python3.6/site-packages (from efficientnet) (0.15.0)\n", |
|
|
14 |
"Requirement already satisfied: keras-applications<=1.0.8,>=1.0.7 in /home/surya/anaconda3/lib/python3.6/site-packages (from efficientnet) (1.0.8)\n", |
|
|
15 |
"Requirement already satisfied: imageio>=2.0.1 in /home/surya/anaconda3/lib/python3.6/site-packages (from scikit-image->efficientnet) (2.3.0)\n", |
|
|
16 |
"Requirement already satisfied: scipy>=0.17.0 in /home/surya/anaconda3/lib/python3.6/site-packages (from scikit-image->efficientnet) (1.1.0)\n", |
|
|
17 |
"Requirement already satisfied: networkx>=2.0 in /home/surya/anaconda3/lib/python3.6/site-packages (from scikit-image->efficientnet) (2.1)\n", |
|
|
18 |
"Requirement already satisfied: matplotlib!=3.0.0,>=2.0.0 in /home/surya/anaconda3/lib/python3.6/site-packages (from scikit-image->efficientnet) (2.2.2)\n", |
|
|
19 |
"Requirement already satisfied: PyWavelets>=0.4.0 in /home/surya/anaconda3/lib/python3.6/site-packages (from scikit-image->efficientnet) (0.5.2)\n", |
|
|
20 |
"Requirement already satisfied: pillow>=4.3.0 in /home/surya/anaconda3/lib/python3.6/site-packages (from scikit-image->efficientnet) (6.2.0)\n", |
|
|
21 |
"Requirement already satisfied: h5py in /home/surya/anaconda3/lib/python3.6/site-packages (from keras-applications<=1.0.8,>=1.0.7->efficientnet) (2.7.1)\n", |
|
|
22 |
"Requirement already satisfied: numpy>=1.9.1 in /home/surya/anaconda3/lib/python3.6/site-packages (from keras-applications<=1.0.8,>=1.0.7->efficientnet) (1.17.3)\n", |
|
|
23 |
"Requirement already satisfied: decorator>=4.1.0 in /home/surya/anaconda3/lib/python3.6/site-packages (from networkx>=2.0->scikit-image->efficientnet) (4.3.0)\n", |
|
|
24 |
"Requirement already satisfied: cycler>=0.10 in /home/surya/anaconda3/lib/python3.6/site-packages (from matplotlib!=3.0.0,>=2.0.0->scikit-image->efficientnet) (0.10.0)\n", |
|
|
25 |
"Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /home/surya/anaconda3/lib/python3.6/site-packages (from matplotlib!=3.0.0,>=2.0.0->scikit-image->efficientnet) (2.2.0)\n", |
|
|
26 |
"Requirement already satisfied: python-dateutil>=2.1 in /home/surya/.local/lib/python3.6/site-packages (from matplotlib!=3.0.0,>=2.0.0->scikit-image->efficientnet) (2.7.3)\n", |
|
|
27 |
"Requirement already satisfied: pytz in /home/surya/.local/lib/python3.6/site-packages (from matplotlib!=3.0.0,>=2.0.0->scikit-image->efficientnet) (2018.5)\n", |
|
|
28 |
"Requirement already satisfied: six>=1.10 in /home/surya/.local/lib/python3.6/site-packages (from matplotlib!=3.0.0,>=2.0.0->scikit-image->efficientnet) (1.11.0)\n", |
|
|
29 |
"Requirement already satisfied: kiwisolver>=1.0.1 in /home/surya/anaconda3/lib/python3.6/site-packages (from matplotlib!=3.0.0,>=2.0.0->scikit-image->efficientnet) (1.0.1)\n", |
|
|
30 |
"Requirement already satisfied: setuptools in /home/surya/anaconda3/lib/python3.6/site-packages (from kiwisolver>=1.0.1->matplotlib!=3.0.0,>=2.0.0->scikit-image->efficientnet) (39.1.0)\n", |
|
|
31 |
"\u001b[33mWARNING: You are using pip version 19.1.1, however version 19.3.1 is available.\n", |
|
|
32 |
"You should consider upgrading via the 'pip install --upgrade pip' command.\u001b[0m\n", |
|
|
33 |
"Requirement already satisfied: iterative-stratification in /home/surya/anaconda3/lib/python3.6/site-packages (0.1.6)\n", |
|
|
34 |
"Requirement already satisfied: scikit-learn in /home/surya/anaconda3/lib/python3.6/site-packages (from iterative-stratification) (0.20.3)\n", |
|
|
35 |
"Requirement already satisfied: numpy in /home/surya/anaconda3/lib/python3.6/site-packages (from iterative-stratification) (1.17.3)\n", |
|
|
36 |
"Requirement already satisfied: scipy in /home/surya/anaconda3/lib/python3.6/site-packages (from iterative-stratification) (1.1.0)\n", |
|
|
37 |
"\u001b[33mWARNING: You are using pip version 19.1.1, however version 19.3.1 is available.\n", |
|
|
38 |
"You should consider upgrading via the 'pip install --upgrade pip' command.\u001b[0m\n", |
|
|
39 |
"Requirement already satisfied: gdown in /home/surya/anaconda3/lib/python3.6/site-packages (3.8.1)\n", |
|
|
40 |
"Requirement already satisfied: six in /home/surya/.local/lib/python3.6/site-packages (from gdown) (1.11.0)\n", |
|
|
41 |
"Requirement already satisfied: filelock in /home/surya/anaconda3/lib/python3.6/site-packages (from gdown) (3.0.4)\n", |
|
|
42 |
"Requirement already satisfied: requests in /home/surya/anaconda3/lib/python3.6/site-packages (from gdown) (2.18.4)\n", |
|
|
43 |
"Requirement already satisfied: tqdm in /home/surya/anaconda3/lib/python3.6/site-packages (from gdown) (4.28.1)\n", |
|
|
44 |
"Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /home/surya/anaconda3/lib/python3.6/site-packages (from requests->gdown) (3.0.4)\n", |
|
|
45 |
"Requirement already satisfied: idna<2.7,>=2.5 in /home/surya/anaconda3/lib/python3.6/site-packages (from requests->gdown) (2.6)\n", |
|
|
46 |
"Requirement already satisfied: urllib3<1.23,>=1.21.1 in /home/surya/anaconda3/lib/python3.6/site-packages (from requests->gdown) (1.22)\n", |
|
|
47 |
"Requirement already satisfied: certifi>=2017.4.17 in /home/surya/anaconda3/lib/python3.6/site-packages (from requests->gdown) (2018.4.16)\n", |
|
|
48 |
"\u001b[33mWARNING: You are using pip version 19.1.1, however version 19.3.1 is available.\n", |
|
|
49 |
"You should consider upgrading via the 'pip install --upgrade pip' command.\u001b[0m\n" |
|
|
50 |
] |
|
|
51 |
} |
|
|
52 |
], |
|
|
53 |
"source": [ |
|
|
54 |
"!pip install efficientnet\n", |
|
|
55 |
"!pip install iterative-stratification\n", |
|
|
56 |
"!pip install gdown" |
|
|
57 |
] |
|
|
58 |
}, |
|
|
59 |
{ |
|
|
60 |
"cell_type": "code", |
|
|
61 |
"execution_count": 2, |
|
|
62 |
"metadata": {}, |
|
|
63 |
"outputs": [], |
|
|
64 |
"source": [ |
|
|
65 |
"import os\n", |
|
|
66 |
"if not os.path.isfile('model_effnet_bo_087.h5'):\n", |
|
|
67 |
" !gdown https://drive.google.com/uc?id=1FXF1HymYbRf3OlThMTXAa74TRup3AhD_" |
|
|
68 |
] |
|
|
69 |
}, |
|
|
70 |
{ |
|
|
71 |
"cell_type": "code", |
|
|
72 |
"execution_count": 3, |
|
|
73 |
"metadata": {}, |
|
|
74 |
"outputs": [ |
|
|
75 |
{ |
|
|
76 |
"name": "stderr", |
|
|
77 |
"output_type": "stream", |
|
|
78 |
"text": [ |
|
|
79 |
"/home/surya/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:523: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n", |
|
|
80 |
" _np_qint8 = np.dtype([(\"qint8\", np.int8, 1)])\n", |
|
|
81 |
"/home/surya/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:524: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n", |
|
|
82 |
" _np_quint8 = np.dtype([(\"quint8\", np.uint8, 1)])\n", |
|
|
83 |
"/home/surya/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:525: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n", |
|
|
84 |
" _np_qint16 = np.dtype([(\"qint16\", np.int16, 1)])\n", |
|
|
85 |
"/home/surya/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:526: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n", |
|
|
86 |
" _np_quint16 = np.dtype([(\"quint16\", np.uint16, 1)])\n", |
|
|
87 |
"/home/surya/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:527: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n", |
|
|
88 |
" _np_qint32 = np.dtype([(\"qint32\", np.int32, 1)])\n", |
|
|
89 |
"/home/surya/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:532: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.\n", |
|
|
90 |
" np_resource = np.dtype([(\"resource\", np.ubyte, 1)])\n", |
|
|
91 |
"/home/surya/anaconda3/lib/python3.6/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.\n", |
|
|
92 |
" from ._conv import register_converters as _register_converters\n", |
|
|
93 |
"Using TensorFlow backend.\n" |
|
|
94 |
] |
|
|
95 |
} |
|
|
96 |
], |
|
|
97 |
"source": [ |
|
|
98 |
"import numpy as np\n", |
|
|
99 |
"import pandas as pd\n", |
|
|
100 |
"import pydicom\n", |
|
|
101 |
"import cv2\n", |
|
|
102 |
"import tensorflow as tf\n", |
|
|
103 |
"import multiprocessing\n", |
|
|
104 |
"from math import ceil, floor\n", |
|
|
105 |
"import keras\n", |
|
|
106 |
"import keras.backend as K\n", |
|
|
107 |
"from keras.callbacks import Callback, ModelCheckpoint\n", |
|
|
108 |
"from keras.layers import Dense, Flatten, Dropout\n", |
|
|
109 |
"from keras.models import Model, load_model\n", |
|
|
110 |
"from keras.utils import Sequence\n", |
|
|
111 |
"from keras.losses import binary_crossentropy\n", |
|
|
112 |
"from keras.optimizers import Adam\n", |
|
|
113 |
"import efficientnet.keras as efn \n", |
|
|
114 |
"from iterstrat.ml_stratifiers import MultilabelStratifiedShuffleSplit\n", |
|
|
115 |
"import matplotlib.pyplot as plt" |
|
|
116 |
] |
|
|
117 |
}, |
|
|
118 |
{ |
|
|
119 |
"cell_type": "code", |
|
|
120 |
"execution_count": 4, |
|
|
121 |
"metadata": {}, |
|
|
122 |
"outputs": [], |
|
|
123 |
"source": [ |
|
|
124 |
"def correct_dcm(dcm):\n", |
|
|
125 |
" x = dcm.pixel_array + 1000\n", |
|
|
126 |
" px_mode = 4096\n", |
|
|
127 |
" x[x>=px_mode] = x[x>=px_mode] - px_mode\n", |
|
|
128 |
" dcm.PixelData = x.tobytes()\n", |
|
|
129 |
" dcm.RescaleIntercept = -1000\n", |
|
|
130 |
"\n", |
|
|
131 |
"def window_image(dcm, window_center, window_width): \n", |
|
|
132 |
" if (dcm.BitsStored == 12) and (dcm.PixelRepresentation == 0) and (int(dcm.RescaleIntercept) > -100):\n", |
|
|
133 |
" correct_dcm(dcm)\n", |
|
|
134 |
" img = dcm.pixel_array * dcm.RescaleSlope + dcm.RescaleIntercept\n", |
|
|
135 |
" \n", |
|
|
136 |
" # Resize\n", |
|
|
137 |
" img = cv2.resize(img, SHAPE[:2], interpolation = cv2.INTER_LINEAR)\n", |
|
|
138 |
" \n", |
|
|
139 |
" img_min = window_center - window_width // 2\n", |
|
|
140 |
" img_max = window_center + window_width // 2\n", |
|
|
141 |
" img = np.clip(img, img_min, img_max)\n", |
|
|
142 |
" return img\n", |
|
|
143 |
"\n", |
|
|
144 |
"def bsb_window(dcm):\n", |
|
|
145 |
" brain_img = window_image(dcm, 40, 80)\n", |
|
|
146 |
" subdural_img = window_image(dcm, 80, 200)\n", |
|
|
147 |
" soft_img = window_image(dcm, 40, 380)\n", |
|
|
148 |
" \n", |
|
|
149 |
" brain_img = (brain_img - 0) / 80\n", |
|
|
150 |
" subdural_img = (subdural_img - (-20)) / 200\n", |
|
|
151 |
" soft_img = (soft_img - (-150)) / 380\n", |
|
|
152 |
" bsb_img = np.array([brain_img, subdural_img, soft_img]).transpose(1,2,0)\n", |
|
|
153 |
" return bsb_img\n", |
|
|
154 |
"\n", |
|
|
155 |
"def _read(path, SHAPE):\n", |
|
|
156 |
" dcm = pydicom.dcmread(path)\n", |
|
|
157 |
" try:\n", |
|
|
158 |
" img = bsb_window(dcm)\n", |
|
|
159 |
" except:\n", |
|
|
160 |
" img = np.zeros(SHAPE)\n", |
|
|
161 |
" return img" |
|
|
162 |
] |
|
|
163 |
}, |
|
|
164 |
{ |
|
|
165 |
"cell_type": "code", |
|
|
166 |
"execution_count": 5, |
|
|
167 |
"metadata": {}, |
|
|
168 |
"outputs": [], |
|
|
169 |
"source": [ |
|
|
170 |
"base_model = efn.EfficientNetB0(weights = 'imagenet', include_top = False, \\\n", |
|
|
171 |
" pooling = 'avg', input_shape = (256, 256, 3))\n", |
|
|
172 |
"\n", |
|
|
173 |
"x = base_model.output\n", |
|
|
174 |
"x = Dropout(0.125)(x)\n", |
|
|
175 |
"output_layer = Dense(6, activation = 'sigmoid')(x)\n", |
|
|
176 |
"model = Model(inputs=base_model.input, outputs=output_layer)\n", |
|
|
177 |
"model.compile(optimizer = Adam(lr = 0.0001), \n", |
|
|
178 |
" loss = 'binary_crossentropy',\n", |
|
|
179 |
" metrics = ['acc'])" |
|
|
180 |
] |
|
|
181 |
}, |
|
|
182 |
{ |
|
|
183 |
"cell_type": "code", |
|
|
184 |
"execution_count": 6, |
|
|
185 |
"metadata": {}, |
|
|
186 |
"outputs": [], |
|
|
187 |
"source": [ |
|
|
188 |
"model.load_weights('model_effnet_bo_087.h5')" |
|
|
189 |
] |
|
|
190 |
}, |
|
|
191 |
{ |
|
|
192 |
"cell_type": "code", |
|
|
193 |
"execution_count": 7, |
|
|
194 |
"metadata": {}, |
|
|
195 |
"outputs": [ |
|
|
196 |
{ |
|
|
197 |
"data": { |
|
|
198 |
"text/plain": [ |
|
|
199 |
"(256, 256)" |
|
|
200 |
] |
|
|
201 |
}, |
|
|
202 |
"execution_count": 7, |
|
|
203 |
"metadata": {}, |
|
|
204 |
"output_type": "execute_result" |
|
|
205 |
} |
|
|
206 |
], |
|
|
207 |
"source": [ |
|
|
208 |
"img_data = _read('ID_000012eaf.dcm', (256, 256))\n", |
|
|
209 |
"img_data.shape" |
|
|
210 |
] |
|
|
211 |
}, |
|
|
212 |
{ |
|
|
213 |
"cell_type": "code", |
|
|
214 |
"execution_count": 14, |
|
|
215 |
"metadata": {}, |
|
|
216 |
"outputs": [ |
|
|
217 |
{ |
|
|
218 |
"data": { |
|
|
219 |
"text/plain": [ |
|
|
220 |
"<matplotlib.image.AxesImage at 0x7f1265f52588>" |
|
|
221 |
] |
|
|
222 |
}, |
|
|
223 |
"execution_count": 14, |
|
|
224 |
"metadata": {}, |
|
|
225 |
"output_type": "execute_result" |
|
|
226 |
}, |
|
|
227 |
{ |
|
|
228 |
"data": { |
|
|
229 |
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAQYAAAD8CAYAAACVSwr3AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAADIlJREFUeJzt3E+MnPV9x/H3p9gYhRCBS0CusQqJXKnkUMdaARJVRIWagC8mByo4BCtCcg5GSqT04CSHcEyrJpGQWiRHQTFVCkVJED7QNmBFQj1AMIgYG5ewIS5sbNlNiQhqJAfIt4d53Az+zXqXnXl2Zqv3S1rN7G+fmf36YfXmeeZfqgpJGvYH0x5A0uwxDJIahkFSwzBIahgGSQ3DIKnRWxiS3JLk5STzSfb29XskTV76eB1DkguAnwJ/CSwAzw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3duz55PsnfY850pyPMmL3VvLD3VrG5M8keSV7vKype6nh7keSHI6yZGhtZFzZeC+bh8fTrJ9Bmadubftn+cjBmZqv67KRyFU1dS+gAuAnwEfAS4EfgJcO82ZRsx4HLj8nLW/BfZ21/cCfzOFuT4BbAeOLDUXsAP4FwbvY7kBeGYGZr0X+OsR217b/R1sAK7p/j4uWKU5NwHbu+uXAD/t5pmp/XqeOSe2T6d9xHAdMF9Vr1bVb4GHGbxte9btBPZ31/cDt632AFX1FPDGOcuLzbUTeLAGngYuPecl7b1aZNbFTO1t+7X4RwzM1H49z5yLed/7dNphWNZbtKesgB8meS7J7m7tyqo6CYP/SMAVU5vuvRaba1b384rftt+3cz5iYGb36yQ/CmHYtMOwrLdoT9mNVbUduBXYk+QT0x5oBWZxP4/1tv0+jfiIgUU3HbG2arNO+qMQhk07DDP/Fu2qOtFdngYeZXAIdursIWN3eXp6E77HYnPN3H6uGX3b/qiPGGAG92vfH4Uw7TA8C2xNck2SCxl8VuSBKc/0f5Jc3H3OJUkuBj7J4O3lB4Bd3Wa7gMemM2FjsbkOAHd1j6LfALx59tB4WmbxbfuLfcQAM7ZfF5tzovt0NR5FXeIR1h0MHlX9GfCVac9zzmwfYfBo7k+Ao2fnA/4QOAi80l1unMJsDzE4XHybwf8R7l5sLgaHkn/f7eMXgbkZmPUfu1kOd3+4m4a2/0o368vAras4558zOMQ+DLzQfe2Ytf16njkntk995aOkxrRPJSTNIMMgqWEYJDUMg6SGYZDUMAySGoZBUsMwSGr8L5WBYebTjJswAAAAAElFTkSuQmCC\n", |
|
|
230 |
"text/plain": [ |
|
|
231 |
"<Figure size 432x288 with 1 Axes>" |
|
|
232 |
] |
|
|
233 |
}, |
|
|
234 |
"metadata": {}, |
|
|
235 |
"output_type": "display_data" |
|
|
236 |
} |
|
|
237 |
], |
|
|
238 |
"source": [ |
|
|
239 |
"plt.imshow(img_data)" |
|
|
240 |
] |
|
|
241 |
}, |
|
|
242 |
{ |
|
|
243 |
"cell_type": "code", |
|
|
244 |
"execution_count": 35, |
|
|
245 |
"metadata": {}, |
|
|
246 |
"outputs": [ |
|
|
247 |
{ |
|
|
248 |
"data": { |
|
|
249 |
"text/plain": [ |
|
|
250 |
"(1, 256, 256, 3)" |
|
|
251 |
] |
|
|
252 |
}, |
|
|
253 |
"execution_count": 35, |
|
|
254 |
"metadata": {}, |
|
|
255 |
"output_type": "execute_result" |
|
|
256 |
} |
|
|
257 |
], |
|
|
258 |
"source": [ |
|
|
259 |
"X = np.empty((1, 256,256, 3))\n", |
|
|
260 |
"X[0] = img_data\n", |
|
|
261 |
"X.shape" |
|
|
262 |
] |
|
|
263 |
}, |
|
|
264 |
{ |
|
|
265 |
"cell_type": "code", |
|
|
266 |
"execution_count": 36, |
|
|
267 |
"metadata": {}, |
|
|
268 |
"outputs": [ |
|
|
269 |
{ |
|
|
270 |
"data": { |
|
|
271 |
"text/plain": [ |
|
|
272 |
"array([[0.02540314, 0.00152788, 0.0010443 , 0.0023855 , 0.00326541,\n", |
|
|
273 |
" 0.00998502]], dtype=float32)" |
|
|
274 |
] |
|
|
275 |
}, |
|
|
276 |
"execution_count": 36, |
|
|
277 |
"metadata": {}, |
|
|
278 |
"output_type": "execute_result" |
|
|
279 |
} |
|
|
280 |
], |
|
|
281 |
"source": [ |
|
|
282 |
"preds = model.predict(X)\n", |
|
|
283 |
"preds" |
|
|
284 |
] |
|
|
285 |
}, |
|
|
286 |
{ |
|
|
287 |
"cell_type": "code", |
|
|
288 |
"execution_count": 37, |
|
|
289 |
"metadata": {}, |
|
|
290 |
"outputs": [ |
|
|
291 |
{ |
|
|
292 |
"data": { |
|
|
293 |
"text/plain": [ |
|
|
294 |
"(1, 6)" |
|
|
295 |
] |
|
|
296 |
}, |
|
|
297 |
"execution_count": 37, |
|
|
298 |
"metadata": {}, |
|
|
299 |
"output_type": "execute_result" |
|
|
300 |
} |
|
|
301 |
], |
|
|
302 |
"source": [ |
|
|
303 |
"preds.shape" |
|
|
304 |
] |
|
|
305 |
} |
|
|
306 |
], |
|
|
307 |
"metadata": { |
|
|
308 |
"kernelspec": { |
|
|
309 |
"display_name": "Python 3", |
|
|
310 |
"language": "python", |
|
|
311 |
"name": "python3" |
|
|
312 |
}, |
|
|
313 |
"language_info": { |
|
|
314 |
"codemirror_mode": { |
|
|
315 |
"name": "ipython", |
|
|
316 |
"version": 3 |
|
|
317 |
}, |
|
|
318 |
"file_extension": ".py", |
|
|
319 |
"mimetype": "text/x-python", |
|
|
320 |
"name": "python", |
|
|
321 |
"nbconvert_exporter": "python", |
|
|
322 |
"pygments_lexer": "ipython3", |
|
|
323 |
"version": "3.6.5" |
|
|
324 |
} |
|
|
325 |
}, |
|
|
326 |
"nbformat": 4, |
|
|
327 |
"nbformat_minor": 1 |
|
|
328 |
} |