NLP_Project_Code.ipynb 16.8 KB
Newer Older
Zaid A Ali's avatar
Zaid A Ali committed
1
2
3
4
5
6
{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
7
    "For this project, our goal is create an NLP model to automatically assign ICD-9 encodings, given the clinical notes for each encounter)."
8
9
   ]
  },
Zaid A Ali's avatar
Zaid A Ali committed
10
11
12
13
14
15
16
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Imports"
   ]
  },
17
18
  {
   "cell_type": "code",
19
   "execution_count": 10,
20
   "metadata": {},
21
22
23
24
25
26
27
28
29
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "All modules imported successfully\n"
     ]
    }
   ],
30
31
32
   "source": [
    "#imports\n",
    "import pandas as pd\n",
33
34
35
36
37
38
39
40
    "from sklearn.feature_extraction.text import TfidfVectorizer\n",
    "from sklearn.naive_bayes import MultinomialNB\n",
    "from sklearn.linear_model import LogisticRegression\n",
    "from sklearn.ensemble import RandomForestClassifier\n",
    "from sklearn.svm import LinearSVC\n",
    "from sklearn.model_selection import cross_val_score\n",
    "from sklearn.model_selection import train_test_split\n",
    "from sklearn.metrics import confusion_matrix\n",
41
42
    "import warnings\n",
    "warnings.filterwarnings('ignore')\n",
43
44
    "\n",
    "\n",
45
46
47
    "print(\"All modules imported successfully\")"
   ]
  },
Zaid A Ali's avatar
Zaid A Ali committed
48
49
50
51
52
53
54
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Fetching Data from File in order to prepare it for processing"
   ]
  },
55
56
  {
   "cell_type": "code",
57
   "execution_count": 2,
58
   "metadata": {},
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Fetching data\n",
      "Done fetching all the data\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>TEXT</th>\n",
       "      <th>ICD9_CODE</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Admission Date:  [**2141-9-18**]              ...</td>\n",
       "      <td>40301</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>PATIENT/TEST INFORMATION:\\nIndication: Pericar...</td>\n",
       "      <td>40301</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Sinus rhythm\\nRightward axis\\nSince previous t...</td>\n",
       "      <td>40301</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Chief Complaint:  hypotension, altered mental ...</td>\n",
       "      <td>40301</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Chief Complaint:  hypotension, altered mental ...</td>\n",
       "      <td>40301</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                TEXT ICD9_CODE\n",
       "0  Admission Date:  [**2141-9-18**]              ...     40301\n",
       "1  PATIENT/TEST INFORMATION:\\nIndication: Pericar...     40301\n",
       "2  Sinus rhythm\\nRightward axis\\nSince previous t...     40301\n",
       "3  Chief Complaint:  hypotension, altered mental ...     40301\n",
       "4  Chief Complaint:  hypotension, altered mental ...     40301"
      ]
     },
132
     "execution_count": 2,
133
134
135
136
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
137
   "source": [
138
139
    "print(\"Fetching data\")\n",
    "\"\"\"\n",
140
    "#This code is to import data from the MIMIC-III files.\n",
141
    "\n",
142
    "#For performance reasons, this code has been commented out\n",
143
    "\n",
144
    "diagnoses = pd.read_csv(\"DIAGNOSES_ICD.csv\")\n",
145
    "note_events = pd.read_csv(\"NOTEEVENTS.csv\", engine=\"python\", on_bad_lines='skip')\n",
146
    "full_dataset = pd.merge(diagnoses, note_events, on =[\"HADM_ID\", \"SUBJECT_ID\"])\n",
147
148
    "full_dataset = full_dataset[:40000]\n",
    "\n",
149
150
151
    "print(full_dataset.head())\n",
    "full_dataset.to_csv(\"ICDdata40k.csv\")\n",
    "\n",
152
153
154
155
156
157
    "\"\"\"\n",
    "\n",
    "full_dataset = pd.read_csv(\"ICDdata40k.csv\")[[ \"TEXT\", \"ICD9_CODE\"]]\n",
    "full_dataset= full_dataset[:1000]\n",
    "print(\"Done fetching all the data\")\n",
    "full_dataset.head()"
158
159
   ]
  },
