Switch to unified view

a b/Ensemble/Ensemble-all.ipynb
1
{
2
 "cells": [
3
  {
4
   "cell_type": "code",
5
   "execution_count": 1,
6
   "source": [
7
    "# Import libraries\n",
8
    "import numpy as np\n",
9
    "import pandas as pd\n",
10
    "import matplotlib.pyplot as plt\n",
11
    "import getpass\n",
12
    "import pdvega\n",
13
    "import plotly.graph_objs as go\n",
14
    "\n",
15
    "from plotly.offline import iplot, init_notebook_mode\n",
16
    "import plotly.io as pio\n",
17
    "from plotly.graph_objs import *\n",
18
    "\n",
19
    "# for configuring connection \n",
20
    "from configobj import ConfigObj\n",
21
    "import os\n",
22
    "\n",
23
    "%matplotlib inline\n",
24
    "\n",
25
    "\n",
26
    "import os\n",
27
    "\n",
28
    "\n",
29
    "from sklearn import linear_model\n",
30
    "from sklearn import metrics\n",
31
    "from sklearn.model_selection import train_test_split\n",
32
    "\n",
33
    "#configure the notebook for use in offline mode\n",
34
    "init_notebook_mode(connected=True)"
35
   ],
36
   "outputs": [
37
    {
38
     "output_type": "display_data",
39
     "data": {
40
      "text/html": [
41
       "<script type=\"text/javascript\">window.PlotlyConfig = {MathJaxConfig: 'local'};</script><script type=\"text/javascript\">if (window.MathJax) {MathJax.Hub.Config({SVG: {font: \"STIX-Web\"}});}</script><script>requirejs.config({paths: { 'plotly': ['https://cdn.plot.ly/plotly-latest.min']},});if(!window._Plotly) {require(['plotly'],function(plotly) {window._Plotly=plotly;});}</script>"
42
      ],
43
      "text/vnd.plotly.v1+html": [
44
       "<script type=\"text/javascript\">window.PlotlyConfig = {MathJaxConfig: 'local'};</script><script type=\"text/javascript\">if (window.MathJax) {MathJax.Hub.Config({SVG: {font: \"STIX-Web\"}});}</script><script>requirejs.config({paths: { 'plotly': ['https://cdn.plot.ly/plotly-latest.min']},});if(!window._Plotly) {require(['plotly'],function(plotly) {window._Plotly=plotly;});}</script>"
45
      ]
46
     },
47
     "metadata": {}
48
    }
49
   ],
50
   "metadata": {}
51
  },
52
  {
53
   "cell_type": "code",
54
   "execution_count": 2,
55
   "source": [
56
    "df2= pd.read_csv(\"analysis.csv\")"
57
   ],
58
   "outputs": [],
59
   "metadata": {}
60
  },
61
  {
62
   "cell_type": "code",
63
   "execution_count": 3,
64
   "source": [
65
    "df2.head()"
66
   ],
67
   "outputs": [
68
    {
69
     "output_type": "execute_result",
70
     "data": {
71
      "text/html": [
72
       "<div>\n",
73
       "<style scoped>\n",
74
       "    .dataframe tbody tr th:only-of-type {\n",
75
       "        vertical-align: middle;\n",
76
       "    }\n",
77
       "\n",
78
       "    .dataframe tbody tr th {\n",
79
       "        vertical-align: top;\n",
80
       "    }\n",
81
       "\n",
82
       "    .dataframe thead th {\n",
83
       "        text-align: right;\n",
84
       "    }\n",
85
       "</style>\n",
86
       "<table border=\"1\" class=\"dataframe\">\n",
87
       "  <thead>\n",
88
       "    <tr style=\"text-align: right;\">\n",
89
       "      <th></th>\n",
90
       "      <th>Unnamed: 0</th>\n",
91
       "      <th>hospitalid</th>\n",
92
       "      <th>sodium</th>\n",
93
       "      <th>electivesurgery</th>\n",
94
       "      <th>vent</th>\n",
95
       "      <th>dialysis</th>\n",
96
       "      <th>gcs</th>\n",
97
       "      <th>urine</th>\n",
98
       "      <th>wbc</th>\n",
99
       "      <th>temperature</th>\n",
100
       "      <th>...</th>\n",
101
       "      <th>m11_True</th>\n",
102
       "      <th>m12_True</th>\n",
103
       "      <th>m13_True</th>\n",
104
       "      <th>m14_True</th>\n",
105
       "      <th>m15_True</th>\n",
106
       "      <th>m16_True</th>\n",
107
       "      <th>m17_True</th>\n",
108
       "      <th>m18_True</th>\n",
109
       "      <th>m19_True</th>\n",
110
       "      <th>m20_True</th>\n",
111
       "    </tr>\n",
112
       "  </thead>\n",
113
       "  <tbody>\n",
114
       "    <tr>\n",
115
       "      <th>0</th>\n",
116
       "      <td>0</td>\n",
117
       "      <td>59.0</td>\n",
118
       "      <td>139.0</td>\n",
119
       "      <td>-1.0</td>\n",
120
       "      <td>0.0</td>\n",
121
       "      <td>0.0</td>\n",
122
       "      <td>15.0</td>\n",
123
       "      <td>-1.0</td>\n",
124
       "      <td>14.7</td>\n",
125
       "      <td>36.1</td>\n",
126
       "      <td>...</td>\n",
127
       "      <td>1</td>\n",
128
       "      <td>0</td>\n",
129
       "      <td>0</td>\n",
130
       "      <td>1</td>\n",
131
       "      <td>1</td>\n",
132
       "      <td>0</td>\n",
133
       "      <td>0</td>\n",
134
       "      <td>0</td>\n",
135
       "      <td>1</td>\n",
136
       "      <td>0</td>\n",
137
       "    </tr>\n",
138
       "    <tr>\n",
139
       "      <th>1</th>\n",
140
       "      <td>1</td>\n",
141
       "      <td>73.0</td>\n",
142
       "      <td>134.0</td>\n",
143
       "      <td>-1.0</td>\n",
144
       "      <td>0.0</td>\n",
145
       "      <td>0.0</td>\n",
146
       "      <td>13.0</td>\n",
147
       "      <td>-1.0</td>\n",
148
       "      <td>14.1</td>\n",
149
       "      <td>39.3</td>\n",
150
       "      <td>...</td>\n",
151
       "      <td>1</td>\n",
152
       "      <td>0</td>\n",
153
       "      <td>0</td>\n",
154
       "      <td>1</td>\n",
155
       "      <td>1</td>\n",
156
       "      <td>0</td>\n",
157
       "      <td>0</td>\n",
158
       "      <td>0</td>\n",
159
       "      <td>1</td>\n",
160
       "      <td>0</td>\n",
161
       "    </tr>\n",
162
       "    <tr>\n",
163
       "      <th>2</th>\n",
164
       "      <td>2</td>\n",
165
       "      <td>73.0</td>\n",
166
       "      <td>-1.0</td>\n",
167
       "      <td>1.0</td>\n",
168
       "      <td>1.0</td>\n",
169
       "      <td>0.0</td>\n",
170
       "      <td>15.0</td>\n",
171
       "      <td>-1.0</td>\n",
172
       "      <td>8.0</td>\n",
173
       "      <td>34.8</td>\n",
174
       "      <td>...</td>\n",
175
       "      <td>0</td>\n",
176
       "      <td>0</td>\n",
177
       "      <td>1</td>\n",
178
       "      <td>0</td>\n",
179
       "      <td>0</td>\n",
180
       "      <td>1</td>\n",
181
       "      <td>0</td>\n",
182
       "      <td>1</td>\n",
183
       "      <td>0</td>\n",
184
       "      <td>0</td>\n",
185
       "    </tr>\n",
186
       "    <tr>\n",
187
       "      <th>3</th>\n",
188
       "      <td>3</td>\n",
189
       "      <td>63.0</td>\n",
190
       "      <td>137.0</td>\n",
191
       "      <td>-1.0</td>\n",
192
       "      <td>0.0</td>\n",
193
       "      <td>0.0</td>\n",
194
       "      <td>15.0</td>\n",
195
       "      <td>-1.0</td>\n",
196
       "      <td>10.9</td>\n",
197
       "      <td>36.6</td>\n",
198
       "      <td>...</td>\n",
199
       "      <td>1</td>\n",
200
       "      <td>0</td>\n",
201
       "      <td>1</td>\n",
202
       "      <td>1</td>\n",
203
       "      <td>1</td>\n",
204
       "      <td>0</td>\n",
205
       "      <td>0</td>\n",
206
       "      <td>1</td>\n",
207
       "      <td>1</td>\n",
208
       "      <td>0</td>\n",
209
       "    </tr>\n",
210
       "    <tr>\n",
211
       "      <th>4</th>\n",
212
       "      <td>4</td>\n",
213
       "      <td>63.0</td>\n",
214
       "      <td>135.0</td>\n",
215
       "      <td>-1.0</td>\n",
216
       "      <td>0.0</td>\n",
217
       "      <td>0.0</td>\n",
218
       "      <td>15.0</td>\n",
219
       "      <td>-1.0</td>\n",
220
       "      <td>5.9</td>\n",
221
       "      <td>35.0</td>\n",
222
       "      <td>...</td>\n",
223
       "      <td>0</td>\n",
224
       "      <td>0</td>\n",
225
       "      <td>1</td>\n",
226
       "      <td>0</td>\n",
227
       "      <td>0</td>\n",
228
       "      <td>0</td>\n",
229
       "      <td>0</td>\n",
230
       "      <td>1</td>\n",
231
       "      <td>0</td>\n",
232
       "      <td>0</td>\n",
233
       "    </tr>\n",
234
       "  </tbody>\n",
235
       "</table>\n",
236
       "<p>5 rows × 85 columns</p>\n",
237
       "</div>"
238
      ],
239
      "text/plain": [
240
       "   Unnamed: 0  hospitalid  sodium  electivesurgery  vent  dialysis   gcs  \\\n",
241
       "0           0        59.0   139.0             -1.0   0.0       0.0  15.0   \n",
242
       "1           1        73.0   134.0             -1.0   0.0       0.0  13.0   \n",
243
       "2           2        73.0    -1.0              1.0   1.0       0.0  15.0   \n",
244
       "3           3        63.0   137.0             -1.0   0.0       0.0  15.0   \n",
245
       "4           4        63.0   135.0             -1.0   0.0       0.0  15.0   \n",
246
       "\n",
247
       "   urine   wbc  temperature  ...  m11_True  m12_True  m13_True  m14_True  \\\n",
248
       "0   -1.0  14.7         36.1  ...         1         0         0         1   \n",
249
       "1   -1.0  14.1         39.3  ...         1         0         0         1   \n",
250
       "2   -1.0   8.0         34.8  ...         0         0         1         0   \n",
251
       "3   -1.0  10.9         36.6  ...         1         0         1         1   \n",
252
       "4   -1.0   5.9         35.0  ...         0         0         1         0   \n",
253
       "\n",
254
       "   m15_True  m16_True  m17_True  m18_True  m19_True  m20_True  \n",
255
       "0         1         0         0         0         1         0  \n",
256
       "1         1         0         0         0         1         0  \n",
257
       "2         0         1         0         1         0         0  \n",
258
       "3         1         0         0         1         1         0  \n",
259
       "4         0         0         0         1         0         0  \n",
260
       "\n",
261
       "[5 rows x 85 columns]"
262
      ]
263
     },
264
     "metadata": {},
265
     "execution_count": 3
266
    }
267
   ],
268
   "metadata": {}
269
  },
270
  {
271
   "cell_type": "code",
272
   "execution_count": 4,
273
   "source": [
274
    "del df2['hospitalid']\n",
275
    "\n",
276
    "df2 = df2.drop(df2.columns[[0]], axis=1)"
277
   ],
278
   "outputs": [],
279
   "metadata": {}
280
  },
281
  {
282
   "cell_type": "code",
283
   "execution_count": 5,
284
   "source": [
285
    "df2.shape"
286
   ],
287
   "outputs": [
288
    {
289
     "output_type": "execute_result",
290
     "data": {
291
      "text/plain": [
292
       "(95148, 83)"
293
      ]
294
     },
295
     "metadata": {},
296
     "execution_count": 5
297
    }
298
   ],
299
   "metadata": {}
300
  },
301
  {
302
   "cell_type": "markdown",
303
   "source": [
304
    "**We moved all the pre-processing including splitting>imputation>Standardization to the CV iterations**"
305
   ],
306
   "metadata": {}
307
  },
308
  {
309
   "cell_type": "code",
310
   "execution_count": 6,
311
   "source": [
312
    "cols_to_norm=['gcs', 'urine', 'wbc', 'sodium',\n",
313
    "       'temperature', 'respiratoryrate', 'heartrate', 'meanbp', 'creatinine',\n",
314
    "       'ph', 'hematocrit', 'albumin', 'pao2', 'pco2', 'bun', 'glucose',\n",
315
    "       'bilirubin', 'fio2', 'age', 'offset']\n",
316
    "\n",
317
    "X=df2.drop('destcopy', 1)\n",
318
    "y=df2['destcopy']\n",
319
    "df_cols = list(X)     #fancy impute removes column names."
320
   ],
321
   "outputs": [],
322
   "metadata": {}
323
  },
324
  {
325
   "cell_type": "code",
326
   "execution_count": 8,
327
   "source": [
328
    "# Load in our libraries\n",
329
    "import pandas as pd\n",
330
    "import numpy as np\n",
331
    "import re\n",
332
    "import sklearn\n",
333
    "import xgboost as xgb\n",
334
    "import seaborn as sns\n",
335
    "import matplotlib.pyplot as plt\n",
336
    "%matplotlib inline\n",
337
    "\n",
338
    "import plotly.offline as py\n",
339
    "py.init_notebook_mode(connected=True)\n",
340
    "import plotly.graph_objs as go\n",
341
    "import plotly.tools as tls\n",
342
    "\n",
343
    "import warnings\n",
344
    "warnings.filterwarnings('ignore')\n",
345
    "\n",
346
    "# Going to use these 5 base models for the stacking\n",
347
    "from sklearn.ensemble import (RandomForestClassifier, AdaBoostClassifier, \n",
348
    "                              GradientBoostingClassifier, ExtraTreesClassifier)\n",
349
    "from sklearn.svm import SVC\n",
350
    "from sklearn.model_selection import KFold\n",
351
    "from sklearn.linear_model import LogisticRegression"
352
   ],
353
   "outputs": [
354
    {
355
     "output_type": "display_data",
356
     "data": {
357
      "text/html": [
358
       "<script type=\"text/javascript\">window.PlotlyConfig = {MathJaxConfig: 'local'};</script><script type=\"text/javascript\">if (window.MathJax) {MathJax.Hub.Config({SVG: {font: \"STIX-Web\"}});}</script><script>requirejs.config({paths: { 'plotly': ['https://cdn.plot.ly/plotly-latest.min']},});if(!window._Plotly) {require(['plotly'],function(plotly) {window._Plotly=plotly;});}</script>"
359
      ],
360
      "text/vnd.plotly.v1+html": [
361
       "<script type=\"text/javascript\">window.PlotlyConfig = {MathJaxConfig: 'local'};</script><script type=\"text/javascript\">if (window.MathJax) {MathJax.Hub.Config({SVG: {font: \"STIX-Web\"}});}</script><script>requirejs.config({paths: { 'plotly': ['https://cdn.plot.ly/plotly-latest.min']},});if(!window._Plotly) {require(['plotly'],function(plotly) {window._Plotly=plotly;});}</script>"
362
      ]
363
     },
364
     "metadata": {}
365
    }
366
   ],
367
   "metadata": {}
368
  },
369
  {
370
   "cell_type": "code",
371
   "execution_count": 9,
372
   "source": [
373
    "from sklearn.model_selection import StratifiedKFold"
374
   ],
375
   "outputs": [],
376
   "metadata": {}
377
  },
378
  {
379
   "cell_type": "code",
380
   "execution_count": 10,
381
   "source": [
382
    "\n",
383
    "classes=['Death','Home','Nursing Home','Rehabilitation']\n",
384
    "\n",
385
    "kf_m = StratifiedKFold(n_splits=10)\n",
386
    "\n",
387
    "\n",
388
    "\n",
389
    "# Class to extend the Sklearn classifier\n",
390
    "class SklearnHelper(object):\n",
391
    "    def __init__(self, clf, seed=0, params=None):\n",
392
    "        params['random_state'] = seed\n",
393
    "        self.clf = clf(**params)\n",
394
    "\n",
395
    "    def train(self, x_train, y_train):\n",
396
    "        self.clf.fit(x_train, y_train)\n",
397
    "\n",
398
    "    def predict(self, x):\n",
399
    "        return self.clf.predict(x)\n",
400
    "\n",
401
    "    def fit(self,x,y):\n",
402
    "        return self.clf.fit(x,y)\n",
403
    "\n",
404
    "    def feature_importances(self,x,y):\n",
405
    "        return(self.clf.fit(x,y).feature_importances_)\n",
406
    "    \n",
407
    "\n",
408
    "\n",
409
    "\n",
410
    "#-------------------------------------------------------------\n",
411
    "\n",
412
    "\n",
413
    "\n",
414
    "\n",
415
    "#------------------------------------------\n",
416
    "\n",
417
    "rf_params = {\n",
418
    "    'n_jobs': -1,\n",
419
    "    'n_estimators': 400,\n",
420
    "     'warm_start': True, \n",
421
    "     #'max_features': 0.2,\n",
422
    "    'max_depth': 30,\n",
423
    "    'min_samples_leaf': 2,\n",
424
    "    'max_features' : 0.8,\n",
425
    "    'verbose': 0,\n",
426
    "     'criterion':'gini'\n",
427
    "}\n",
428
    "\n",
429
    "\n",
430
    "# Extra Trees Parameters\n",
431
    "et_params = {\n",
432
    "    'n_jobs': -1,\n",
433
    "    'n_estimators':500,\n",
434
    "    #'max_features': 0.5,\n",
435
    "    'max_depth': 8,\n",
436
    "    'min_samples_leaf': 2,\n",
437
    "    'verbose': 0\n",
438
    "}\n",
439
    "\n",
440
    "# AdaBoost parameters\n",
441
    "ada_params = {\n",
442
    "    'n_estimators': 500,\n",
443
    "    'learning_rate' : 0.75\n",
444
    "}\n",
445
    "\n",
446
    "# Gradient Boosting parameters\n",
447
    "gb_params = {\n",
448
    "    'n_estimators': 500,\n",
449
    "     #'max_features': 0.2,\n",
450
    "    'max_depth': 5,\n",
451
    "    'min_samples_leaf': 2,\n",
452
    "    'verbose': 0\n",
453
    "}\n",
454
    "\n",
455
    "\n",
456
    "\n",
457
    "# Support Vector Classifier parameters \n",
458
    "lr_params = {\n",
459
    "    'penalty' : 'l1',\n",
460
    "    'tol' : 6.75e-05,\n",
461
    "    'C' : 2.5,\n",
462
    "    'max_iter': 66\n",
463
    "    }\n",
464
    "\n"
465
   ],
466
   "outputs": [],
467
   "metadata": {}
468
  },
469
  {
470
   "cell_type": "markdown",
471
   "source": [
472
    "**Random Forest**"
473
   ],
474
   "metadata": {}
475
  },
476
  {
477
   "cell_type": "code",
478
   "execution_count": 11,
479
   "source": [
480
    "from collections import Counter"
481
   ],
482
   "outputs": [],
483
   "metadata": {}
484
  },
485
  {
486
   "cell_type": "code",
487
   "execution_count": 12,
488
   "source": [
489
    "from sklearn.model_selection import KFold\n",
490
    "from sklearn import preprocessing\n",
491
    "from imblearn.over_sampling import SMOTENC\n",
492
    "from sklearn.metrics import f1_score\n",
493
    "from yellowbrick.classifier import ROCAUC\n",
494
    "from sklearn.linear_model import LogisticRegression\n",
495
    "from numpy import loadtxt\n",
496
    "import os\n",
497
    "os.environ['KMP_DUPLICATE_LIB_OK']='True'\n",
498
    "from xgboost import XGBClassifier\n",
499
    "from sklearn.model_selection import train_test_split\n",
500
    "from sklearn.metrics import accuracy_score\n",
501
    "from sklearn.ensemble import AdaBoostClassifier\n",
502
    "from sklearn.datasets import make_classification\n",
503
    "from sklearn.model_selection import StratifiedKFold\n",
504
    "import io \n",
505
    "\n",
506
    "\n",
507
    "\n",
508
    "for fold, (train_index, test_index) in enumerate(kf_m.split(X,y), 1):\n",
509
    "    X_train = X.iloc[train_index]\n",
510
    "    y_train = y.iloc[train_index]  # Based on your code, you might need a ravel call here, but I would look into how you're generating your y\n",
511
    "    X_test = X.iloc[test_index]\n",
512
    "    y_test = y.iloc[test_index]  # See comment on ravel and  y_train\n",
513
    "    \n",
514
    "    \n",
515
    "#------------------------------Standardize Testing Set------------------------------------\n",
516
    "    \n",
517
    "    std_scale = preprocessing.StandardScaler().fit(X_train[cols_to_norm])\n",
518
    "    X_train[cols_to_norm] = std_scale.transform(X_train[cols_to_norm])\n",
519
    "    X_test[cols_to_norm] = std_scale.transform(X_test[cols_to_norm])\n",
520
    "#------------------------------------------------------------------------------------------\n",
521
    "\n",
522
    " # Hyperparameters are optimized using hyperopt\n",
523
    "\n",
524
    "\n",
525
    "\n",
526
    "# Class to extend XGboost classifer\n",
527
    "    sm = SMOTENC(random_state=50, categorical_features=[1,2,3,22,23,24,25,26,27,28,29,30,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])\n",
528
    "    X_train_oversampled, y_train_oversampled = sm.fit_sample(X_train, y_train)\n",
529
    "    print(sorted(Counter(y_train_oversampled).items()))\n",
530
    "    \n",
531
    "# --------------- Let's Start the fun ------------------------\n",
532
    "\n",
533
    "    # Some useful parameters which will come in handy later on\n",
534
    "    ntrain = X_train_oversampled.shape[0]\n",
535
    "    print(ntrain)\n",
536
    "    ntest = X_test.shape[0]\n",
537
    "    SEED = 0 # for reproducibility\n",
538
    "    # set folds for out-of-fold prediction\n",
539
    "    #kf = KFold(ntrain, n_split=5, random_state=SEED)\n",
540
    "    \n",
541
    "    def get_oof(clf, x_train, y_train, x_test):\n",
542
    "        oof_train = np.zeros((ntrain,))\n",
543
    "        oof_test = np.zeros((ntest,))\n",
544
    "        oof_test_skf = np.empty((10, ntest))\n",
545
    "\n",
546
    "\n",
547
    "        for i, (train_index, test_index) in enumerate(kf_m.split(x_train, y_train)):\n",
548
    "            x_tr = x_train[train_index]\n",
549
    "            y_tr = y_train[train_index]\n",
550
    "            x_te = x_train[test_index]\n",
551
    "\n",
552
    "            clf.train(x_tr, y_tr)\n",
553
    "            \n",
554
    "            oof_train[test_index] = clf.predict(x_te)\n",
555
    "            oof_test_skf[i, :] = clf.predict(x_test)\n",
556
    "\n",
557
    "        oof_test[:] = oof_test_skf.mean(axis=0)\n",
558
    "        return oof_train.reshape(-1, 1), oof_test.reshape(-1, 1)\n",
559
    "    \n",
560
    "        # Create 5 objects that represent our 4 models\n",
561
    "    #rf = SklearnHelper(clf=RandomForestClassifier, seed=SEED, params=rf_params)\n",
562
    "    et = SklearnHelper(clf=ExtraTreesClassifier, seed=SEED, params=et_params)\n",
563
    "    #ada = SklearnHelper(clf=AdaBoostClassifier, seed=SEED, params=ada_params)\n",
564
    "    gb = SklearnHelper(clf=GradientBoostingClassifier, seed=SEED, params=gb_params)\n",
565
    "    #lr = SklearnHelper(clf=LogisticRegression, seed=SEED, params=lr_params)\n",
566
    "\n",
567
    "    #------------------------------------------\n",
568
    "    # Create our OOF train and test predictions. These base results will be used as new features\n",
569
    "    et_oof_train, et_oof_test = get_oof(et, X_train_oversampled, y_train_oversampled, X_test) # Extra Trees\n",
570
    "    #rf_oof_train, rf_oof_test = get_oof(rf,X_train_oversampled, y_train_oversampled, X_test) # Random Forest\n",
571
    "    #ada_oof_train, ada_oof_test = get_oof(ada, X_train_oversampled, y_train_oversampled, X_test) # AdaBoost \n",
572
    "    gb_oof_train, gb_oof_test = get_oof(gb,X_train_oversampled, y_train_oversampled, X_test) # Gradient Boost\n",
573
    "    #lr_oof_train, lr_oof_test = get_oof(lr,X_train_oversampled, y_train_oversampled, X_test) # Support Vector Classifier\n",
574
    "\n",
575
    "    print(\"Training is complete\")\n",
576
    "\n",
577
    "\n",
578
    "\n",
579
    "    #rf_features = rf.feature_importances(X_train_oversampled,y_train_oversampled).tolist()\n",
580
    "    et_features = et.feature_importances(X_train_oversampled, y_train_oversampled).tolist()\n",
581
    "    #ada_features = ada.feature_importances(X_train_oversampled, y_train_oversampled).tolist()\n",
582
    "    gb_features = gb.feature_importances(X_train_oversampled, y_train_oversampled).tolist()\n",
583
    "    #lr_features=(map(abs,lr_features)) / (abs(lr_fit.coef_).max())\n",
584
    "\n",
585
    "\n",
586
    "\n",
587
    "    cols = df2.drop('destcopy', 1).columns.values\n",
588
    "        # Create a dataframe with features\n",
589
    "    feature_dataframe = pd.DataFrame( {'features': cols,\n",
590
    "         \n",
591
    "         'Extra Trees  feature importances': et_features,\n",
592
    "         \n",
593
    "         'Gradient Boost feature importances': gb_features,\n",
594
    "         #'LR feature importances': lr_features\n",
595
    "        })\n",
596
    "\n",
597
    "\n",
598
    "\n",
599
    "\n",
600
    "    # Create a dataframe with features\n",
601
    "\n",
602
    "\n",
603
    "\n",
604
    "\n",
605
    "    # Scatter plot \n",
606
    "    trace = go.Scatter(\n",
607
    "        y = feature_dataframe['Extra Trees  feature importances'].values,\n",
608
    "        x = feature_dataframe['features'].values,\n",
609
    "        mode='markers',\n",
610
    "        marker=dict(\n",
611
    "            sizemode = 'diameter',\n",
612
    "            sizeref = 1,\n",
613
    "            size = 25,\n",
614
    "    #       size= feature_dataframe['AdaBoost feature importances'].values,\n",
615
    "            #color = np.random.randn(500), #set color equal to a variable\n",
616
    "            color = feature_dataframe['Extra Trees  feature importances'].values,\n",
617
    "            colorscale='Portland',\n",
618
    "            showscale=True\n",
619
    "        ),\n",
620
    "        text = feature_dataframe['features'].values\n",
621
    "    )\n",
622
    "    data = [trace]\n",
623
    "\n",
624
    "    layout= go.Layout(\n",
625
    "        autosize= True,\n",
626
    "        title= 'Extra Trees Feature Importance',\n",
627
    "        hovermode= 'closest',\n",
628
    "    #     xaxis= dict(\n",
629
    "    #         title= 'Pop',\n",
630
    "    #         ticklen= 5,\n",
631
    "    #         zeroline= False,\n",
632
    "    #         gridwidth= 2,\n",
633
    "    #     ),\n",
634
    "        yaxis=dict(\n",
635
    "            title= 'Feature Importance',\n",
636
    "            ticklen= 5,\n",
637
    "            gridwidth= 2\n",
638
    "        ),\n",
639
    "        showlegend= False\n",
640
    "    )\n",
641
    "    fig = go.Figure(data=data, layout=layout)\n",
642
    "    py.iplot(fig,filename='scatter2010')\n",
643
    "\n",
644
    "\n",
645
    "\n",
646
    "    # Scatter plot \n",
647
    "    trace = go.Scatter(\n",
648
    "        y = feature_dataframe['Gradient Boost feature importances'].values,\n",
649
    "        x = feature_dataframe['features'].values,\n",
650
    "        mode='markers',\n",
651
    "        marker=dict(\n",
652
    "            sizemode = 'diameter',\n",
653
    "            sizeref = 1,\n",
654
    "            size = 25,\n",
655
    "    #       size= feature_dataframe['AdaBoost feature importances'].values,\n",
656
    "            #color = np.random.randn(500), #set color equal to a variable\n",
657
    "            color = feature_dataframe['Gradient Boost feature importances'].values,\n",
658
    "            colorscale='Portland',\n",
659
    "            showscale=True\n",
660
    "        ),\n",
661
    "        text = feature_dataframe['features'].values\n",
662
    "    )\n",
663
    "    data = [trace]\n",
664
    "\n",
665
    "    layout= go.Layout(\n",
666
    "        autosize= True,\n",
667
    "        title= 'Gradient Boosting Feature Importance',\n",
668
    "        hovermode= 'closest',\n",
669
    "    #     xaxis= dict(\n",
670
    "    #         title= 'Pop',\n",
671
    "    #         ticklen= 5,\n",
672
    "    #         zeroline= False,\n",
673
    "    #         gridwidth= 2,\n",
674
    "    #     ),\n",
675
    "        yaxis=dict(\n",
676
    "            title= 'Feature Importance',\n",
677
    "            ticklen= 5,\n",
678
    "            gridwidth= 2\n",
679
    "        ),\n",
680
    "        showlegend= False\n",
681
    "    )\n",
682
    "    fig = go.Figure(data=data, layout=layout)\n",
683
    "    py.iplot(fig,filename='scatter2010')\n",
684
    "\n",
685
    "    feature_dataframe['mean'] = feature_dataframe.mean(axis= 1) # axis = 1 computes the mean row-wise\n",
686
    "    feature_dataframe.head(3)\n",
687
    "\n",
688
    "    yv = feature_dataframe['mean'].values\n",
689
    "    x = feature_dataframe['features'].values\n",
690
    "    data = [go.Bar(\n",
691
    "                x= x,\n",
692
    "                y= yv,\n",
693
    "                width = 0.5,\n",
694
    "                marker=dict(\n",
695
    "                   color = feature_dataframe['mean'].values,\n",
696
    "                colorscale='Portland',\n",
697
    "                showscale=True,\n",
698
    "                reversescale = False\n",
699
    "                ),\n",
700
    "                opacity=0.6\n",
701
    "            )]\n",
702
    "\n",
703
    "    layout= go.Layout(\n",
704
    "        autosize= True,\n",
705
    "        title= 'Barplots of Mean Feature Importance',\n",
706
    "        hovermode= 'closest',\n",
707
    "    #     xaxis= dict(\n",
708
    "    #         title= 'Pop',\n",
709
    "    #         ticklen= 5,\n",
710
    "    #         zeroline= False,\n",
711
    "    #         gridwidth= 2,\n",
712
    "    #     ),\n",
713
    "        yaxis=dict(\n",
714
    "            title= 'Feature Importance',\n",
715
    "            ticklen= 5,\n",
716
    "            gridwidth= 2\n",
717
    "        ),\n",
718
    "        showlegend= False\n",
719
    "    )\n",
720
    "    fig = go.Figure(data=data, layout=layout)\n",
721
    "    py.iplot(fig, filename='bar-direct-labels')\n",
722
    "\n",
723
    "\n",
724
    "\n",
725
    "\n",
726
    "    base_predictions_train = pd.DataFrame( {\n",
727
    "     'ExtraTrees': et_oof_train.ravel(),\n",
728
    "     \n",
729
    "     'GradientBoost': gb_oof_train.ravel(),\n",
730
    "     #'LR': lr_oof_train.ravel()\n",
731
    "    })\n",
732
    "    base_predictions_train.head()\n",
733
    "\n",
734
    "    data = [\n",
735
    "    go.Heatmap(\n",
736
    "        z= base_predictions_train.astype(float).corr().values ,\n",
737
    "        x=base_predictions_train.columns.values,\n",
738
    "        y= base_predictions_train.columns.values,\n",
739
    "          colorscale='Viridis',\n",
740
    "            showscale=True,\n",
741
    "            reversescale = True\n",
742
    "        )\n",
743
    "    ]\n",
744
    "    py.iplot(data, filename='labelled-heatmap')\n",
745
    "\n",
746
    "    x_train = np.concatenate(( et_oof_train,gb_oof_train), axis=1)\n",
747
    "    x_test = np.concatenate(( et_oof_test, gb_oof_test), axis=1)\n",
748
    "    \n",
749
    "    gbm = RandomForestClassifier().fit(x_train,y_train_oversampled)\n",
750
    "    y_pred = gbm.predict(x_test)\n",
751
    "    visualizer = ROCAUC(gbm, classes=classes)\n",
752
    "    visualizer.fit(x_train, y_train_oversampled)  # Fit the training data to the visualizer\n",
753
    "    visualizer.score(x_test, y_test)  # Evaluate the model on the test data\n",
754
    "    visualizer.poof(\"Ensembel_{}.pdf\".format(fold), clear_figure=True) \n",
755
    "    print(f'For fold {fold}:')\n",
756
    "    print(f'Accuracy: {gbm.score(x_test, y_test)}')\n",
757
    "    f1=f1_score(y_test, y_pred, average='micro')\n",
758
    "    print(f'f-score: {f1}')\n",
759
    "    print(classification_report_imbalanced(y_test, y_pred))\n",
760
    "    K= classification_report_imbalanced(y_test, y_pred)\n",
761
    "    df = pd.read_fwf(io.StringIO(K))\n",
762
    "    df.loc[\"1\":\"1\",\"pre\":\"sup\"].to_csv(\"RF-Ensemble-D.csv\" , sep=',', encoding='utf-8', doublequote=False, index=False, mode=\"a\", header=False)\n",
763
    "    df.loc[\"2\":\"2\",\"pre\":\"sup\"].to_csv(\"RF-Ensemble-H.csv\" , sep=',', encoding='utf-8', doublequote=False, index=False, mode=\"a\", header=False)\n",
764
    "    df.loc[\"3\":\"3\",\"pre\":\"sup\"].to_csv(\"RF-Ensemble-N.csv\" , sep=',', encoding='utf-8', doublequote=False, index=False, mode=\"a\", header=False)\n",
765
    "    df.loc[\"4\":\"4\",\"pre\":\"sup\"].to_csv(\"RF-Ensemble-R.csv\" , sep=',', encoding='utf-8', doublequote=False, index=False, mode=\"a\", header=False)\n",
766
    "    df.iloc[6:7,:].to_csv(\"RF-Ensemble-avg.csv\" , sep=',', encoding='utf-8', doublequote=False, index=False, mode=\"a\", header=False)\n",
767
    "    \n",
768
    "    "
769
   ],
770
   "outputs": [
771
    {
772
     "output_type": "stream",
773
     "name": "stdout",
774
     "text": [
775
      "[(1, 59596), (2, 59596), (3, 59596), (4, 59596)]\n",
776
      "238384\n",
777
      "Training is complete\n"
778
     ]
779
    },
780
    {
781
     "output_type": "display_data",
782
     "data": {
783
      "application/vnd.plotly.v1+json": {
784
       "config": {
785
        "linkText": "Export to plot.ly",
786
        "plotlyServerURL": "https://plot.ly",
787
        "showLink": false
788
       },
789
       "data": [
790
        {
791
         "marker": {
792
          "color": [
793
           0.0018353646817492182,
794
           0.05084310545549719,
795
           0.09400970408912715,
796
           0.0009886418699209191,
797
           0.10234222172294358,
798
           0.003640032842124243,
799
           0.0013646024310890242,
800
           0.003016195056874061,
801
           0.007971256941994166,
802
           0.004620637010899481,
803
           0.005530885089654668,
804
           0.004322134153054816,
805
           0.019205862429324715,
806
           0.002515465892167688,
807
           0.0029068529574578974,
808
           0.0034366571531583533,
809
           0.007804291207740086,
810
           0.009402396653016296,
811
           0.0018958531833847049,
812
           0.002110420701936828,
813
           0.038700339733758235,
814
           0.03423588600963781,
815
           0.00817997089251627,
816
           0.000002642167259916031,
817
           0.00013126404080853596,
818
           0.000013986071937127094,
819
           0.00034378765813338706,
820
           0.000020677034739334597,
821
           0.0009338911010296967,
822
           0.0001707054178427359,
823
           0.0011383842741308104,
824
           0.0009118602546884352,
825
           0.02020044289867789,
826
           0.006722478106964732,
827
           0.00003362408612181299,
828
           0.010061882271833413,
829
           0.000022615551677283513,
830
           0.0003677843800595879,
831
           0.013704607900350243,
832
           0.007208557871758271,
833
           0.00026973301527727416,
834
           0.008129624547063242,
835
           0.014065248845423622,
836
           0.004248744953256545,
837
           0.06376424950946484,
838
           0.011617612464246977,
839
           0.05976497182742223,
840
           0.0004453574258103735,
841
           0.0005074781663826736,
842
           0.033473028923271225,
843
           0.014834521177518382,
844
           0.00022639718661120363,
845
           0.005806196675825123,
846
           0.021814353144357184,
847
           0.014162892666176269,
848
           0.0010164493656439567,
849
           0.005271419199920207,
850
           0.03845638943926816,
851
           0.021141805218045706,
852
           0.006183774361108017,
853
           0.0032385940401626267,
854
           0.000004525283649994152,
855
           0.0017687513793295886,
856
           0.04464062601841449,
857
           0.002590304435506645,
858
           0.031068104371901287,
859
           0.0031761755250237435,
860
           0.0014848938806685972,
861
           0.00014321109881672463,
862
           0.00017648741137150546,
863
           0.0001727334966912723,
864
           0.002155924445924486,
865
           0.023218428487430897,
866
           0.0022595503546761217,
867
           0.003996836103398738,
868
           0.019780160281208,
869
           0.020686656005668783,
870
           0.0021768086898221904,
871
           0.0020361736675598993,
872
           0.0051595512410654455,
873
           0.018875900987376886,
874
           0.013121385435198118
875
          ],
876
          "colorscale": "Portland",
877
          "showscale": true,
878
          "size": 25,
879
          "sizemode": "diameter",
880
          "sizeref": 1
881
         },
882
         "mode": "markers",
883
         "text": [
884
          "sodium",
885
          "electivesurgery",
886
          "vent",
887
          "dialysis",
888
          "gcs",
889
          "urine",
890
          "wbc",
891
          "temperature",
892
          "respiratoryrate",
893
          "heartrate",
894
          "meanbp",
895
          "creatinine",
896
          "ph",
897
          "hematocrit",
898
          "albumin",
899
          "pao2",
900
          "pco2",
901
          "bun",
902
          "glucose",
903
          "bilirubin",
904
          "fio2",
905
          "age",
906
          "thrombolytics",
907
          "aids",
908
          "hepaticfailure",
909
          "lymphoma",
910
          "metastaticcancer",
911
          "leukemia",
912
          "immunosuppression",
913
          "cirrhosis",
914
          "readmit",
915
          "offset",
916
          "admitsource_1.0",
917
          "admitsource_2.0",
918
          "admitsource_3.0",
919
          "admitsource_4.0",
920
          "admitsource_5.0",
921
          "admitsource_6.0",
922
          "admitsource_7.0",
923
          "admitsource_8.0",
924
          "diaggroup_ARF",
925
          "diaggroup_Asthma-Emphys",
926
          "diaggroup_CABG",
927
          "diaggroup_CHF",
928
          "diaggroup_CVA",
929
          "diaggroup_CVOther",
930
          "diaggroup_CardiacArrest",
931
          "diaggroup_ChestPainUnknown",
932
          "diaggroup_Coma",
933
          "diaggroup_DKA",
934
          "diaggroup_GIBleed",
935
          "diaggroup_GIObstruction",
936
          "diaggroup_Neuro",
937
          "diaggroup_Other",
938
          "diaggroup_Overdose",
939
          "diaggroup_PNA",
940
          "diaggroup_RespMedOther",
941
          "diaggroup_Sepsis",
942
          "diaggroup_Trauma",
943
          "diaggroup_ValveDz",
944
          "gender_Male",
945
          "gender_Other",
946
          "m1_True",
947
          "m2_True",
948
          "m3_True",
949
          "m4_True",
950
          "m5_True",
951
          "m6_True",
952
          "m7_True",
953
          "m8_True",
954
          "m9_True",
955
          "m10_True",
956
          "m11_True",
957
          "m12_True",
958
          "m13_True",
959
          "m14_True",
960
          "m15_True",
961
          "m16_True",
962
          "m17_True",
963
          "m18_True",
964
          "m19_True",
965
          "m20_True"
966
         ],
967
         "type": "scatter",
968
         "uid": "ed896635-15d8-49be-ab7b-626cd70d9f44",
969
         "x": [
970
          "sodium",
971
          "electivesurgery",
972
          "vent",
973
          "dialysis",
974
          "gcs",
975
          "urine",
976
          "wbc",
977
          "temperature",
978
          "respiratoryrate",
979
          "heartrate",
980
          "meanbp",
981
          "creatinine",
982
          "ph",
983
          "hematocrit",
984
          "albumin",
985
          "pao2",
986
          "pco2",
987
          "bun",
988
          "glucose",
989
          "bilirubin",
990
          "fio2",
991
          "age",
992
          "thrombolytics",
993
          "aids",
994
          "hepaticfailure",
995
          "lymphoma",
996
          "metastaticcancer",
997
          "leukemia",
998
          "immunosuppression",
999
          "cirrhosis",
1000
          "readmit",
1001
          "offset",
1002
          "admitsource_1.0",
1003
          "admitsource_2.0",
1004
          "admitsource_3.0",
1005
          "admitsource_4.0",
1006
          "admitsource_5.0",
1007
          "admitsource_6.0",
1008
          "admitsource_7.0",
1009
          "admitsource_8.0",
1010
          "diaggroup_ARF",
1011
          "diaggroup_Asthma-Emphys",
1012
          "diaggroup_CABG",
1013
          "diaggroup_CHF",
1014
          "diaggroup_CVA",
1015
          "diaggroup_CVOther",
1016
          "diaggroup_CardiacArrest",
1017
          "diaggroup_ChestPainUnknown",
1018
          "diaggroup_Coma",
1019
          "diaggroup_DKA",
1020
          "diaggroup_GIBleed",
1021
          "diaggroup_GIObstruction",
1022
          "diaggroup_Neuro",
1023
          "diaggroup_Other",
1024
          "diaggroup_Overdose",
1025
          "diaggroup_PNA",
1026
          "diaggroup_RespMedOther",
1027
          "diaggroup_Sepsis",
1028
          "diaggroup_Trauma",
1029
          "diaggroup_ValveDz",
1030
          "gender_Male",
1031
          "gender_Other",
1032
          "m1_True",
1033
          "m2_True",
1034
          "m3_True",
1035
          "m4_True",
1036
          "m5_True",
1037
          "m6_True",
1038
          "m7_True",
1039
          "m8_True",
1040
          "m9_True",
1041
          "m10_True",
1042
          "m11_True",
1043
          "m12_True",
1044
          "m13_True",
1045
          "m14_True",
1046
          "m15_True",
1047
          "m16_True",
1048
          "m17_True",
1049
          "m18_True",
1050
          "m19_True",
1051
          "m20_True"
1052
         ],
1053
         "y": [
1054
          0.0018353646817492182,
1055
          0.05084310545549719,
1056
          0.09400970408912715,
1057
          0.0009886418699209191,
1058
          0.10234222172294358,
1059
          0.003640032842124243,
1060
          0.0013646024310890242,
1061
          0.003016195056874061,
1062
          0.007971256941994166,
1063
          0.004620637010899481,
1064
          0.005530885089654668,
1065
          0.004322134153054816,
1066
          0.019205862429324715,
1067
          0.002515465892167688,
1068
          0.0029068529574578974,
1069
          0.0034366571531583533,
1070
          0.007804291207740086,
1071
          0.009402396653016296,
1072
          0.0018958531833847049,
1073
          0.002110420701936828,
1074
          0.038700339733758235,
1075
          0.03423588600963781,
1076
          0.00817997089251627,
1077
          0.000002642167259916031,
1078
          0.00013126404080853596,
1079
          0.000013986071937127094,
1080
          0.00034378765813338706,
1081
          0.000020677034739334597,
1082
          0.0009338911010296967,
1083
          0.0001707054178427359,
1084
          0.0011383842741308104,
1085
          0.0009118602546884352,
1086
          0.02020044289867789,
1087
          0.006722478106964732,
1088
          0.00003362408612181299,
1089
          0.010061882271833413,
1090
          0.000022615551677283513,
1091
          0.0003677843800595879,
1092
          0.013704607900350243,
1093
          0.007208557871758271,
1094
          0.00026973301527727416,
1095
          0.008129624547063242,
1096
          0.014065248845423622,
1097
          0.004248744953256545,
1098
          0.06376424950946484,
1099
          0.011617612464246977,
1100
          0.05976497182742223,
1101
          0.0004453574258103735,
1102
          0.0005074781663826736,
1103
          0.033473028923271225,
1104
          0.014834521177518382,
1105
          0.00022639718661120363,
1106
          0.005806196675825123,
1107
          0.021814353144357184,
1108
          0.014162892666176269,
1109
          0.0010164493656439567,
1110
          0.005271419199920207,
1111
          0.03845638943926816,
1112
          0.021141805218045706,
1113
          0.006183774361108017,
1114
          0.0032385940401626267,
1115
          0.000004525283649994152,
1116
          0.0017687513793295886,
1117
          0.04464062601841449,
1118
          0.002590304435506645,
1119
          0.031068104371901287,
1120
          0.0031761755250237435,
1121
          0.0014848938806685972,
1122
          0.00014321109881672463,
1123
          0.00017648741137150546,
1124
          0.0001727334966912723,
1125
          0.002155924445924486,
1126
          0.023218428487430897,
1127
          0.0022595503546761217,
1128
          0.003996836103398738,
1129
          0.019780160281208,
1130
          0.020686656005668783,
1131
          0.0021768086898221904,
1132
          0.0020361736675598993,
1133
          0.0051595512410654455,
1134
          0.018875900987376886,
1135
          0.013121385435198118
1136
         ]
1137
        }
1138
       ],
1139
       "layout": {
1140
        "autosize": true,
1141
        "hovermode": "closest",
1142
        "showlegend": false,
1143
        "title": {
1144
         "text": "Extra Trees Feature Importance"
1145
        },
1146
        "yaxis": {
1147
         "gridwidth": 2,
1148
         "ticklen": 5,
1149
         "title": {
1150
          "text": "Feature Importance"
1151
         }
1152
        }
1153
       }
1154
      },
1155
      "text/html": [
1156
       "<div id=\"724f57ba-d509-454b-999a-e0d2f64c494b\" style=\"height: 525px; width: 100%;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";\n",
1157
       "if (document.getElementById(\"724f57ba-d509-454b-999a-e0d2f64c494b\")) {\n",
1158
       "    Plotly.newPlot(\"724f57ba-d509-454b-999a-e0d2f64c494b\", [{\"marker\": {\"color\": [0.0018353646817492182, 0.05084310545549719, 0.09400970408912715, 0.0009886418699209191, 0.10234222172294358, 0.003640032842124243, 0.0013646024310890242, 0.003016195056874061, 0.007971256941994166, 0.004620637010899481, 0.005530885089654668, 0.004322134153054816, 0.019205862429324715, 0.002515465892167688, 0.0029068529574578974, 0.0034366571531583533, 0.007804291207740086, 0.009402396653016296, 0.0018958531833847049, 0.002110420701936828, 0.038700339733758235, 0.03423588600963781, 0.00817997089251627, 2.642167259916031e-06, 0.00013126404080853596, 1.3986071937127094e-05, 0.00034378765813338706, 2.0677034739334597e-05, 0.0009338911010296967, 0.0001707054178427359, 0.0011383842741308104, 0.0009118602546884352, 0.02020044289867789, 0.006722478106964732, 3.362408612181299e-05, 0.010061882271833413, 2.2615551677283513e-05, 0.0003677843800595879, 0.013704607900350243, 0.007208557871758271, 0.00026973301527727416, 0.008129624547063242, 0.014065248845423622, 0.004248744953256545, 0.06376424950946484, 0.011617612464246977, 0.05976497182742223, 0.0004453574258103735, 0.0005074781663826736, 0.033473028923271225, 0.014834521177518382, 0.00022639718661120363, 0.005806196675825123, 0.021814353144357184, 0.014162892666176269, 0.0010164493656439567, 0.005271419199920207, 0.03845638943926816, 0.021141805218045706, 0.006183774361108017, 0.0032385940401626267, 4.525283649994152e-06, 0.0017687513793295886, 0.04464062601841449, 0.002590304435506645, 0.031068104371901287, 0.0031761755250237435, 0.0014848938806685972, 0.00014321109881672463, 0.00017648741137150546, 0.0001727334966912723, 0.002155924445924486, 0.023218428487430897, 0.0022595503546761217, 0.003996836103398738, 0.019780160281208, 0.020686656005668783, 0.0021768086898221904, 0.0020361736675598993, 0.0051595512410654455, 0.018875900987376886, 0.013121385435198118], \"colorscale\": \"Portland\", \"showscale\": true, \"size\": 25, \"sizemode\": \"diameter\", \"sizeref\": 1}, \"mode\": \"markers\", \"text\": [\"sodium\", \"electivesurgery\", \"vent\", \"dialysis\", \"gcs\", \"urine\", \"wbc\", \"temperature\", \"respiratoryrate\", \"heartrate\", \"meanbp\", \"creatinine\", \"ph\", \"hematocrit\", \"albumin\", \"pao2\", \"pco2\", \"bun\", \"glucose\", \"bilirubin\", \"fio2\", \"age\", \"thrombolytics\", \"aids\", \"hepaticfailure\", \"lymphoma\", \"metastaticcancer\", \"leukemia\", \"immunosuppression\", \"cirrhosis\", \"readmit\", \"offset\", \"admitsource_1.0\", \"admitsource_2.0\", \"admitsource_3.0\", \"admitsource_4.0\", \"admitsource_5.0\", \"admitsource_6.0\", \"admitsource_7.0\", \"admitsource_8.0\", \"diaggroup_ARF\", \"diaggroup_Asthma-Emphys\", \"diaggroup_CABG\", \"diaggroup_CHF\", \"diaggroup_CVA\", \"diaggroup_CVOther\", \"diaggroup_CardiacArrest\", \"diaggroup_ChestPainUnknown\", \"diaggroup_Coma\", \"diaggroup_DKA\", \"diaggroup_GIBleed\", \"diaggroup_GIObstruction\", \"diaggroup_Neuro\", \"diaggroup_Other\", \"diaggroup_Overdose\", \"diaggroup_PNA\", \"diaggroup_RespMedOther\", \"diaggroup_Sepsis\", \"diaggroup_Trauma\", \"diaggroup_ValveDz\", \"gender_Male\", \"gender_Other\", \"m1_True\", \"m2_True\", \"m3_True\", \"m4_True\", \"m5_True\", \"m6_True\", \"m7_True\", \"m8_True\", \"m9_True\", \"m10_True\", \"m11_True\", \"m12_True\", \"m13_True\", \"m14_True\", \"m15_True\", \"m16_True\", \"m17_True\", \"m18_True\", \"m19_True\", \"m20_True\"], \"x\": [\"sodium\", \"electivesurgery\", \"vent\", \"dialysis\", \"gcs\", \"urine\", \"wbc\", \"temperature\", \"respiratoryrate\", \"heartrate\", \"meanbp\", \"creatinine\", \"ph\", \"hematocrit\", \"albumin\", \"pao2\", \"pco2\", \"bun\", \"glucose\", \"bilirubin\", \"fio2\", \"age\", \"thrombolytics\", \"aids\", \"hepaticfailure\", \"lymphoma\", \"metastaticcancer\", \"leukemia\", \"immunosuppression\", \"cirrhosis\", \"readmit\", \"offset\", \"admitsource_1.0\", \"admitsource_2.0\", \"admitsource_3.0\", \"admitsource_4.0\", \"admitsource_5.0\", \"admitsource_6.0\", \"admitsource_7.0\", \"admitsource_8.0\", \"diaggroup_ARF\", \"diaggroup_Asthma-Emphys\", \"diaggroup_CABG\", \"diaggroup_CHF\", \"diaggroup_CVA\", \"diaggroup_CVOther\", \"diaggroup_CardiacArrest\", \"diaggroup_ChestPainUnknown\", \"diaggroup_Coma\", \"diaggroup_DKA\", \"diaggroup_GIBleed\", \"diaggroup_GIObstruction\", \"diaggroup_Neuro\", \"diaggroup_Other\", \"diaggroup_Overdose\", \"diaggroup_PNA\", \"diaggroup_RespMedOther\", \"diaggroup_Sepsis\", \"diaggroup_Trauma\", \"diaggroup_ValveDz\", \"gender_Male\", \"gender_Other\", \"m1_True\", \"m2_True\", \"m3_True\", \"m4_True\", \"m5_True\", \"m6_True\", \"m7_True\", \"m8_True\", \"m9_True\", \"m10_True\", \"m11_True\", \"m12_True\", \"m13_True\", \"m14_True\", \"m15_True\", \"m16_True\", \"m17_True\", \"m18_True\", \"m19_True\", \"m20_True\"], \"y\": [0.0018353646817492182, 0.05084310545549719, 0.09400970408912715, 0.0009886418699209191, 0.10234222172294358, 0.003640032842124243, 0.0013646024310890242, 0.003016195056874061, 0.007971256941994166, 0.004620637010899481, 0.005530885089654668, 0.004322134153054816, 0.019205862429324715, 0.002515465892167688, 0.0029068529574578974, 0.0034366571531583533, 0.007804291207740086, 0.009402396653016296, 0.0018958531833847049, 0.002110420701936828, 0.038700339733758235, 0.03423588600963781, 0.00817997089251627, 2.642167259916031e-06, 0.00013126404080853596, 1.3986071937127094e-05, 0.00034378765813338706, 2.0677034739334597e-05, 0.0009338911010296967, 0.0001707054178427359, 0.0011383842741308104, 0.0009118602546884352, 0.02020044289867789, 0.006722478106964732, 3.362408612181299e-05, 0.010061882271833413, 2.2615551677283513e-05, 0.0003677843800595879, 0.013704607900350243, 0.007208557871758271, 0.00026973301527727416, 0.008129624547063242, 0.014065248845423622, 0.004248744953256545, 0.06376424950946484, 0.011617612464246977, 0.05976497182742223, 0.0004453574258103735, 0.0005074781663826736, 0.033473028923271225, 0.014834521177518382, 0.00022639718661120363, 0.005806196675825123, 0.021814353144357184, 0.014162892666176269, 0.0010164493656439567, 0.005271419199920207, 0.03845638943926816, 0.021141805218045706, 0.006183774361108017, 0.0032385940401626267, 4.525283649994152e-06, 0.0017687513793295886, 0.04464062601841449, 0.002590304435506645, 0.031068104371901287, 0.0031761755250237435, 0.0014848938806685972, 0.00014321109881672463, 0.00017648741137150546, 0.0001727334966912723, 0.002155924445924486, 0.023218428487430897, 0.0022595503546761217, 0.003996836103398738, 0.019780160281208, 0.020686656005668783, 0.0021768086898221904, 0.0020361736675598993, 0.0051595512410654455, 0.018875900987376886, 0.013121385435198118], \"type\": \"scatter\", \"uid\": \"ed896635-15d8-49be-ab7b-626cd70d9f44\"}], {\"autosize\": true, \"hovermode\": \"closest\", \"showlegend\": false, \"title\": {\"text\": \"Extra Trees Feature Importance\"}, \"yaxis\": {\"gridwidth\": 2, \"ticklen\": 5, \"title\": {\"text\": \"Feature Importance\"}}}, {\"showLink\": false, \"linkText\": \"Export to plot.ly\", \"plotlyServerURL\": \"https://plot.ly\"}); \n",
1159
       "}\n",
1160
       "});</script><script type=\"text/javascript\">window.addEventListener(\"resize\", function(){if (document.getElementById(\"724f57ba-d509-454b-999a-e0d2f64c494b\")) {window._Plotly.Plots.resize(document.getElementById(\"724f57ba-d509-454b-999a-e0d2f64c494b\"));};})</script>"
1161
      ],
1162
      "text/vnd.plotly.v1+html": [
1163
       "<div id=\"724f57ba-d509-454b-999a-e0d2f64c494b\" style=\"height: 525px; width: 100%;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";\n",
1164
       "if (document.getElementById(\"724f57ba-d509-454b-999a-e0d2f64c494b\")) {\n",
1165
       "    Plotly.newPlot(\"724f57ba-d509-454b-999a-e0d2f64c494b\", [{\"marker\": {\"color\": [0.0018353646817492182, 0.05084310545549719, 0.09400970408912715, 0.0009886418699209191, 0.10234222172294358, 0.003640032842124243, 0.0013646024310890242, 0.003016195056874061, 0.007971256941994166, 0.004620637010899481, 0.005530885089654668, 0.004322134153054816, 0.019205862429324715, 0.002515465892167688, 0.0029068529574578974, 0.0034366571531583533, 0.007804291207740086, 0.009402396653016296, 0.0018958531833847049, 0.002110420701936828, 0.038700339733758235, 0.03423588600963781, 0.00817997089251627, 2.642167259916031e-06, 0.00013126404080853596, 1.3986071937127094e-05, 0.00034378765813338706, 2.0677034739334597e-05, 0.0009338911010296967, 0.0001707054178427359, 0.0011383842741308104, 0.0009118602546884352, 0.02020044289867789, 0.006722478106964732, 3.362408612181299e-05, 0.010061882271833413, 2.2615551677283513e-05, 0.0003677843800595879, 0.013704607900350243, 0.007208557871758271, 0.00026973301527727416, 0.008129624547063242, 0.014065248845423622, 0.004248744953256545, 0.06376424950946484, 0.011617612464246977, 0.05976497182742223, 0.0004453574258103735, 0.0005074781663826736, 0.033473028923271225, 0.014834521177518382, 0.00022639718661120363, 0.005806196675825123, 0.021814353144357184, 0.014162892666176269, 0.0010164493656439567, 0.005271419199920207, 0.03845638943926816, 0.021141805218045706, 0.006183774361108017, 0.0032385940401626267, 4.525283649994152e-06, 0.0017687513793295886, 0.04464062601841449, 0.002590304435506645, 0.031068104371901287, 0.0031761755250237435, 0.0014848938806685972, 0.00014321109881672463, 0.00017648741137150546, 0.0001727334966912723, 0.002155924445924486, 0.023218428487430897, 0.0022595503546761217, 0.003996836103398738, 0.019780160281208, 0.020686656005668783, 0.0021768086898221904, 0.0020361736675598993, 0.0051595512410654455, 0.018875900987376886, 0.013121385435198118], \"colorscale\": \"Portland\", \"showscale\": true, \"size\": 25, \"sizemode\": \"diameter\", \"sizeref\": 1}, \"mode\": \"markers\", \"text\": [\"sodium\", \"electivesurgery\", \"vent\", \"dialysis\", \"gcs\", \"urine\", \"wbc\", \"temperature\", \"respiratoryrate\", \"heartrate\", \"meanbp\", \"creatinine\", \"ph\", \"hematocrit\", \"albumin\", \"pao2\", \"pco2\", \"bun\", \"glucose\", \"bilirubin\", \"fio2\", \"age\", \"thrombolytics\", \"aids\", \"hepaticfailure\", \"lymphoma\", \"metastaticcancer\", \"leukemia\", \"immunosuppression\", \"cirrhosis\", \"readmit\", \"offset\", \"admitsource_1.0\", \"admitsource_2.0\", \"admitsource_3.0\", \"admitsource_4.0\", \"admitsource_5.0\", \"admitsource_6.0\", \"admitsource_7.0\", \"admitsource_8.0\", \"diaggroup_ARF\", \"diaggroup_Asthma-Emphys\", \"diaggroup_CABG\", \"diaggroup_CHF\", \"diaggroup_CVA\", \"diaggroup_CVOther\", \"diaggroup_CardiacArrest\", \"diaggroup_ChestPainUnknown\", \"diaggroup_Coma\", \"diaggroup_DKA\", \"diaggroup_GIBleed\", \"diaggroup_GIObstruction\", \"diaggroup_Neuro\", \"diaggroup_Other\", \"diaggroup_Overdose\", \"diaggroup_PNA\", \"diaggroup_RespMedOther\", \"diaggroup_Sepsis\", \"diaggroup_Trauma\", \"diaggroup_ValveDz\", \"gender_Male\", \"gender_Other\", \"m1_True\", \"m2_True\", \"m3_True\", \"m4_True\", \"m5_True\", \"m6_True\", \"m7_True\", \"m8_True\", \"m9_True\", \"m10_True\", \"m11_True\", \"m12_True\", \"m13_True\", \"m14_True\", \"m15_True\", \"m16_True\", \"m17_True\", \"m18_True\", \"m19_True\", \"m20_True\"], \"x\": [\"sodium\", \"electivesurgery\", \"vent\", \"dialysis\", \"gcs\", \"urine\", \"wbc\", \"temperature\", \"respiratoryrate\", \"heartrate\", \"meanbp\", \"creatinine\", \"ph\", \"hematocrit\", \"albumin\", \"pao2\", \"pco2\", \"bun\", \"glucose\", \"bilirubin\", \"fio2\", \"age\", \"thrombolytics\", \"aids\", \"hepaticfailure\", \"lymphoma\", \"metastaticcancer\", \"leukemia\", \"immunosuppression\", \"cirrhosis\", \"readmit\", \"offset\", \"admitsource_1.0\", \"admitsource_2.0\", \"admitsource_3.0\", \"admitsource_4.0\", \"admitsource_5.0\", \"admitsource_6.0\", \"admitsource_7.0\", \"admitsource_8.0\", \"diaggroup_ARF\", \"diaggroup_Asthma-Emphys\", \"diaggroup_CABG\", \"diaggroup_CHF\", \"diaggroup_CVA\", \"diaggroup_CVOther\", \"diaggroup_CardiacArrest\", \"diaggroup_ChestPainUnknown\", \"diaggroup_Coma\", \"diaggroup_DKA\", \"diaggroup_GIBleed\", \"diaggroup_GIObstruction\", \"diaggroup_Neuro\", \"diaggroup_Other\", \"diaggroup_Overdose\", \"diaggroup_PNA\", \"diaggroup_RespMedOther\", \"diaggroup_Sepsis\", \"diaggroup_Trauma\", \"diaggroup_ValveDz\", \"gender_Male\", \"gender_Other\", \"m1_True\", \"m2_True\", \"m3_True\", \"m4_True\", \"m5_True\", \"m6_True\", \"m7_True\", \"m8_True\", \"m9_True\", \"m10_True\", \"m11_True\", \"m12_True\", \"m13_True\", \"m14_True\", \"m15_True\", \"m16_True\", \"m17_True\", \"m18_True\", \"m19_True\", \"m20_True\"], \"y\": [0.0018353646817492182, 0.05084310545549719, 0.09400970408912715, 0.0009886418699209191, 0.10234222172294358, 0.003640032842124243, 0.0013646024310890242, 0.003016195056874061, 0.007971256941994166, 0.004620637010899481, 0.005530885089654668, 0.004322134153054816, 0.019205862429324715, 0.002515465892167688, 0.0029068529574578974, 0.0034366571531583533, 0.007804291207740086, 0.009402396653016296, 0.0018958531833847049, 0.002110420701936828, 0.038700339733758235, 0.03423588600963781, 0.00817997089251627, 2.642167259916031e-06, 0.00013126404080853596, 1.3986071937127094e-05, 0.00034378765813338706, 2.0677034739334597e-05, 0.0009338911010296967, 0.0001707054178427359, 0.0011383842741308104, 0.0009118602546884352, 0.02020044289867789, 0.006722478106964732, 3.362408612181299e-05, 0.010061882271833413, 2.2615551677283513e-05, 0.0003677843800595879, 0.013704607900350243, 0.007208557871758271, 0.00026973301527727416, 0.008129624547063242, 0.014065248845423622, 0.004248744953256545, 0.06376424950946484, 0.011617612464246977, 0.05976497182742223, 0.0004453574258103735, 0.0005074781663826736, 0.033473028923271225, 0.014834521177518382, 0.00022639718661120363, 0.005806196675825123, 0.021814353144357184, 0.014162892666176269, 0.0010164493656439567, 0.005271419199920207, 0.03845638943926816, 0.021141805218045706, 0.006183774361108017, 0.0032385940401626267, 4.525283649994152e-06, 0.0017687513793295886, 0.04464062601841449, 0.002590304435506645, 0.031068104371901287, 0.0031761755250237435, 0.0014848938806685972, 0.00014321109881672463, 0.00017648741137150546, 0.0001727334966912723, 0.002155924445924486, 0.023218428487430897, 0.0022595503546761217, 0.003996836103398738, 0.019780160281208, 0.020686656005668783, 0.0021768086898221904, 0.0020361736675598993, 0.0051595512410654455, 0.018875900987376886, 0.013121385435198118], \"type\": \"scatter\", \"uid\": \"ed896635-15d8-49be-ab7b-626cd70d9f44\"}], {\"autosize\": true, \"hovermode\": \"closest\", \"showlegend\": false, \"title\": {\"text\": \"Extra Trees Feature Importance\"}, \"yaxis\": {\"gridwidth\": 2, \"ticklen\": 5, \"title\": {\"text\": \"Feature Importance\"}}}, {\"showLink\": false, \"linkText\": \"Export to plot.ly\", \"plotlyServerURL\": \"https://plot.ly\"}); \n",
1166
       "}\n",
1167
       "});</script><script type=\"text/javascript\">window.addEventListener(\"resize\", function(){if (document.getElementById(\"724f57ba-d509-454b-999a-e0d2f64c494b\")) {window._Plotly.Plots.resize(document.getElementById(\"724f57ba-d509-454b-999a-e0d2f64c494b\"));};})</script>"
1168
      ]
1169
     },
1170
     "metadata": {}
1171
    },
1172
    {
1173
     "output_type": "display_data",
1174
     "data": {
1175
      "application/vnd.plotly.v1+json": {
1176
       "config": {
1177
        "linkText": "Export to plot.ly",
1178
        "plotlyServerURL": "https://plot.ly",
1179
        "showLink": false
1180
       },
1181
       "data": [
1182
        {
1183
         "marker": {
1184
          "color": [
1185
           0.02895100008920424,
1186
           0.01940889181967343,
1187
           0.01713397112196333,
1188
           0.0006888048715839917,
1189
           0.19943724634884952,
1190
           0.02533979514667484,
1191
           0.01876847510296464,
1192
           0.059907484539022726,
1193
           0.03118646710646018,
1194
           0.03090449684447332,
1195
           0.030793189430916895,
1196
           0.02089485838046929,
1197
           0.00879895366559916,
1198
           0.01259603502926633,
1199
           0.014804259064389239,
1200
           0.006116415474074245,
1201
           0.006781288603417748,
1202
           0.04069577405038757,
1203
           0.016778793438278258,
1204
           0.01897283888878102,
1205
           0.01832390108747583,
1206
           0.07812599893362324,
1207
           0.002962254344109083,
1208
           0.000042048554744753824,
1209
           0.0002238103351767069,
1210
           0.00009523997474768742,
1211
           0.0005200448443643561,
1212
           0.00016872489921494353,
1213
           0.0005661422812375212,
1214
           0.0002791824804045882,
1215
           0.0007312175206979133,
1216
           0.04873564675659822,
1217
           0.01634749861630543,
1218
           0.0017569377442036523,
1219
           0.0001913455363586476,
1220
           0.006714635293616546,
1221
           0.00008449044682818052,
1222
           0.00030841006190384545,
1223
           0.0032686970169763445,
1224
           0.005871734202759891,
1225
           0.0019213571600408086,
1226
           0.004536967337591905,
1227
           0.006859050935355847,
1228
           0.005319202569766147,
1229
           0.02782732741683144,
1230
           0.00516748393921808,
1231
           0.021132005357644496,
1232
           0.0011644991203162115,
1233
           0.0027817190845017253,
1234
           0.006112789646132433,
1235
           0.008028640083417802,
1236
           0.0012692347381076123,
1237
           0.005863116227885496,
1238
           0.011362942040987284,
1239
           0.009588107560505321,
1240
           0.003230215272296569,
1241
           0.005562687657783538,
1242
           0.014814582870448472,
1243
           0.013788101856366882,
1244
           0.004404936157351929,
1245
           0.005287599611263047,
1246
           0.00001575200082121126,
1247
           0.00008180812195822928,
1248
           0.008547861985514006,
1249
           0.002768742233742037,
1250
           0.01292689711014233,
1251
           0.0004311241532687182,
1252
           0.00034245906354993526,
1253
           0.0001626202609141136,
1254
           0.00019376841710366558,
1255
           0.00005846849317033116,
1256
           0.0005971032709410448,
1257
           0.000006173066489507722,
1258
           0.0007804211444204773,
1259
           0.0006015691500332959,
1260
           0.000013881165602887428,
1261
           0.00004166988296844418,
1262
           0.00002905911173326329,
1263
           0.001215075633558963,
1264
           0.0014923308590539296,
1265
           0.0000014489417273680594,
1266
           0.009392199341675855
1267
          ],
1268
          "colorscale": "Portland",
1269
          "showscale": true,
1270
          "size": 25,
1271
          "sizemode": "diameter",
1272
          "sizeref": 1
1273
         },
1274
         "mode": "markers",
1275
         "text": [
1276
          "sodium",
1277
          "electivesurgery",
1278
          "vent",
1279
          "dialysis",
1280
          "gcs",
1281
          "urine",
1282
          "wbc",
1283
          "temperature",
1284
          "respiratoryrate",
1285
          "heartrate",
1286
          "meanbp",
1287
          "creatinine",
1288
          "ph",
1289
          "hematocrit",
1290
          "albumin",
1291
          "pao2",
1292
          "pco2",
1293
          "bun",
1294
          "glucose",
1295
          "bilirubin",
1296
          "fio2",
1297
          "age",
1298
          "thrombolytics",
1299
          "aids",
1300
          "hepaticfailure",
1301
          "lymphoma",
1302
          "metastaticcancer",
1303
          "leukemia",
1304
          "immunosuppression",
1305
          "cirrhosis",
1306
          "readmit",
1307
          "offset",
1308
          "admitsource_1.0",
1309
          "admitsource_2.0",
1310
          "admitsource_3.0",
1311
          "admitsource_4.0",
1312
          "admitsource_5.0",
1313
          "admitsource_6.0",
1314
          "admitsource_7.0",
1315
          "admitsource_8.0",
1316
          "diaggroup_ARF",
1317
          "diaggroup_Asthma-Emphys",
1318
          "diaggroup_CABG",
1319
          "diaggroup_CHF",
1320
          "diaggroup_CVA",
1321
          "diaggroup_CVOther",
1322
          "diaggroup_CardiacArrest",
1323
          "diaggroup_ChestPainUnknown",
1324
          "diaggroup_Coma",
1325
          "diaggroup_DKA",
1326
          "diaggroup_GIBleed",
1327
          "diaggroup_GIObstruction",
1328
          "diaggroup_Neuro",
1329
          "diaggroup_Other",
1330
          "diaggroup_Overdose",
1331
          "diaggroup_PNA",
1332
          "diaggroup_RespMedOther",
1333
          "diaggroup_Sepsis",
1334
          "diaggroup_Trauma",
1335
          "diaggroup_ValveDz",
1336
          "gender_Male",
1337
          "gender_Other",
1338
          "m1_True",
1339
          "m2_True",
1340
          "m3_True",
1341
          "m4_True",
1342
          "m5_True",
1343
          "m6_True",
1344
          "m7_True",
1345
          "m8_True",
1346
          "m9_True",
1347
          "m10_True",
1348
          "m11_True",
1349
          "m12_True",
1350
          "m13_True",
1351
          "m14_True",
1352
          "m15_True",
1353
          "m16_True",
1354
          "m17_True",
1355
          "m18_True",
1356
          "m19_True",
1357
          "m20_True"
1358
         ],
1359
         "type": "scatter",
1360
         "uid": "28a65fda-6624-406f-8a1b-7e1dcb9f0d54",
1361
         "x": [
1362
          "sodium",
1363
          "electivesurgery",
1364
          "vent",
1365
          "dialysis",
1366
          "gcs",
1367
          "urine",
1368
          "wbc",
1369
          "temperature",
1370
          "respiratoryrate",
1371
          "heartrate",
1372
          "meanbp",
1373
          "creatinine",
1374
          "ph",
1375
          "hematocrit",
1376
          "albumin",
1377
          "pao2",
1378
          "pco2",
1379
          "bun",
1380
          "glucose",
1381
          "bilirubin",
1382
          "fio2",
1383
          "age",
1384
          "thrombolytics",
1385
          "aids",
1386
          "hepaticfailure",
1387
          "lymphoma",
1388
          "metastaticcancer",
1389
          "leukemia",
1390
          "immunosuppression",
1391
          "cirrhosis",
1392
          "readmit",
1393
          "offset",
1394
          "admitsource_1.0",
1395
          "admitsource_2.0",
1396
          "admitsource_3.0",
1397
          "admitsource_4.0",
1398
          "admitsource_5.0",
1399
          "admitsource_6.0",
1400
          "admitsource_7.0",
1401
          "admitsource_8.0",
1402
          "diaggroup_ARF",
1403
          "diaggroup_Asthma-Emphys",
1404
          "diaggroup_CABG",
1405
          "diaggroup_CHF",
1406
          "diaggroup_CVA",
1407
          "diaggroup_CVOther",
1408
          "diaggroup_CardiacArrest",
1409
          "diaggroup_ChestPainUnknown",
1410
          "diaggroup_Coma",
1411
          "diaggroup_DKA",
1412
          "diaggroup_GIBleed",
1413
          "diaggroup_GIObstruction",
1414
          "diaggroup_Neuro",
1415
          "diaggroup_Other",
1416
          "diaggroup_Overdose",
1417
          "diaggroup_PNA",
1418
          "diaggroup_RespMedOther",
1419
          "diaggroup_Sepsis",
1420
          "diaggroup_Trauma",
1421
          "diaggroup_ValveDz",
1422
          "gender_Male",
1423
          "gender_Other",
1424
          "m1_True",
1425
          "m2_True",
1426
          "m3_True",
1427
          "m4_True",
1428
          "m5_True",
1429
          "m6_True",
1430
          "m7_True",
1431
          "m8_True",
1432
          "m9_True",
1433
          "m10_True",
1434
          "m11_True",
1435
          "m12_True",
1436
          "m13_True",
1437
          "m14_True",
1438
          "m15_True",
1439
          "m16_True",
1440
          "m17_True",
1441
          "m18_True",
1442
          "m19_True",
1443
          "m20_True"
1444
         ],
1445
         "y": [
1446
          0.02895100008920424,
1447
          0.01940889181967343,
1448
          0.01713397112196333,
1449
          0.0006888048715839917,
1450
          0.19943724634884952,
1451
          0.02533979514667484,
1452
          0.01876847510296464,
1453
          0.059907484539022726,
1454
          0.03118646710646018,
1455
          0.03090449684447332,
1456
          0.030793189430916895,
1457
          0.02089485838046929,
1458
          0.00879895366559916,
1459
          0.01259603502926633,
1460
          0.014804259064389239,
1461
          0.006116415474074245,
1462
          0.006781288603417748,
1463
          0.04069577405038757,
1464
          0.016778793438278258,
1465
          0.01897283888878102,
1466
          0.01832390108747583,
1467
          0.07812599893362324,
1468
          0.002962254344109083,
1469
          0.000042048554744753824,
1470
          0.0002238103351767069,
1471
          0.00009523997474768742,
1472
          0.0005200448443643561,
1473
          0.00016872489921494353,
1474
          0.0005661422812375212,
1475
          0.0002791824804045882,
1476
          0.0007312175206979133,
1477
          0.04873564675659822,
1478
          0.01634749861630543,
1479
          0.0017569377442036523,
1480
          0.0001913455363586476,
1481
          0.006714635293616546,
1482
          0.00008449044682818052,
1483
          0.00030841006190384545,
1484
          0.0032686970169763445,
1485
          0.005871734202759891,
1486
          0.0019213571600408086,
1487
          0.004536967337591905,
1488
          0.006859050935355847,
1489
          0.005319202569766147,
1490
          0.02782732741683144,
1491
          0.00516748393921808,
1492
          0.021132005357644496,
1493
          0.0011644991203162115,
1494
          0.0027817190845017253,
1495
          0.006112789646132433,
1496
          0.008028640083417802,
1497
          0.0012692347381076123,
1498
          0.005863116227885496,
1499
          0.011362942040987284,
1500
          0.009588107560505321,
1501
          0.003230215272296569,
1502
          0.005562687657783538,
1503
          0.014814582870448472,
1504
          0.013788101856366882,
1505
          0.004404936157351929,
1506
          0.005287599611263047,
1507
          0.00001575200082121126,
1508
          0.00008180812195822928,
1509
          0.008547861985514006,
1510
          0.002768742233742037,
1511
          0.01292689711014233,
1512
          0.0004311241532687182,
1513
          0.00034245906354993526,
1514
          0.0001626202609141136,
1515
          0.00019376841710366558,
1516
          0.00005846849317033116,
1517
          0.0005971032709410448,
1518
          0.000006173066489507722,
1519
          0.0007804211444204773,
1520
          0.0006015691500332959,
1521
          0.000013881165602887428,
1522
          0.00004166988296844418,
1523
          0.00002905911173326329,
1524
          0.001215075633558963,
1525
          0.0014923308590539296,
1526
          0.0000014489417273680594,
1527
          0.009392199341675855
1528
         ]
1529
        }
1530
       ],
1531
       "layout": {
1532
        "autosize": true,
1533
        "hovermode": "closest",
1534
        "showlegend": false,
1535
        "title": {
1536
         "text": "Gradient Boosting Feature Importance"
1537
        },
1538
        "yaxis": {
1539
         "gridwidth": 2,
1540
         "ticklen": 5,
1541
         "title": {
1542
          "text": "Feature Importance"
1543
         }
1544
        }
1545
       }
1546
      },
1547
      "text/html": [
1548
       "<div id=\"fe9f6910-47e3-46ae-9587-8065966406f2\" style=\"height: 525px; width: 100%;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";\n",
1549
       "if (document.getElementById(\"fe9f6910-47e3-46ae-9587-8065966406f2\")) {\n",
1550
       "    Plotly.newPlot(\"fe9f6910-47e3-46ae-9587-8065966406f2\", [{\"marker\": {\"color\": [0.02895100008920424, 0.01940889181967343, 0.01713397112196333, 0.0006888048715839917, 0.19943724634884952, 0.02533979514667484, 0.01876847510296464, 0.059907484539022726, 0.03118646710646018, 0.03090449684447332, 0.030793189430916895, 0.02089485838046929, 0.00879895366559916, 0.01259603502926633, 0.014804259064389239, 0.006116415474074245, 0.006781288603417748, 0.04069577405038757, 0.016778793438278258, 0.01897283888878102, 0.01832390108747583, 0.07812599893362324, 0.002962254344109083, 4.2048554744753824e-05, 0.0002238103351767069, 9.523997474768742e-05, 0.0005200448443643561, 0.00016872489921494353, 0.0005661422812375212, 0.0002791824804045882, 0.0007312175206979133, 0.04873564675659822, 0.01634749861630543, 0.0017569377442036523, 0.0001913455363586476, 0.006714635293616546, 8.449044682818052e-05, 0.00030841006190384545, 0.0032686970169763445, 0.005871734202759891, 0.0019213571600408086, 0.004536967337591905, 0.006859050935355847, 0.005319202569766147, 0.02782732741683144, 0.00516748393921808, 0.021132005357644496, 0.0011644991203162115, 0.0027817190845017253, 0.006112789646132433, 0.008028640083417802, 0.0012692347381076123, 0.005863116227885496, 0.011362942040987284, 0.009588107560505321, 0.003230215272296569, 0.005562687657783538, 0.014814582870448472, 0.013788101856366882, 0.004404936157351929, 0.005287599611263047, 1.575200082121126e-05, 8.180812195822928e-05, 0.008547861985514006, 0.002768742233742037, 0.01292689711014233, 0.0004311241532687182, 0.00034245906354993526, 0.0001626202609141136, 0.00019376841710366558, 5.846849317033116e-05, 0.0005971032709410448, 6.173066489507722e-06, 0.0007804211444204773, 0.0006015691500332959, 1.3881165602887428e-05, 4.166988296844418e-05, 2.905911173326329e-05, 0.001215075633558963, 0.0014923308590539296, 1.4489417273680594e-06, 0.009392199341675855], \"colorscale\": \"Portland\", \"showscale\": true, \"size\": 25, \"sizemode\": \"diameter\", \"sizeref\": 1}, \"mode\": \"markers\", \"text\": [\"sodium\", \"electivesurgery\", \"vent\", \"dialysis\", \"gcs\", \"urine\", \"wbc\", \"temperature\", \"respiratoryrate\", \"heartrate\", \"meanbp\", \"creatinine\", \"ph\", \"hematocrit\", \"albumin\", \"pao2\", \"pco2\", \"bun\", \"glucose\", \"bilirubin\", \"fio2\", \"age\", \"thrombolytics\", \"aids\", \"hepaticfailure\", \"lymphoma\", \"metastaticcancer\", \"leukemia\", \"immunosuppression\", \"cirrhosis\", \"readmit\", \"offset\", \"admitsource_1.0\", \"admitsource_2.0\", \"admitsource_3.0\", \"admitsource_4.0\", \"admitsource_5.0\", \"admitsource_6.0\", \"admitsource_7.0\", \"admitsource_8.0\", \"diaggroup_ARF\", \"diaggroup_Asthma-Emphys\", \"diaggroup_CABG\", \"diaggroup_CHF\", \"diaggroup_CVA\", \"diaggroup_CVOther\", \"diaggroup_CardiacArrest\", \"diaggroup_ChestPainUnknown\", \"diaggroup_Coma\", \"diaggroup_DKA\", \"diaggroup_GIBleed\", \"diaggroup_GIObstruction\", \"diaggroup_Neuro\", \"diaggroup_Other\", \"diaggroup_Overdose\", \"diaggroup_PNA\", \"diaggroup_RespMedOther\", \"diaggroup_Sepsis\", \"diaggroup_Trauma\", \"diaggroup_ValveDz\", \"gender_Male\", \"gender_Other\", \"m1_True\", \"m2_True\", \"m3_True\", \"m4_True\", \"m5_True\", \"m6_True\", \"m7_True\", \"m8_True\", \"m9_True\", \"m10_True\", \"m11_True\", \"m12_True\", \"m13_True\", \"m14_True\", \"m15_True\", \"m16_True\", \"m17_True\", \"m18_True\", \"m19_True\", \"m20_True\"], \"x\": [\"sodium\", \"electivesurgery\", \"vent\", \"dialysis\", \"gcs\", \"urine\", \"wbc\", \"temperature\", \"respiratoryrate\", \"heartrate\", \"meanbp\", \"creatinine\", \"ph\", \"hematocrit\", \"albumin\", \"pao2\", \"pco2\", \"bun\", \"glucose\", \"bilirubin\", \"fio2\", \"age\", \"thrombolytics\", \"aids\", \"hepaticfailure\", \"lymphoma\", \"metastaticcancer\", \"leukemia\", \"immunosuppression\", \"cirrhosis\", \"readmit\", \"offset\", \"admitsource_1.0\", \"admitsource_2.0\", \"admitsource_3.0\", \"admitsource_4.0\", \"admitsource_5.0\", \"admitsource_6.0\", \"admitsource_7.0\", \"admitsource_8.0\", \"diaggroup_ARF\", \"diaggroup_Asthma-Emphys\", \"diaggroup_CABG\", \"diaggroup_CHF\", \"diaggroup_CVA\", \"diaggroup_CVOther\", \"diaggroup_CardiacArrest\", \"diaggroup_ChestPainUnknown\", \"diaggroup_Coma\", \"diaggroup_DKA\", \"diaggroup_GIBleed\", \"diaggroup_GIObstruction\", \"diaggroup_Neuro\", \"diaggroup_Other\", \"diaggroup_Overdose\", \"diaggroup_PNA\", \"diaggroup_RespMedOther\", \"diaggroup_Sepsis\", \"diaggroup_Trauma\", \"diaggroup_ValveDz\", \"gender_Male\", \"gender_Other\", \"m1_True\", \"m2_True\", \"m3_True\", \"m4_True\", \"m5_True\", \"m6_True\", \"m7_True\", \"m8_True\", \"m9_True\", \"m10_True\", \"m11_True\", \"m12_True\", \"m13_True\", \"m14_True\", \"m15_True\", \"m16_True\", \"m17_True\", \"m18_True\", \"m19_True\", \"m20_True\"], \"y\": [0.02895100008920424, 0.01940889181967343, 0.01713397112196333, 0.0006888048715839917, 0.19943724634884952, 0.02533979514667484, 0.01876847510296464, 0.059907484539022726, 0.03118646710646018, 0.03090449684447332, 0.030793189430916895, 0.02089485838046929, 0.00879895366559916, 0.01259603502926633, 0.014804259064389239, 0.006116415474074245, 0.006781288603417748, 0.04069577405038757, 0.016778793438278258, 0.01897283888878102, 0.01832390108747583, 0.07812599893362324, 0.002962254344109083, 4.2048554744753824e-05, 0.0002238103351767069, 9.523997474768742e-05, 0.0005200448443643561, 0.00016872489921494353, 0.0005661422812375212, 0.0002791824804045882, 0.0007312175206979133, 0.04873564675659822, 0.01634749861630543, 0.0017569377442036523, 0.0001913455363586476, 0.006714635293616546, 8.449044682818052e-05, 0.00030841006190384545, 0.0032686970169763445, 0.005871734202759891, 0.0019213571600408086, 0.004536967337591905, 0.006859050935355847, 0.005319202569766147, 0.02782732741683144, 0.00516748393921808, 0.021132005357644496, 0.0011644991203162115, 0.0027817190845017253, 0.006112789646132433, 0.008028640083417802, 0.0012692347381076123, 0.005863116227885496, 0.011362942040987284, 0.009588107560505321, 0.003230215272296569, 0.005562687657783538, 0.014814582870448472, 0.013788101856366882, 0.004404936157351929, 0.005287599611263047, 1.575200082121126e-05, 8.180812195822928e-05, 0.008547861985514006, 0.002768742233742037, 0.01292689711014233, 0.0004311241532687182, 0.00034245906354993526, 0.0001626202609141136, 0.00019376841710366558, 5.846849317033116e-05, 0.0005971032709410448, 6.173066489507722e-06, 0.0007804211444204773, 0.0006015691500332959, 1.3881165602887428e-05, 4.166988296844418e-05, 2.905911173326329e-05, 0.001215075633558963, 0.0014923308590539296, 1.4489417273680594e-06, 0.009392199341675855], \"type\": \"scatter\", \"uid\": \"28a65fda-6624-406f-8a1b-7e1dcb9f0d54\"}], {\"autosize\": true, \"hovermode\": \"closest\", \"showlegend\": false, \"title\": {\"text\": \"Gradient Boosting Feature Importance\"}, \"yaxis\": {\"gridwidth\": 2, \"ticklen\": 5, \"title\": {\"text\": \"Feature Importance\"}}}, {\"showLink\": false, \"linkText\": \"Export to plot.ly\", \"plotlyServerURL\": \"https://plot.ly\"}); \n",
1551
       "}\n",
1552
       "});</script><script type=\"text/javascript\">window.addEventListener(\"resize\", function(){if (document.getElementById(\"fe9f6910-47e3-46ae-9587-8065966406f2\")) {window._Plotly.Plots.resize(document.getElementById(\"fe9f6910-47e3-46ae-9587-8065966406f2\"));};})</script>"
1553
      ],
1554
      "text/vnd.plotly.v1+html": [
1555
       "<div id=\"fe9f6910-47e3-46ae-9587-8065966406f2\" style=\"height: 525px; width: 100%;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";\n",
1556
       "if (document.getElementById(\"fe9f6910-47e3-46ae-9587-8065966406f2\")) {\n",
1557
       "    Plotly.newPlot(\"fe9f6910-47e3-46ae-9587-8065966406f2\", [{\"marker\": {\"color\": [0.02895100008920424, 0.01940889181967343, 0.01713397112196333, 0.0006888048715839917, 0.19943724634884952, 0.02533979514667484, 0.01876847510296464, 0.059907484539022726, 0.03118646710646018, 0.03090449684447332, 0.030793189430916895, 0.02089485838046929, 0.00879895366559916, 0.01259603502926633, 0.014804259064389239, 0.006116415474074245, 0.006781288603417748, 0.04069577405038757, 0.016778793438278258, 0.01897283888878102, 0.01832390108747583, 0.07812599893362324, 0.002962254344109083, 4.2048554744753824e-05, 0.0002238103351767069, 9.523997474768742e-05, 0.0005200448443643561, 0.00016872489921494353, 0.0005661422812375212, 0.0002791824804045882, 0.0007312175206979133, 0.04873564675659822, 0.01634749861630543, 0.0017569377442036523, 0.0001913455363586476, 0.006714635293616546, 8.449044682818052e-05, 0.00030841006190384545, 0.0032686970169763445, 0.005871734202759891, 0.0019213571600408086, 0.004536967337591905, 0.006859050935355847, 0.005319202569766147, 0.02782732741683144, 0.00516748393921808, 0.021132005357644496, 0.0011644991203162115, 0.0027817190845017253, 0.006112789646132433, 0.008028640083417802, 0.0012692347381076123, 0.005863116227885496, 0.011362942040987284, 0.009588107560505321, 0.003230215272296569, 0.005562687657783538, 0.014814582870448472, 0.013788101856366882, 0.004404936157351929, 0.005287599611263047, 1.575200082121126e-05, 8.180812195822928e-05, 0.008547861985514006, 0.002768742233742037, 0.01292689711014233, 0.0004311241532687182, 0.00034245906354993526, 0.0001626202609141136, 0.00019376841710366558, 5.846849317033116e-05, 0.0005971032709410448, 6.173066489507722e-06, 0.0007804211444204773, 0.0006015691500332959, 1.3881165602887428e-05, 4.166988296844418e-05, 2.905911173326329e-05, 0.001215075633558963, 0.0014923308590539296, 1.4489417273680594e-06, 0.009392199341675855], \"colorscale\": \"Portland\", \"showscale\": true, \"size\": 25, \"sizemode\": \"diameter\", \"sizeref\": 1}, \"mode\": \"markers\", \"text\": [\"sodium\", \"electivesurgery\", \"vent\", \"dialysis\", \"gcs\", \"urine\", \"wbc\", \"temperature\", \"respiratoryrate\", \"heartrate\", \"meanbp\", \"creatinine\", \"ph\", \"hematocrit\", \"albumin\", \"pao2\", \"pco2\", \"bun\", \"glucose\", \"bilirubin\", \"fio2\", \"age\", \"thrombolytics\", \"aids\", \"hepaticfailure\", \"lymphoma\", \"metastaticcancer\", \"leukemia\", \"immunosuppression\", \"cirrhosis\", \"readmit\", \"offset\", \"admitsource_1.0\", \"admitsource_2.0\", \"admitsource_3.0\", \"admitsource_4.0\", \"admitsource_5.0\", \"admitsource_6.0\", \"admitsource_7.0\", \"admitsource_8.0\", \"diaggroup_ARF\", \"diaggroup_Asthma-Emphys\", \"diaggroup_CABG\", \"diaggroup_CHF\", \"diaggroup_CVA\", \"diaggroup_CVOther\", \"diaggroup_CardiacArrest\", \"diaggroup_ChestPainUnknown\", \"diaggroup_Coma\", \"diaggroup_DKA\", \"diaggroup_GIBleed\", \"diaggroup_GIObstruction\", \"diaggroup_Neuro\", \"diaggroup_Other\", \"diaggroup_Overdose\", \"diaggroup_PNA\", \"diaggroup_RespMedOther\", \"diaggroup_Sepsis\", \"diaggroup_Trauma\", \"diaggroup_ValveDz\", \"gender_Male\", \"gender_Other\", \"m1_True\", \"m2_True\", \"m3_True\", \"m4_True\", \"m5_True\", \"m6_True\", \"m7_True\", \"m8_True\", \"m9_True\", \"m10_True\", \"m11_True\", \"m12_True\", \"m13_True\", \"m14_True\", \"m15_True\", \"m16_True\", \"m17_True\", \"m18_True\", \"m19_True\", \"m20_True\"], \"x\": [\"sodium\", \"electivesurgery\", \"vent\", \"dialysis\", \"gcs\", \"urine\", \"wbc\", \"temperature\", \"respiratoryrate\", \"heartrate\", \"meanbp\", \"creatinine\", \"ph\", \"hematocrit\", \"albumin\", \"pao2\", \"pco2\", \"bun\", \"glucose\", \"bilirubin\", \"fio2\", \"age\", \"thrombolytics\", \"aids\", \"hepaticfailure\", \"lymphoma\", \"metastaticcancer\", \"leukemia\", \"immunosuppression\", \"cirrhosis\", \"readmit\", \"offset\", \"admitsource_1.0\", \"admitsource_2.0\", \"admitsource_3.0\", \"admitsource_4.0\", \"admitsource_5.0\", \"admitsource_6.0\", \"admitsource_7.0\", \"admitsource_8.0\", \"diaggroup_ARF\", \"diaggroup_Asthma-Emphys\", \"diaggroup_CABG\", \"diaggroup_CHF\", \"diaggroup_CVA\", \"diaggroup_CVOther\", \"diaggroup_CardiacArrest\", \"diaggroup_ChestPainUnknown\", \"diaggroup_Coma\", \"diaggroup_DKA\", \"diaggroup_GIBleed\", \"diaggroup_GIObstruction\", \"diaggroup_Neuro\", \"diaggroup_Other\", \"diaggroup_Overdose\", \"diaggroup_PNA\", \"diaggroup_RespMedOther\", \"diaggroup_Sepsis\", \"diaggroup_Trauma\", \"diaggroup_ValveDz\", \"gender_Male\", \"gender_Other\", \"m1_True\", \"m2_True\", \"m3_True\", \"m4_True\", \"m5_True\", \"m6_True\", \"m7_True\", \"m8_True\", \"m9_True\", \"m10_True\", \"m11_True\", \"m12_True\", \"m13_True\", \"m14_True\", \"m15_True\", \"m16_True\", \"m17_True\", \"m18_True\", \"m19_True\", \"m20_True\"], \"y\": [0.02895100008920424, 0.01940889181967343, 0.01713397112196333, 0.0006888048715839917, 0.19943724634884952, 0.02533979514667484, 0.01876847510296464, 0.059907484539022726, 0.03118646710646018, 0.03090449684447332, 0.030793189430916895, 0.02089485838046929, 0.00879895366559916, 0.01259603502926633, 0.014804259064389239, 0.006116415474074245, 0.006781288603417748, 0.04069577405038757, 0.016778793438278258, 0.01897283888878102, 0.01832390108747583, 0.07812599893362324, 0.002962254344109083, 4.2048554744753824e-05, 0.0002238103351767069, 9.523997474768742e-05, 0.0005200448443643561, 0.00016872489921494353, 0.0005661422812375212, 0.0002791824804045882, 0.0007312175206979133, 0.04873564675659822, 0.01634749861630543, 0.0017569377442036523, 0.0001913455363586476, 0.006714635293616546, 8.449044682818052e-05, 0.00030841006190384545, 0.0032686970169763445, 0.005871734202759891, 0.0019213571600408086, 0.004536967337591905, 0.006859050935355847, 0.005319202569766147, 0.02782732741683144, 0.00516748393921808, 0.021132005357644496, 0.0011644991203162115, 0.0027817190845017253, 0.006112789646132433, 0.008028640083417802, 0.0012692347381076123, 0.005863116227885496, 0.011362942040987284, 0.009588107560505321, 0.003230215272296569, 0.005562687657783538, 0.014814582870448472, 0.013788101856366882, 0.004404936157351929, 0.005287599611263047, 1.575200082121126e-05, 8.180812195822928e-05, 0.008547861985514006, 0.002768742233742037, 0.01292689711014233, 0.0004311241532687182, 0.00034245906354993526, 0.0001626202609141136, 0.00019376841710366558, 5.846849317033116e-05, 0.0005971032709410448, 6.173066489507722e-06, 0.0007804211444204773, 0.0006015691500332959, 1.3881165602887428e-05, 4.166988296844418e-05, 2.905911173326329e-05, 0.001215075633558963, 0.0014923308590539296, 1.4489417273680594e-06, 0.009392199341675855], \"type\": \"scatter\", \"uid\": \"28a65fda-6624-406f-8a1b-7e1dcb9f0d54\"}], {\"autosize\": true, \"hovermode\": \"closest\", \"showlegend\": false, \"title\": {\"text\": \"Gradient Boosting Feature Importance\"}, \"yaxis\": {\"gridwidth\": 2, \"ticklen\": 5, \"title\": {\"text\": \"Feature Importance\"}}}, {\"showLink\": false, \"linkText\": \"Export to plot.ly\", \"plotlyServerURL\": \"https://plot.ly\"}); \n",
1558
       "}\n",
1559
       "});</script><script type=\"text/javascript\">window.addEventListener(\"resize\", function(){if (document.getElementById(\"fe9f6910-47e3-46ae-9587-8065966406f2\")) {window._Plotly.Plots.resize(document.getElementById(\"fe9f6910-47e3-46ae-9587-8065966406f2\"));};})</script>"
1560
      ]
1561
     },
1562
     "metadata": {}
1563
    },
1564
    {
1565
     "output_type": "display_data",
1566
     "data": {
1567
      "application/vnd.plotly.v1+json": {
1568
       "config": {
1569
        "linkText": "Export to plot.ly",
1570
        "plotlyServerURL": "https://plot.ly",
1571
        "showLink": false
1572
       },
1573
       "data": [
1574
        {
1575
         "marker": {
1576
          "color": [
1577
           0.015393182385476729,
1578
           0.03512599863758531,
1579
           0.05557183760554524,
1580
           0.0008387233707524554,
1581
           0.15088973403589656,
1582
           0.014489913994399542,
1583
           0.010066538767026833,
1584
           0.03146183979794839,
1585
           0.01957886202422717,
1586
           0.0177625669276864,
1587
           0.01816203726028578,
1588
           0.012608496266762054,
1589
           0.014002408047461938,
1590
           0.007555750460717009,
1591
           0.008855556010923568,
1592
           0.004776536313616299,
1593
           0.007292789905578917,
1594
           0.025049085351701934,
1595
           0.009337323310831482,
1596
           0.010541629795358925,
1597
           0.028512120410617032,
1598
           0.056180942471630524,
1599
           0.005571112618312676,
1600
           0.00002234536100233493,
1601
           0.00017753718799262143,
1602
           0.00005461302334240726,
1603
           0.0004319162512488716,
1604
           0.00009470096697713907,
1605
           0.0007500166911336089,
1606
           0.00022494394912366203,
1607
           0.0009348008974143619,
1608
           0.02482375350564333,
1609
           0.01827397075749166,
1610
           0.004239707925584192,
1611
           0.0001124848112402303,
1612
           0.00838825878272498,
1613
           0.00005355299925273202,
1614
           0.00033809722098171663,
1615
           0.008486652458663294,
1616
           0.006540146037259081,
1617
           0.0010955450876590413,
1618
           0.006333295942327574,
1619
           0.010462149890389735,
1620
           0.004783973761511346,
1621
           0.04579578846314814,
1622
           0.008392548201732528,
1623
           0.04044848859253336,
1624
           0.0008049282730632925,
1625
           0.0016445986254421995,
1626
           0.01979290928470183,
1627
           0.011431580630468091,
1628
           0.000747815962359408,
1629
           0.005834656451855309,
1630
           0.016588647592672236,
1631
           0.011875500113340796,
1632
           0.002123332318970263,
1633
           0.005417053428851872,
1634
           0.026635486154858314,
1635
           0.017464953537206295,
1636
           0.005294355259229973,
1637
           0.004263096825712837,
1638
           0.000010138642235602707,
1639
           0.000925279750643909,
1640
           0.026594244001964248,
1641
           0.002679523334624341,
1642
           0.02199750074102181,
1643
           0.0018036498391462309,
1644
           0.0009136764721092663,
1645
           0.0001529156798654191,
1646
           0.00018512791423758553,
1647
           0.00011560099493080172,
1648
           0.0013765138584327654,
1649
           0.011612300776960202,
1650
           0.0015199857495482995,
1651
           0.002299202626716017,
1652
           0.009897020723405443,
1653
           0.010364162944318613,
1654
           0.0011029339007777269,
1655
           0.0016256246505594312,
1656
           0.0033259410500596875,
1657
           0.009438674964552127,
1658
           0.011256792388436986
1659
          ],
1660
          "colorscale": "Portland",
1661
          "reversescale": false,
1662
          "showscale": true
1663
         },
1664
         "opacity": 0.6,
1665
         "type": "bar",
1666
         "uid": "3aadb222-91ce-4d34-ae5b-f5b2e1bd2098",
1667
         "width": 0.5,
1668
         "x": [
1669
          "sodium",
1670
          "electivesurgery",
1671
          "vent",
1672
          "dialysis",
1673
          "gcs",
1674
          "urine",
1675
          "wbc",
1676
          "temperature",
1677
          "respiratoryrate",
1678
          "heartrate",
1679
          "meanbp",
1680
          "creatinine",
1681
          "ph",
1682
          "hematocrit",
1683
          "albumin",
1684
          "pao2",
1685
          "pco2",
1686
          "bun",
1687
          "glucose",
1688
          "bilirubin",
1689
          "fio2",
1690
          "age",
1691
          "thrombolytics",
1692
          "aids",
1693
          "hepaticfailure",
1694
          "lymphoma",
1695
          "metastaticcancer",
1696
          "leukemia",
1697
          "immunosuppression",
1698
          "cirrhosis",
1699
          "readmit",
1700
          "offset",
1701
          "admitsource_1.0",
1702
          "admitsource_2.0",
1703
          "admitsource_3.0",
1704
          "admitsource_4.0",
1705
          "admitsource_5.0",
1706
          "admitsource_6.0",
1707
          "admitsource_7.0",
1708
          "admitsource_8.0",
1709
          "diaggroup_ARF",
1710
          "diaggroup_Asthma-Emphys",
1711
          "diaggroup_CABG",
1712
          "diaggroup_CHF",
1713
          "diaggroup_CVA",
1714
          "diaggroup_CVOther",
1715
          "diaggroup_CardiacArrest",
1716
          "diaggroup_ChestPainUnknown",
1717
          "diaggroup_Coma",
1718
          "diaggroup_DKA",
1719
          "diaggroup_GIBleed",
1720
          "diaggroup_GIObstruction",
1721
          "diaggroup_Neuro",
1722
          "diaggroup_Other",
1723
          "diaggroup_Overdose",
1724
          "diaggroup_PNA",
1725
          "diaggroup_RespMedOther",
1726
          "diaggroup_Sepsis",
1727
          "diaggroup_Trauma",
1728
          "diaggroup_ValveDz",
1729
          "gender_Male",
1730
          "gender_Other",
1731
          "m1_True",
1732
          "m2_True",
1733
          "m3_True",
1734
          "m4_True",
1735
          "m5_True",
1736
          "m6_True",
1737
          "m7_True",
1738
          "m8_True",
1739
          "m9_True",
1740
          "m10_True",
1741
          "m11_True",
1742
          "m12_True",
1743
          "m13_True",
1744
          "m14_True",
1745
          "m15_True",
1746
          "m16_True",
1747
          "m17_True",
1748
          "m18_True",
1749
          "m19_True",
1750
          "m20_True"
1751
         ],
1752
         "y": [
1753
          0.015393182385476729,
1754
          0.03512599863758531,
1755
          0.05557183760554524,
1756
          0.0008387233707524554,
1757
          0.15088973403589656,
1758
          0.014489913994399542,
1759
          0.010066538767026833,
1760
          0.03146183979794839,
1761
          0.01957886202422717,
1762
          0.0177625669276864,
1763
          0.01816203726028578,
1764
          0.012608496266762054,
1765
          0.014002408047461938,
1766
          0.007555750460717009,
1767
          0.008855556010923568,
1768
          0.004776536313616299,
1769
          0.007292789905578917,
1770
          0.025049085351701934,
1771
          0.009337323310831482,
1772
          0.010541629795358925,
1773
          0.028512120410617032,
1774
          0.056180942471630524,
1775
          0.005571112618312676,
1776
          0.00002234536100233493,
1777
          0.00017753718799262143,
1778
          0.00005461302334240726,
1779
          0.0004319162512488716,
1780
          0.00009470096697713907,
1781
          0.0007500166911336089,
1782
          0.00022494394912366203,
1783
          0.0009348008974143619,
1784
          0.02482375350564333,
1785
          0.01827397075749166,
1786
          0.004239707925584192,
1787
          0.0001124848112402303,
1788
          0.00838825878272498,
1789
          0.00005355299925273202,
1790
          0.00033809722098171663,
1791
          0.008486652458663294,
1792
          0.006540146037259081,
1793
          0.0010955450876590413,
1794
          0.006333295942327574,
1795
          0.010462149890389735,
1796
          0.004783973761511346,
1797
          0.04579578846314814,
1798
          0.008392548201732528,
1799
          0.04044848859253336,
1800
          0.0008049282730632925,
1801
          0.0016445986254421995,
1802
          0.01979290928470183,
1803
          0.011431580630468091,
1804
          0.000747815962359408,
1805
          0.005834656451855309,
1806
          0.016588647592672236,
1807
          0.011875500113340796,
1808
          0.002123332318970263,
1809
          0.005417053428851872,
1810
          0.026635486154858314,
1811
          0.017464953537206295,
1812
          0.005294355259229973,
1813
          0.004263096825712837,
1814
          0.000010138642235602707,
1815
          0.000925279750643909,
1816
          0.026594244001964248,
1817
          0.002679523334624341,
1818
          0.02199750074102181,
1819
          0.0018036498391462309,
1820
          0.0009136764721092663,
1821
          0.0001529156798654191,
1822
          0.00018512791423758553,
1823
          0.00011560099493080172,
1824
          0.0013765138584327654,
1825
          0.011612300776960202,
1826
          0.0015199857495482995,
1827
          0.002299202626716017,
1828
          0.009897020723405443,
1829
          0.010364162944318613,
1830
          0.0011029339007777269,
1831
          0.0016256246505594312,
1832
          0.0033259410500596875,
1833
          0.009438674964552127,
1834
          0.011256792388436986
1835
         ]
1836
        }
1837
       ],
1838
       "layout": {
1839
        "autosize": true,
1840
        "hovermode": "closest",
1841
        "showlegend": false,
1842
        "title": {
1843
         "text": "Barplots of Mean Feature Importance"
1844
        },
1845
        "yaxis": {
1846
         "gridwidth": 2,
1847
         "ticklen": 5,
1848
         "title": {
1849
          "text": "Feature Importance"
1850
         }
1851
        }
1852
       }
1853
      },
1854
      "text/html": [
1855
       "<div id=\"36dd33b7-f855-4704-8faf-1fe58ba1203c\" style=\"height: 525px; width: 100%;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";\n",
1856
       "if (document.getElementById(\"36dd33b7-f855-4704-8faf-1fe58ba1203c\")) {\n",
1857
       "    Plotly.newPlot(\"36dd33b7-f855-4704-8faf-1fe58ba1203c\", [{\"marker\": {\"color\": [0.015393182385476729, 0.03512599863758531, 0.05557183760554524, 0.0008387233707524554, 0.15088973403589656, 0.014489913994399542, 0.010066538767026833, 0.03146183979794839, 0.01957886202422717, 0.0177625669276864, 0.01816203726028578, 0.012608496266762054, 0.014002408047461938, 0.007555750460717009, 0.008855556010923568, 0.004776536313616299, 0.007292789905578917, 0.025049085351701934, 0.009337323310831482, 0.010541629795358925, 0.028512120410617032, 0.056180942471630524, 0.005571112618312676, 2.234536100233493e-05, 0.00017753718799262143, 5.461302334240726e-05, 0.0004319162512488716, 9.470096697713907e-05, 0.0007500166911336089, 0.00022494394912366203, 0.0009348008974143619, 0.02482375350564333, 0.01827397075749166, 0.004239707925584192, 0.0001124848112402303, 0.00838825878272498, 5.355299925273202e-05, 0.00033809722098171663, 0.008486652458663294, 0.006540146037259081, 0.0010955450876590413, 0.006333295942327574, 0.010462149890389735, 0.004783973761511346, 0.04579578846314814, 0.008392548201732528, 0.04044848859253336, 0.0008049282730632925, 0.0016445986254421995, 0.01979290928470183, 0.011431580630468091, 0.000747815962359408, 0.005834656451855309, 0.016588647592672236, 0.011875500113340796, 0.002123332318970263, 0.005417053428851872, 0.026635486154858314, 0.017464953537206295, 0.005294355259229973, 0.004263096825712837, 1.0138642235602707e-05, 0.000925279750643909, 0.026594244001964248, 0.002679523334624341, 0.02199750074102181, 0.0018036498391462309, 0.0009136764721092663, 0.0001529156798654191, 0.00018512791423758553, 0.00011560099493080172, 0.0013765138584327654, 0.011612300776960202, 0.0015199857495482995, 0.002299202626716017, 0.009897020723405443, 0.010364162944318613, 0.0011029339007777269, 0.0016256246505594312, 0.0033259410500596875, 0.009438674964552127, 0.011256792388436986], \"colorscale\": \"Portland\", \"reversescale\": false, \"showscale\": true}, \"opacity\": 0.6, \"width\": 0.5, \"x\": [\"sodium\", \"electivesurgery\", \"vent\", \"dialysis\", \"gcs\", \"urine\", \"wbc\", \"temperature\", \"respiratoryrate\", \"heartrate\", \"meanbp\", \"creatinine\", \"ph\", \"hematocrit\", \"albumin\", \"pao2\", \"pco2\", \"bun\", \"glucose\", \"bilirubin\", \"fio2\", \"age\", \"thrombolytics\", \"aids\", \"hepaticfailure\", \"lymphoma\", \"metastaticcancer\", \"leukemia\", \"immunosuppression\", \"cirrhosis\", \"readmit\", \"offset\", \"admitsource_1.0\", \"admitsource_2.0\", \"admitsource_3.0\", \"admitsource_4.0\", \"admitsource_5.0\", \"admitsource_6.0\", \"admitsource_7.0\", \"admitsource_8.0\", \"diaggroup_ARF\", \"diaggroup_Asthma-Emphys\", \"diaggroup_CABG\", \"diaggroup_CHF\", \"diaggroup_CVA\", \"diaggroup_CVOther\", \"diaggroup_CardiacArrest\", \"diaggroup_ChestPainUnknown\", \"diaggroup_Coma\", \"diaggroup_DKA\", \"diaggroup_GIBleed\", \"diaggroup_GIObstruction\", \"diaggroup_Neuro\", \"diaggroup_Other\", \"diaggroup_Overdose\", \"diaggroup_PNA\", \"diaggroup_RespMedOther\", \"diaggroup_Sepsis\", \"diaggroup_Trauma\", \"diaggroup_ValveDz\", \"gender_Male\", \"gender_Other\", \"m1_True\", \"m2_True\", \"m3_True\", \"m4_True\", \"m5_True\", \"m6_True\", \"m7_True\", \"m8_True\", \"m9_True\", \"m10_True\", \"m11_True\", \"m12_True\", \"m13_True\", \"m14_True\", \"m15_True\", \"m16_True\", \"m17_True\", \"m18_True\", \"m19_True\", \"m20_True\"], \"y\": [0.015393182385476729, 0.03512599863758531, 0.05557183760554524, 0.0008387233707524554, 0.15088973403589656, 0.014489913994399542, 0.010066538767026833, 0.03146183979794839, 0.01957886202422717, 0.0177625669276864, 0.01816203726028578, 0.012608496266762054, 0.014002408047461938, 0.007555750460717009, 0.008855556010923568, 0.004776536313616299, 0.007292789905578917, 0.025049085351701934, 0.009337323310831482, 0.010541629795358925, 0.028512120410617032, 0.056180942471630524, 0.005571112618312676, 2.234536100233493e-05, 0.00017753718799262143, 5.461302334240726e-05, 0.0004319162512488716, 9.470096697713907e-05, 0.0007500166911336089, 0.00022494394912366203, 0.0009348008974143619, 0.02482375350564333, 0.01827397075749166, 0.004239707925584192, 0.0001124848112402303, 0.00838825878272498, 5.355299925273202e-05, 0.00033809722098171663, 0.008486652458663294, 0.006540146037259081, 0.0010955450876590413, 0.006333295942327574, 0.010462149890389735, 0.004783973761511346, 0.04579578846314814, 0.008392548201732528, 0.04044848859253336, 0.0008049282730632925, 0.0016445986254421995, 0.01979290928470183, 0.011431580630468091, 0.000747815962359408, 0.005834656451855309, 0.016588647592672236, 0.011875500113340796, 0.002123332318970263, 0.005417053428851872, 0.026635486154858314, 0.017464953537206295, 0.005294355259229973, 0.004263096825712837, 1.0138642235602707e-05, 0.000925279750643909, 0.026594244001964248, 0.002679523334624341, 0.02199750074102181, 0.0018036498391462309, 0.0009136764721092663, 0.0001529156798654191, 0.00018512791423758553, 0.00011560099493080172, 0.0013765138584327654, 0.011612300776960202, 0.0015199857495482995, 0.002299202626716017, 0.009897020723405443, 0.010364162944318613, 0.0011029339007777269, 0.0016256246505594312, 0.0033259410500596875, 0.009438674964552127, 0.011256792388436986], \"type\": \"bar\", \"uid\": \"3aadb222-91ce-4d34-ae5b-f5b2e1bd2098\"}], {\"autosize\": true, \"hovermode\": \"closest\", \"showlegend\": false, \"title\": {\"text\": \"Barplots of Mean Feature Importance\"}, \"yaxis\": {\"gridwidth\": 2, \"ticklen\": 5, \"title\": {\"text\": \"Feature Importance\"}}}, {\"showLink\": false, \"linkText\": \"Export to plot.ly\", \"plotlyServerURL\": \"https://plot.ly\"}); \n",
1858
       "}\n",
1859
       "});</script><script type=\"text/javascript\">window.addEventListener(\"resize\", function(){if (document.getElementById(\"36dd33b7-f855-4704-8faf-1fe58ba1203c\")) {window._Plotly.Plots.resize(document.getElementById(\"36dd33b7-f855-4704-8faf-1fe58ba1203c\"));};})</script>"
1860
      ],
1861
      "text/vnd.plotly.v1+html": [
1862
       "<div id=\"36dd33b7-f855-4704-8faf-1fe58ba1203c\" style=\"height: 525px; width: 100%;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";\n",
1863
       "if (document.getElementById(\"36dd33b7-f855-4704-8faf-1fe58ba1203c\")) {\n",
1864
       "    Plotly.newPlot(\"36dd33b7-f855-4704-8faf-1fe58ba1203c\", [{\"marker\": {\"color\": [0.015393182385476729, 0.03512599863758531, 0.05557183760554524, 0.0008387233707524554, 0.15088973403589656, 0.014489913994399542, 0.010066538767026833, 0.03146183979794839, 0.01957886202422717, 0.0177625669276864, 0.01816203726028578, 0.012608496266762054, 0.014002408047461938, 0.007555750460717009, 0.008855556010923568, 0.004776536313616299, 0.007292789905578917, 0.025049085351701934, 0.009337323310831482, 0.010541629795358925, 0.028512120410617032, 0.056180942471630524, 0.005571112618312676, 2.234536100233493e-05, 0.00017753718799262143, 5.461302334240726e-05, 0.0004319162512488716, 9.470096697713907e-05, 0.0007500166911336089, 0.00022494394912366203, 0.0009348008974143619, 0.02482375350564333, 0.01827397075749166, 0.004239707925584192, 0.0001124848112402303, 0.00838825878272498, 5.355299925273202e-05, 0.00033809722098171663, 0.008486652458663294, 0.006540146037259081, 0.0010955450876590413, 0.006333295942327574, 0.010462149890389735, 0.004783973761511346, 0.04579578846314814, 0.008392548201732528, 0.04044848859253336, 0.0008049282730632925, 0.0016445986254421995, 0.01979290928470183, 0.011431580630468091, 0.000747815962359408, 0.005834656451855309, 0.016588647592672236, 0.011875500113340796, 0.002123332318970263, 0.005417053428851872, 0.026635486154858314, 0.017464953537206295, 0.005294355259229973, 0.004263096825712837, 1.0138642235602707e-05, 0.000925279750643909, 0.026594244001964248, 0.002679523334624341, 0.02199750074102181, 0.0018036498391462309, 0.0009136764721092663, 0.0001529156798654191, 0.00018512791423758553, 0.00011560099493080172, 0.0013765138584327654, 0.011612300776960202, 0.0015199857495482995, 0.002299202626716017, 0.009897020723405443, 0.010364162944318613, 0.0011029339007777269, 0.0016256246505594312, 0.0033259410500596875, 0.009438674964552127, 0.011256792388436986], \"colorscale\": \"Portland\", \"reversescale\": false, \"showscale\": true}, \"opacity\": 0.6, \"width\": 0.5, \"x\": [\"sodium\", \"electivesurgery\", \"vent\", \"dialysis\", \"gcs\", \"urine\", \"wbc\", \"temperature\", \"respiratoryrate\", \"heartrate\", \"meanbp\", \"creatinine\", \"ph\", \"hematocrit\", \"albumin\", \"pao2\", \"pco2\", \"bun\", \"glucose\", \"bilirubin\", \"fio2\", \"age\", \"thrombolytics\", \"aids\", \"hepaticfailure\", \"lymphoma\", \"metastaticcancer\", \"leukemia\", \"immunosuppression\", \"cirrhosis\", \"readmit\", \"offset\", \"admitsource_1.0\", \"admitsource_2.0\", \"admitsource_3.0\", \"admitsource_4.0\", \"admitsource_5.0\", \"admitsource_6.0\", \"admitsource_7.0\", \"admitsource_8.0\", \"diaggroup_ARF\", \"diaggroup_Asthma-Emphys\", \"diaggroup_CABG\", \"diaggroup_CHF\", \"diaggroup_CVA\", \"diaggroup_CVOther\", \"diaggroup_CardiacArrest\", \"diaggroup_ChestPainUnknown\", \"diaggroup_Coma\", \"diaggroup_DKA\", \"diaggroup_GIBleed\", \"diaggroup_GIObstruction\", \"diaggroup_Neuro\", \"diaggroup_Other\", \"diaggroup_Overdose\", \"diaggroup_PNA\", \"diaggroup_RespMedOther\", \"diaggroup_Sepsis\", \"diaggroup_Trauma\", \"diaggroup_ValveDz\", \"gender_Male\", \"gender_Other\", \"m1_True\", \"m2_True\", \"m3_True\", \"m4_True\", \"m5_True\", \"m6_True\", \"m7_True\", \"m8_True\", \"m9_True\", \"m10_True\", \"m11_True\", \"m12_True\", \"m13_True\", \"m14_True\", \"m15_True\", \"m16_True\", \"m17_True\", \"m18_True\", \"m19_True\", \"m20_True\"], \"y\": [0.015393182385476729, 0.03512599863758531, 0.05557183760554524, 0.0008387233707524554, 0.15088973403589656, 0.014489913994399542, 0.010066538767026833, 0.03146183979794839, 0.01957886202422717, 0.0177625669276864, 0.01816203726028578, 0.012608496266762054, 0.014002408047461938, 0.007555750460717009, 0.008855556010923568, 0.004776536313616299, 0.007292789905578917, 0.025049085351701934, 0.009337323310831482, 0.010541629795358925, 0.028512120410617032, 0.056180942471630524, 0.005571112618312676, 2.234536100233493e-05, 0.00017753718799262143, 5.461302334240726e-05, 0.0004319162512488716, 9.470096697713907e-05, 0.0007500166911336089, 0.00022494394912366203, 0.0009348008974143619, 0.02482375350564333, 0.01827397075749166, 0.004239707925584192, 0.0001124848112402303, 0.00838825878272498, 5.355299925273202e-05, 0.00033809722098171663, 0.008486652458663294, 0.006540146037259081, 0.0010955450876590413, 0.006333295942327574, 0.010462149890389735, 0.004783973761511346, 0.04579578846314814, 0.008392548201732528, 0.04044848859253336, 0.0008049282730632925, 0.0016445986254421995, 0.01979290928470183, 0.011431580630468091, 0.000747815962359408, 0.005834656451855309, 0.016588647592672236, 0.011875500113340796, 0.002123332318970263, 0.005417053428851872, 0.026635486154858314, 0.017464953537206295, 0.005294355259229973, 0.004263096825712837, 1.0138642235602707e-05, 0.000925279750643909, 0.026594244001964248, 0.002679523334624341, 0.02199750074102181, 0.0018036498391462309, 0.0009136764721092663, 0.0001529156798654191, 0.00018512791423758553, 0.00011560099493080172, 0.0013765138584327654, 0.011612300776960202, 0.0015199857495482995, 0.002299202626716017, 0.009897020723405443, 0.010364162944318613, 0.0011029339007777269, 0.0016256246505594312, 0.0033259410500596875, 0.009438674964552127, 0.011256792388436986], \"type\": \"bar\", \"uid\": \"3aadb222-91ce-4d34-ae5b-f5b2e1bd2098\"}], {\"autosize\": true, \"hovermode\": \"closest\", \"showlegend\": false, \"title\": {\"text\": \"Barplots of Mean Feature Importance\"}, \"yaxis\": {\"gridwidth\": 2, \"ticklen\": 5, \"title\": {\"text\": \"Feature Importance\"}}}, {\"showLink\": false, \"linkText\": \"Export to plot.ly\", \"plotlyServerURL\": \"https://plot.ly\"}); \n",
1865
       "}\n",
1866
       "});</script><script type=\"text/javascript\">window.addEventListener(\"resize\", function(){if (document.getElementById(\"36dd33b7-f855-4704-8faf-1fe58ba1203c\")) {window._Plotly.Plots.resize(document.getElementById(\"36dd33b7-f855-4704-8faf-1fe58ba1203c\"));};})</script>"
1867
      ]
1868
     },
1869
     "metadata": {}
1870
    },
1871
    {
1872
     "output_type": "display_data",
1873
     "data": {
1874
      "application/vnd.plotly.v1+json": {
1875
       "config": {
1876
        "linkText": "Export to plot.ly",
1877
        "plotlyServerURL": "https://plot.ly",
1878
        "showLink": false
1879
       },
1880
       "data": [
1881
        {
1882
         "colorscale": "Viridis",
1883
         "reversescale": true,
1884
         "showscale": true,
1885
         "type": "heatmap",
1886
         "uid": "ca5a2a9a-2059-4187-a451-d643a7f5d4b9",
1887
         "x": [
1888
          "ExtraTrees",
1889
          "GradientBoost"
1890
         ],
1891
         "y": [
1892
          "ExtraTrees",
1893
          "GradientBoost"
1894
         ],
1895
         "z": [
1896
          [
1897
           1,
1898
           0.45313604730131996
1899
          ],
1900
          [
1901
           0.45313604730131996,
1902
           1
1903
          ]
1904
         ]
1905
        }
1906
       ],
1907
       "layout": {}
1908
      },
1909
      "text/html": [
1910
       "<div id=\"91f9ef4a-5fc9-4db8-ad82-9683e4fc14b7\" style=\"height: 525px; width: 100%;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";\n",
1911
       "if (document.getElementById(\"91f9ef4a-5fc9-4db8-ad82-9683e4fc14b7\")) {\n",
1912
       "    Plotly.newPlot(\"91f9ef4a-5fc9-4db8-ad82-9683e4fc14b7\", [{\"colorscale\": \"Viridis\", \"reversescale\": true, \"showscale\": true, \"x\": [\"ExtraTrees\", \"GradientBoost\"], \"y\": [\"ExtraTrees\", \"GradientBoost\"], \"z\": [[1.0, 0.45313604730131996], [0.45313604730131996, 1.0]], \"type\": \"heatmap\", \"uid\": \"0e643610-bd18-4b5d-b400-2f772e0de6bc\"}], {}, {\"showLink\": false, \"linkText\": \"Export to plot.ly\", \"plotlyServerURL\": \"https://plot.ly\"}); \n",
1913
       "}\n",
1914
       "});</script><script type=\"text/javascript\">window.addEventListener(\"resize\", function(){if (document.getElementById(\"91f9ef4a-5fc9-4db8-ad82-9683e4fc14b7\")) {window._Plotly.Plots.resize(document.getElementById(\"91f9ef4a-5fc9-4db8-ad82-9683e4fc14b7\"));};})</script>"
1915
      ],
1916
      "text/vnd.plotly.v1+html": [
1917
       "<div id=\"91f9ef4a-5fc9-4db8-ad82-9683e4fc14b7\" style=\"height: 525px; width: 100%;\" class=\"plotly-graph-div\"></div><script type=\"text/javascript\">require([\"plotly\"], function(Plotly) { window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL=\"https://plot.ly\";\n",
1918
       "if (document.getElementById(\"91f9ef4a-5fc9-4db8-ad82-9683e4fc14b7\")) {\n",
1919
       "    Plotly.newPlot(\"91f9ef4a-5fc9-4db8-ad82-9683e4fc14b7\", [{\"colorscale\": \"Viridis\", \"reversescale\": true, \"showscale\": true, \"x\": [\"ExtraTrees\", \"GradientBoost\"], \"y\": [\"ExtraTrees\", \"GradientBoost\"], \"z\": [[1.0, 0.45313604730131996], [0.45313604730131996, 1.0]], \"type\": \"heatmap\", \"uid\": \"0e643610-bd18-4b5d-b400-2f772e0de6bc\"}], {}, {\"showLink\": false, \"linkText\": \"Export to plot.ly\", \"plotlyServerURL\": \"https://plot.ly\"}); \n",
1920
       "}\n",
1921
       "});</script><script type=\"text/javascript\">window.addEventListener(\"resize\", function(){if (document.getElementById(\"91f9ef4a-5fc9-4db8-ad82-9683e4fc14b7\")) {window._Plotly.Plots.resize(document.getElementById(\"91f9ef4a-5fc9-4db8-ad82-9683e4fc14b7\"));};})</script>"
1922
      ]
1923
     },
1924
     "metadata": {}
1925
    },
1926
    {
1927
     "output_type": "stream",
1928
     "name": "stdout",
1929
     "text": [
1930
      "For fold 1:\n",
1931
      "Accuracy: 0.7351828499369483\n",
1932
      "f-score: 0.7351828499369484\n"
1933
     ]
1934
    },
1935
    {
1936
     "output_type": "error",
1937
     "ename": "NameError",
1938
     "evalue": "name 'classification_report_imbalanced' is not defined",
1939
     "traceback": [
1940
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
1941
      "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
1942
      "\u001b[1;32m<ipython-input-12-5ccabd3c0e33>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m    269\u001b[0m     \u001b[0mf1\u001b[0m\u001b[1;33m=\u001b[0m\u001b[0mf1_score\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0my_test\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0my_pred\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0maverage\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m'micro'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    270\u001b[0m     \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;34mf'f-score: {f1}'\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 271\u001b[1;33m     \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mclassification_report_imbalanced\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0my_test\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0my_pred\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    272\u001b[0m     \u001b[0mK\u001b[0m\u001b[1;33m=\u001b[0m \u001b[0mclassification_report_imbalanced\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0my_test\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0my_pred\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    273\u001b[0m     \u001b[0mdf\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mpd\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mread_fwf\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mio\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mStringIO\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mK\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
1943
      "\u001b[1;31mNameError\u001b[0m: name 'classification_report_imbalanced' is not defined"
1944
     ]
1945
    },
1946
    {
1947
     "output_type": "display_data",
1948
     "data": {
1949
      "text/plain": [
1950
       "<Figure size 576x396 with 0 Axes>"
1951
      ]
1952
     },
1953
     "metadata": {}
1954
    }
1955
   ],
1956
   "metadata": {}
1957
  },
1958
  {
1959
   "cell_type": "code",
1960
   "execution_count": null,
1961
   "source": [
1962
    "len(y_test)"
1963
   ],
1964
   "outputs": [],
1965
   "metadata": {}
1966
  },
1967
  {
1968
   "cell_type": "code",
1969
   "execution_count": null,
1970
   "source": [
1971
    "list(map(abs,lr_features))"
1972
   ],
1973
   "outputs": [],
1974
   "metadata": {}
1975
  },
1976
  {
1977
   "cell_type": "code",
1978
   "execution_count": null,
1979
   "source": [
1980
    "visualizer\n"
1981
   ],
1982
   "outputs": [],
1983
   "metadata": {}
1984
  },
1985
  {
1986
   "cell_type": "code",
1987
   "execution_count": null,
1988
   "source": [
1989
    "fig.write_image(\"images/fig1.png\")"
1990
   ],
1991
   "outputs": [],
1992
   "metadata": {}
1993
  },
1994
  {
1995
   "cell_type": "code",
1996
   "execution_count": null,
1997
   "source": [
1998
    "#lr_fit= lr.fit(X_train_oversampled, y_train_oversampled).tolist()\n",
1999
    "lr_features = lr_fit.coef_\n",
2000
    "len(list(lr_features.flat))"
2001
   ],
2002
   "outputs": [],
2003
   "metadata": {}
2004
  },
2005
  {
2006
   "cell_type": "code",
2007
   "execution_count": null,
2008
   "source": [
2009
    "  \n",
2010
    "    \n",
2011
    "    model = AdaBoostClassifier() \n",
2012
    "    model.fit(X_train_oversampled, y_train_oversampled)  \n",
2013
    "    y_pred = model.predict(X_test.values)\n",
2014
    "    visualizer = ROCAUC(model, classes=classes)\n",
2015
    "    visualizer.fit(X_train_oversampled, y_train_oversampled)  # Fit the training data to the visualizer\n",
2016
    "    visualizer.score(X_test.values, y_test)  # Evaluate the model on the test data\n",
2017
    "    visualizer.poof(\"Ada_Indicator_Replace_{}.pdf\".format(fold), clear_figure=True) \n",
2018
    "    print(f'For fold {fold}:')\n",
2019
    "    print(f'Accuracy: {model.score(X_test.values, y_test)}')\n",
2020
    "    f1=f1_score(y_test, y_pred, average='micro')\n",
2021
    "    print(f'f-score: {f1}')\n",
2022
    "    print(classification_report_imbalanced(y_test, y_pred))\n",
2023
    "    \n",
2024
    "    #\n",
2025
    "\n",
2026
    "    "
2027
   ],
2028
   "outputs": [],
2029
   "metadata": {}
2030
  },
2031
  {
2032
   "cell_type": "code",
2033
   "execution_count": null,
2034
   "source": [
2035
    " feature_dataframe['mean'] = feature_dataframe.mean(axis= 1) # axis = 1 computes the mean row-wise\n",
2036
    "    feature_dataframe.head(3)\n",
2037
    "    \n",
2038
    "    y = feature_dataframe['mean'].values\n",
2039
    "    x = feature_dataframe['features'].values\n",
2040
    "    data = [go.Bar(\n",
2041
    "                x= x,\n",
2042
    "                 y= y,\n",
2043
    "                width = 0.5,\n",
2044
    "                marker=dict(\n",
2045
    "                   color = feature_dataframe['mean'].values,\n",
2046
    "                colorscale='Portland',\n",
2047
    "                showscale=True,\n",
2048
    "                reversescale = False\n",
2049
    "                ),\n",
2050
    "                opacity=0.6\n",
2051
    "            )]\n",
2052
    "\n",
2053
    "    layout= go.Layout(\n",
2054
    "        autosize= True,\n",
2055
    "        title= 'Barplots of Mean Feature Importance',\n",
2056
    "        hovermode= 'closest',\n",
2057
    "    #     xaxis= dict(\n",
2058
    "    #         title= 'Pop',\n",
2059
    "    #         ticklen= 5,\n",
2060
    "    #         zeroline= False,\n",
2061
    "    #         gridwidth= 2,\n",
2062
    "    #     ),\n",
2063
    "        yaxis=dict(\n",
2064
    "            title= 'Feature Importance',\n",
2065
    "            ticklen= 5,\n",
2066
    "            gridwidth= 2\n",
2067
    "        ),\n",
2068
    "        showlegend= False\n",
2069
    "    )\n",
2070
    "    fig = go.Figure(data=data, layout=layout)\n",
2071
    "    py.iplot(fig, filename='bar-direct-labels')\n",
2072
    "    \n",
2073
    "    base_predictions_train = pd.DataFrame( {\n",
2074
    "     'ExtraTrees': et_oof_train.ravel(),\n",
2075
    "     'GradientBoost': gb_oof_train.ravel()\n",
2076
    "    })\n",
2077
    "    base_predictions_train.head()\n",
2078
    "    \n",
2079
    "    data = [\n",
2080
    "    go.Heatmap(\n",
2081
    "        z= base_predictions_train.astype(float).corr().values ,\n",
2082
    "        x=base_predictions_train.columns.values,\n",
2083
    "        y= base_predictions_train.columns.values,\n",
2084
    "          colorscale='Viridis',\n",
2085
    "            showscale=True,\n",
2086
    "            reversescale = True\n",
2087
    "    )\n",
2088
    "    ]\n",
2089
    "    py.iplot(data, filename='labelled-heatmap')\n",
2090
    "    \n",
2091
    "    #-------------------------------------------------------------------------------------\n",
2092
    "    x_train = np.concatenate(( et_oof_train, rf_oof_train, ada_oof_train, gb_oof_train, lr_oof_train), axis=1)\n",
2093
    "    x_test = np.concatenate(( et_oof_test, rf_oof_test, ada_oof_test, gb_oof_test, lr_oof_test), axis=1)\n",
2094
    "    \n",
2095
    "    gbm = xgb.XGBClassifier(\n",
2096
    "    #learning_rate = 0.02,\n",
2097
    "     n_estimators= 2000,\n",
2098
    "     max_depth= 4,\n",
2099
    "     min_child_weight= 2,\n",
2100
    "     #gamma=1,\n",
2101
    "     gamma=0.9,                        \n",
2102
    "     subsample=0.8,\n",
2103
    "     colsample_bytree=0.8,\n",
2104
    "     objective= 'binary:logistic',\n",
2105
    "     nthread= -1,\n",
2106
    "     scale_pos_weight=1).fit(x_train, y_train_oversampled)\n",
2107
    "    predictions = gbm.predict(x_test)\n",
2108
    "    "
2109
   ],
2110
   "outputs": [],
2111
   "metadata": {}
2112
  },
2113
  {
2114
   "cell_type": "code",
2115
   "execution_count": null,
2116
   "source": [
2117
    "len(lr_features)"
2118
   ],
2119
   "outputs": [],
2120
   "metadata": {}
2121
  },
2122
  {
2123
   "cell_type": "code",
2124
   "execution_count": null,
2125
   "source": [
2126
    "cols = df2.drop('destcopy', 1).columns.values"
2127
   ],
2128
   "outputs": [],
2129
   "metadata": {}
2130
  },
2131
  {
2132
   "cell_type": "code",
2133
   "execution_count": null,
2134
   "source": [
2135
    "import plotly.graph_objects as go"
2136
   ],
2137
   "outputs": [],
2138
   "metadata": {}
2139
  },
2140
  {
2141
   "cell_type": "code",
2142
   "execution_count": null,
2143
   "source": [
2144
    "fig.show()"
2145
   ],
2146
   "outputs": [],
2147
   "metadata": {}
2148
  },
2149
  {
2150
   "cell_type": "code",
2151
   "execution_count": null,
2152
   "source": [
2153
    "import numpy as np    \n",
2154
    "from sklearn.linear_model import LogisticRegression\n",
2155
    "from sklearn.preprocessing import StandardScaler\n",
2156
    "import pandas as pd\n",
2157
    "import matplotlib.pyplot as plt\n",
2158
    "\n",
2159
    "x1 = np.random.randn(100)\n",
2160
    "x2 = np.random.randn(100)\n",
2161
    "x3 = np.random.randn(100)\n",
2162
    "\n",
2163
    "#Make difference in feature dependance\n",
2164
    "y = (3 + x1 + 2*x2 + 5*x3 + 0.2*np.random.randn()) > 0\n",
2165
    "\n",
2166
    "X = pd.DataFrame({'x1':x1,'x2':x2,'x3':x3})\n",
2167
    "\n",
2168
    "#Scale your data\n",
2169
    "scaler = StandardScaler()\n",
2170
    "scaler.fit(X) \n",
2171
    "X_scaled = pd.DataFrame(scaler.transform(X),columns = X.columns)\n",
2172
    "\n",
2173
    "clf = LogisticRegression(random_state = 0)\n",
2174
    "clf.fit(X_scaled, y)\n",
2175
    "\n",
2176
    "feature_importance = abs(clf.coef_[0])\n",
2177
    "feature_importance = 100.0 * (feature_importance / feature_importance.max())\n",
2178
    "sorted_idx = np.argsort(feature_importance)\n",
2179
    "pos = np.arange(sorted_idx.shape[0]) + .5\n",
2180
    "\n",
2181
    "featfig = plt.figure()\n",
2182
    "featax = featfig.add_subplot(1, 1, 1)\n",
2183
    "featax.barh(pos, feature_importance[sorted_idx], align='center')\n",
2184
    "featax.set_yticks(pos)\n",
2185
    "featax.set_yticklabels(np.array(X.columns)[sorted_idx], fontsize=8)\n",
2186
    "featax.set_xlabel('Relative Feature Importance')\n",
2187
    "\n",
2188
    "plt.tight_layout()   \n",
2189
    "plt.show()"
2190
   ],
2191
   "outputs": [],
2192
   "metadata": {}
2193
  },
2194
  {
2195
   "cell_type": "code",
2196
   "execution_count": null,
2197
   "source": [
2198
    "feature_importance"
2199
   ],
2200
   "outputs": [],
2201
   "metadata": {}
2202
  },
2203
  {
2204
   "cell_type": "code",
2205
   "execution_count": null,
2206
   "source": [],
2207
   "outputs": [],
2208
   "metadata": {}
2209
  }
2210
 ],
2211
 "metadata": {
2212
  "kernelspec": {
2213
   "display_name": "Python 3",
2214
   "language": "python",
2215
   "name": "python3"
2216
  },
2217
  "language_info": {
2218
   "codemirror_mode": {
2219
    "name": "ipython",
2220
    "version": 3
2221
   },
2222
   "file_extension": ".py",
2223
   "mimetype": "text/x-python",
2224
   "name": "python",
2225
   "nbconvert_exporter": "python",
2226
   "pygments_lexer": "ipython3",
2227
   "version": "3.8.3"
2228
  }
2229
 },
2230
 "nbformat": 4,
2231
 "nbformat_minor": 4
2232
}