Zaid A Ali's avatar
Zaid A Ali committed
160
161
162
163
164
165
166
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Converting clinical notes to tf-idf vectors"
   ]
  },
167
168
169
  {
   "cell_type": "code",
   "execution_count": null,
170
   "metadata": {},
171
172
173
174
175
176
177
   "outputs": [],
   "source": [
    "import nltk"
   ]
  },
  {
   "cell_type": "code",
178
   "execution_count": 3,
179
   "metadata": {},
180
181
182
183
184
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
185
186
187
      "Transforming descriptions into TF-IDF vectors\n",
      "(1000, 9878)\n",
      "Done transforming data\n"
188
189
190
191
     ]
    }
   ],
   "source": [
192
193
194
195
196
197
198
199
200
    "#tf-idf vectorization\n",
    "print(\"Transforming descriptions into TF-IDF vectors\")\n",
    "texts = full_dataset.TEXT\n",
    "tfidf = TfidfVectorizer(sublinear_tf=True, min_df=5, norm='l2', encoding='latin-1', ngram_range=(1, 2), stop_words='english')\n",
    "feature_vectors = tfidf.fit_transform(texts)\n",
    "feature_vectors = feature_vectors.toarray()\n",
    "icd_codes = full_dataset.ICD9_CODE\n",
    "print(feature_vectors.shape)\n",
    "print(\"Done transforming data\")\n"
201
202
   ]
  },
Zaid A Ali's avatar
Zaid A Ali committed
203
204
205
206
207
208
209
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Passing the tfi-idf vectors into multiple ML models in order to evaluate which one is the best model"
   ]
  },
210
211
  {
   "cell_type": "code",
212
   "execution_count": 4,
213
   "metadata": {},
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Model</th>\n",
       "      <th>Average_Accuracy</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>LinearSVC</td>\n",
       "      <td>0.038</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>MultinomialNB</td>\n",
       "      <td>0.041</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>LogisticRegression</td>\n",
       "      <td>0.038</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>RandomForestClassifier</td>\n",
       "      <td>0.041</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                    Model  Average_Accuracy\n",
       "0               LinearSVC             0.038\n",
       "1           MultinomialNB             0.041\n",
       "2      LogisticRegression             0.038\n",
       "3  RandomForestClassifier             0.041"
      ]
     },
273
     "execution_count": 4,
274
275
276
277
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
278
   "source": [
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
    "#Evaluating different models\n",
    "models = [\n",
    "    \n",
    "    LinearSVC(),\n",
    "    MultinomialNB(),\n",
    "    LogisticRegression(random_state=0),\n",
    "    RandomForestClassifier(n_estimators=200, max_depth=3, random_state=0)\n",
    "]\n",
    "\n",
    "CV = 2\n",
    "\n",
    "cross_val_results = pd.DataFrame(columns=[\"Model\", \"Average_Accuracy\"])\n",
    "\n",
    "for model in models:\n",
    "    \n",
    "    model_name = model.__class__.__name__\n",
    "    accuracies = cross_val_score(model, feature_vectors, icd_codes, scoring='accuracy', cv=CV)\n",
    "    avg_accuracy = sum(accuracies)/len(accuracies)\n",
    "    cross_val_results = cross_val_results.append({\"Model\": model_name, \"Average_Accuracy\": avg_accuracy }, ignore_index=True)\n",
Zaid A Ali's avatar
Zaid A Ali committed
298
    "\n",
299
300
    "\n",
    "cross_val_results"
Zaid A Ali's avatar
Zaid A Ali committed
301
302
   ]
  },
Zaid A Ali's avatar
Zaid A Ali committed
303
304
305
306
307
308
309
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Further exploring the Random Forest Classifier by creating a confusion matrix"
   ]
  },
Zaid A Ali's avatar
Zaid A Ali committed
310
311
  {
   "cell_type": "code",
312
   "execution_count": 8,
Zaid A Ali's avatar
Zaid A Ali committed
313
   "metadata": {},
314
315
316
317
318
319
320
321
322
323
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Done exploring Random Forest Classifier\n"
     ]
    },
    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334
      "text/plain": [
       "<Figure size 288x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
335
   "source": [
336
337
338
    "#Random Forest Classifier appears to have a slight edge over the other models, so it is time to explore it in more depth\n",
    "from matplotlib.pyplot import matshow\n",
    "model = RandomForestClassifier(n_estimators=200, max_depth=3, random_state=0)\n",
339
    "X_train, X_test, y_train, y_test = train_test_split(feature_vectors, icd_codes, test_size=0.10, random_state=0)\n",
340
    "\n",
341
342
    "model.fit(X_train, y_train)\n",
    "y_pred = model.predict(X_test)\n",
343
    "\n",
344
    "conf_mat = confusion_matrix(y_test, y_pred)\n",
345
    "\n",
346
347
    "matshow(conf_mat)\n",
    "print(\"Done exploring Random Forest Classifier\")\n"
348
   ]
349
  },
Zaid A Ali's avatar
Zaid A Ali committed
350
351
352
353
354
355
356
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Create final classification report for the Random Forest classifier"
   ]
  },
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "              precision    recall  f1-score   support\n",
      "\n",
      "       40301       0.00      0.00      0.00       2.0\n",
      "         486       0.00      0.00      0.00       2.0\n",
      "       58281       0.00      0.00      0.00       3.0\n",
      "        5855       0.00      0.00      0.00       9.0\n",
      "        4254       0.00      0.00      0.00       7.0\n",
      "        2762       0.00      0.00      0.00       4.0\n",
      "        7100       0.00      0.00      0.00       5.0\n",
      "        2767       0.00      0.00      0.00       5.0\n",
      "        7243       0.00      0.00      0.00       4.0\n",
      "       45829       0.00      0.00      0.00      10.0\n",
      "        2875       0.00      0.00      0.00       2.0\n",
      "       28521       0.00      0.00      0.00       7.0\n",
      "       28529       0.00      0.00      0.00       2.0\n",
      "       27541       0.00      0.00      0.00       5.0\n",
      "        5856       0.00      0.00      0.00       1.0\n",
      "       58381       0.00      0.00      0.00       8.0\n",
      "        5589       0.00      0.00      0.00       2.0\n",
      "       32723       0.00      0.00      0.00       1.0\n",
      "       22804       0.00      0.00      0.00       5.0\n",
      "       33829       0.00      0.00      0.00       5.0\n",
      "       78900       0.00      0.00      0.00       5.0\n",
      "       79092       0.00      0.00      0.00       1.0\n",
      "       V4511       0.00      0.00      0.00       5.0\n",
      "\n",
      "    accuracy                           0.00     100.0\n",
      "   macro avg       0.00      0.00      0.00     100.0\n",
      "weighted avg       0.00      0.00      0.00     100.0\n",
      "\n"
     ]
    }
   ],
   "source": [
    "from sklearn import metrics\n",
    "#Display metrics on Random Forest Classifier\n",
    "print(metrics.classification_report(y_test, y_pred, target_names=full_dataset['ICD9_CODE'].unique()))"
   ]
  },
405
  {
Zaid A Ali's avatar
Zaid A Ali committed
406
   "cell_type": "markdown",
407
408
   "metadata": {},
   "source": []
Zaid A Ali's avatar
Zaid A Ali committed
409
410
411
412
  }
 ],
 "metadata": {
  "kernelspec": {
413
   "display_name": "Python 3",
Zaid A Ali's avatar
Zaid A Ali committed
414
   "language": "python",
415
   "name": "python3"
Zaid A Ali's avatar
Zaid A Ali committed
416
417
418
419
420
421
422
423
424
425
426
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
427
   "version": "3.8.8"
Zaid A Ali's avatar
Zaid A Ali committed
428
429
430
  }
 },
 "nbformat": 4,
431
 "nbformat_minor": 4
Zaid A Ali's avatar
Zaid A Ali committed
432
}