Predicting Discharge Medications At Admission Time Based On Deep Learning

Predicting Discharge Medications At Admission Time Based On Deep Learning

Yuan Yang Pengtao Xie Xin Gao Petuum Inc., Pittsburgh, 15222, USA Carol Cheng Christy Li Petuum Inc., Pittsburgh, 15222, USA Hongbao Zhang Petuum Inc., Pittsburgh, 15222, USA Eric Xing

Predicting discharge medications right after a patient is admitted is an important clinical decision, which helps physicians plan the type of medication regiment and decide when to start or stop medications during an inpatient stay as some medications require time to add on and need to be managed in the setting of other medications. This could be a difficult decision to make for human physicians since the information available upon admission is limited and patients’ condition may evolve during an inpatient stay. In this work, we investigate how to leverage deep learning technologies to assist physicians in predicting discharge medications based on information documented in the admission note. We build a convolutional neural network which takes an admission note as input and predicts the medications placed on the patient at discharge time. Our method is able to distill semantic patterns from unstructured and noisy texts, and is capable of capturing the pharmacological correlations among medications. We evaluate our method on 25K patient visits and compare with 4 strong baselines. Our methods demonstrate a 20% increase in macro-averaged F1 score than the best baseline.


With the adoption of the Electronic Health Record (EHR) systems in the US and the rapid development of new sources of healthcare data, a tsunami of medical and healthcare data has emerged [raghupathi2014big]. As the amount and complexity of the data grows, medical analysis and decision making become time-consuming, error-prone, and suboptimal. Among the various clinical decisions, making treatment plans is a critical and challenging one. Given the right diagnosis, physicians need to optimize a treatment plan across time. One of such decisions is discharge medication prediction: for a newly admitted patient, predicting the medications placed on the patient at discharge time based on the information available at admission time. A successful prediction of discharge medications provides physicians with guidance on what type of medication regiment to plan for and when to start or stop medications during an inpatient stay as some medications require time to add on and need to be managed in the setting of other medications. In an inpatient setting, patients are admitted on their home medications and due to various reasons including the cause for admission, the condition of the patient, diagnosis, and other co-morbidities, the patient’s medications are changed throughout the inpatient stay and will be different at the time of discharge. For example, a chronic kidney disease patient with chronic heart failure and hypertension could have been admitted for a heart failure exacerbation and then require changes to their antihypertensive medication. In this case, it would be helpful for the physician to understand what medications are better to add or remove through analysis of past cases given that in those situations one medication can improve one disease at the cost of exacerbating another. Sometimes it could be difficult for human physicians to balance the pros and cons in that situation, who are left without a good way to make that decision.

With the advancement of machine learning and deep learning (DL) technologies, data-driven computational models can be developed to automatically and comprehensively digest massive medical information such as EHRs, images, behavior and genomic data, distill clinical patterns and insights therefrom and make more informed decisions. In this work, we leverage DL methods to predict discharge medications at admission time. Two issues make this task challenging. First, information available upon admission is mostly documented in unstructured clinical notes (called admission notes), such as past medical history, family and social history, allergies, etc. Compared with structured information such as labs and vital signs, the free-form texts are more difficult to process and to understand for machines. The notes contain synonyms, abbreviations and misspellings. Distilling semantic patterns from such unstructured and noisy texts are very challenging. Second, since independent medications have pharmacological effects on each other, there are various situations in medicine where medications are prescribed together as a pair or more due to research and public consensus about optimal therapy. For example, for those patients who have had a recent stroke while already on aspirin, it is recommended as future stroke prevention for them to be prescribed aspirin and clopidogrel, which is referred to as dual anti-platelet therapy. In another example, in those who have had a recent heart attack while also having diabetes, it is recommended starting them on a statin, aspirin, beta-blocker, and ace-inhibitor. In this situation, physicians utilize multi-medication therapy because all have been shown to have a certain impact on mortality/disease progression. How to automatically discover and leverage such pharmacological correlations among medications is crucial for more accurate multiple-medication prediction and is highly non-trivial.


In this paper, we develop a Convolutional Neural Network (CNN) model which takes an admission note as input and predicts one or multiple discharge medications. The CNN model is able to learn rich semantic representations from raw texts and can automatically capture the correlations among medications. We evaluate the model on a specific medication category – antihypertensive medications, on 25K patient visits. Our model demonstrates a 20% increase in macro-averaged F1 score than the best baseline method.

Related work

With the prosperity of healthcare data such as Electronic Health Record (EHR), genomic data, patient behavior data and the growing need of extracting knowledge and insights from these data, data-driven healthcare analytics based on machine learning and deep learning have received much attention recently.

Predictive Modeling

Predictive modeling in data-driven healthcare is concerned about building machine learning models to predict diagnosis, prognosis, patient risk factors, readmission, disease onset and so on. Wang et al. [wang2012medical] studied disease prognosis by leveraging the information of clinically similar patient cohort. Zhou et al. [zhou2013patient] proposed a top-k stability selection method to select the most informative features for patient risk prediction. Chen et al. [chen2015cloud] developed a cloud-based predictive modeling system for pediatric asthma readmission prediction. Lipton et al. [lipton2015learning] applied long short-term memory (LSTM) network for pattern discovery from lab measurements and make diagnostic predictions based on the discovered patterns. Razavian et al. [razavian2015population] developed predictive models to predict the onset and risk factors of type-2 diabetes. Choi et al. [choi2016doctor] used recurrent neural networks (RNN) to predict diseases and recommend medications for patients’ subsequent encounters [miotto2017deep]. Pham et al. [pham2016deepcare] utilized RNN to model disease progression, recommend intervention and predict future risk for mental health and diabetes. Razavian et al. [razavian2016multi] developed a LSTM network and two convolutional neural networks (CNNs) for multi-task prediction of disease onset. Several works [cheng2016risk, zhou2014micro, nguyen2017mathtt] leveraged CNNs for heart disease diagnosis. Miotto et al. [miotto2016deep] proposed to use denoising autoencoders to learn a general-purpose patient representation that can be used to predict patients’ future health status.

Natural Language Processing and Understanding of Clinical Notes

Clinical notes contain rich medical information. Many studies have developed natural language processing and machine learning methods to extract useful information from free-from clinical texts. Cheng et al. [chen2013applying] investigated word sense disambiguation using support vector machine (SVM) and active learning. Fan et al. [fan2013syntactic] developed a handbook of domain-customized syntactic parsing guidelines of clinical texts, in particular, how to handle ill-formed sentences. Tang et al. [tang2013hybrid] developed a temporal information extraction system that can identify events, temporal expressions, and their temporal relations in clinical text. Tang et al. [tang2013recognizing] studied clinical entities recognition in hospital discharge summaries using structured SVM. Gobbel et al. [gobbel2014assisted] designed a tool to assist the annotation of medical texts based on interactive training. Lei et al. [lei2014comprehensive] systematically investigated features and machine learning algorithms for named entity recognition in Chinese clinical text. Tang et al. [tang2014evaluating] performed a comparison study of three different types of word representation features for biomedical named entity recognition, including clustering-based representation, distributional representation, and word embeddings. Halpern et al. [halpern2016clinical] developed a bipartite probabilistic graphical models for joint prediction of clinical conditions from the electronic medical records. Jagannatha et al. [jagannatha2016structured] applied LSTM and conditional random field to recognize medical entities from clinical notes.


Figure 1: Frequencies of 8 antihypertensive medications in the MIMIC-III dataset. “Hctz” is the shorthand for hydrochlorothiazide.

Study design

On previously collected electronic health records of Intensive Care Unit (ICU) patients, we performed a retrospective study to build a deep learning model predicting discharge medications based on admission notes. We evaluated the proposed model by comparing the predicted medications with the ground-truth medications given by physicians and compared with several competitive baselines.

Dataset description and preparation

The study is performed on the MIMIC-III dataset [johnson2016mimic], a public dataset containing 52K patient-visits of 40K unique patients who stayed in the ICU at Beth Israel Deaconess Medical Center between 2001 and 2012 (registration required for accessing the data). This dataset contains thousands of unique medications. With such limited data (52K patients visits), it is extremely difficult to build a highly accurate predictive model for thousands of medications. Instead, we focus our study on 8 antihypertensive medications: metoprolol, furosemide, lisinopril, amlodipine, atenolol, hydrochlorothiazide (hctz), diltiazem, carvedilol, due to the following two considerations. First, these medications are commonly used to treat hypertension – one of the most prevalent and severe chronic diseases. In particular, they widely occur in MIMIC-III. Second, they are difficult to predict: their prescriptions and usage have large variance, especially when multiple of them are used together, making them an excellent testbed of our approach. The frequencies of these medications are imbalanced (as shown in Figure 1): some of them occur very frequently while others are of small frequency, which adds another layer of difficulty for prediction. It is worth noting that our method can be readily extended to other categories of medications, as long as sufficient clinical data is available.

In this dataset, only discharge notes and nursing notes are provided. The admission notes are not directly accessible. To address this issue, from the discharge notes which contain information collected during the entire course of a patient visit, we extract the information that is only available upon admission such as chief complaint, past medical history and combine them into an admission note. The entire list of different types of admission information is given in Table 1. Each discharge note consists of multiple sections, each of which has a heading summarizing the content of this section. We perform string matching on the headings to pick up the sections containing admission information. It is often the case that the same type of admission information (e.g., history of the present illness) are given different headings (e.g., “History of present illness”, “HPI”) in different notes. To extract admission information as much as possible, we enumerate all the heading strings that indicate admission information (example strings shown in Table 1) and use them to match the headings in the notes to pick out sections containing admission information.

The discharge medications are also contained in the admission notes as semi-structured sections. Each such section starts with a heading named “discharge medications” or “meds on discharge”, which is followed by a list of bullet points, each containing a discharge-medication string. We use regular expressions to recognize the antihypertensive medications. Patient visits containing no antihypertensive medications are discarded.

After preprocessing, the dataset contains 25K patient visits, each consisting of an admission note and a set of discharge antihypertensive medications. Words in the admission notes are all lower-cased and stopwords are removed. The average word count of admission notes is 350.

Types of Admission Information Heading Strings
Allergy “allergies”
Chief complaint “chief complaint”
History of present illness “history of present illness”, “hpi”
Past medical history “past medical history”, “major surgical or invasive procedure”,
Social history “social history”, “history”
Family history “family history”, “family hx”
Initial exam “admission labs”, “physical exam”
Admission medications “admission medications”, “meds on admission”
Table 1: Different types of information available upon admission and subsets of heading strings used to extract each type of information.
Figure 2: The network architecture of the CNN model.

Model design

We develop a deep learning model to predict discharge medications based on information available upon admission. The input of the model is an admission note and the output is one or multiple medications that are placed on the patient at discharge time. The model is supposed to have two capabilities. First, it should be able to effectively distill high-level semantics from the noisy and unstructured raw texts and properly take into account the sequential structure among consecutive words. A sequence of consecutive words is called a -gram where is the size of this gram. Second, it should have the mechanism to capture the pharmaceutical correlation among medications.

To simultaneously achieve these two goals, we develop a convolutional neural network (CNN) [kim2014convolutional] based model. At a high level, the model (1) uses multiple layers of stacked hidden units to capture the latent semantics of input notes; (2) uses convolutional operators with different window sizes to capture the local semantics and sequential structure existing in -grams; (3) discovers common latent factors to capture the pharmaceutical correlations among medications. In the sequel, we describe the model in detail.

The full architecture of the CNN model is shown in Figure 2. The input of the model is an admission note, which is represented as a sequence of words , where denotes the -th word. is the length of this note. The first layer of the CNN model performs word embedding, which learns a semantic vector representation for each word. Different occurrences of the same word (e.g., and are both “hypertension”) share the same embedding vector. This layer has a weight parameter matrix where is the number of unique words in the vocabulary, is the dimension of the embedding vectors and the -th row vector is the embedding of word . After the word embedding layer, the note is represented as a -by- matrix where the -th row vector is the embedding of .

The second layer of CNN performs convolution, which captures the local semantics and sequential structure manifested in -grams. The convolution operation is conducted by filters, each aiming at capturing one specific semantic. Each filter is parameterized by a -by- weight matrix and a bias term , where is the window size. The input of the filter is a -by- matrix — the embeddings of words in a -gram. The output is a new feature value computed as

where denotes matrix inner product and denotes a nonlinear activation function such as sigmoid, hyperbolic tangent and rectified linear. These nonlinear functions enhance the expressiveness of CNN to capture nonlinear and complicated semantic patterns. The same filter is applied to all possible -grams at different positions to detect the saliency of the semantic it represents. To capture a variety of different semantics, multiple filters with different weight parameters are used. In addition, the size of grams plays a crucial role in differentiating the subtlety in semantics. For example, for the three grams “leukemia”, “lymphoblastic leukemia”, “acute lymphoblastic leukemia” with size 1, 2, 3 respectively, though they all refer to the same type of disease, the specificity of disease type varies substantially under different sizes. To be able to capture semantically meaningful phrases containing a variable number of words, we set up filters with different window sizes.

The convolution layer is followed by the max pooling layer, which aims at capturing the most important semantics in the notes. Among the feature values produced by a filter, the max pooling scheme selects the largest one as the final output of this filter. The purpose is to be robust to small variations in semantics. The pooled values of all filters are concatenated together to represent the entire note. The concatenation layer is followed by a dense layer, aiming at further capturing the nonlinear patterns presenting in notes. The dense layer consists of hidden units, each of which is connected to all units (denoted by ) in the concatenation layer. The value of the -th dense unit is computed as

where and are the weight vector and bias term associated with this unit, and is the activation function.

Next, on top of the dense layer, we make predictions of the discharge medications. As noted earlier, it is often the case that multiple medications are used together. Thereby, this is a multi-label prediction problem: given a total of medications, picking up a subset of them. As stated earlier, medications have pharmacological effects on each other and it is important to capture such correlation for more accurate prediction. To achieve this goal, we borrow ideas from the factor analysis [jolliffe1986principal] model and assume these medications share a common set of latent factors (which are probabilistic variables) and the predictive model of each medication is a linear combination of the latent factors. The linear coefficients are different for different medications. These common factors capture the commonality among medications while the medication-specific linear coefficients preserve the difference among medications. We use the hidden units in the dense layer to characterize the latent factors and model each medication as a weighted combination of the factors (denoted by ). Let be a -dimensional random vector where denotes the confidence score of using medication . According to the factor analysis model, we assume

where is the coefficient matrix (referred to as loading matrix in the factor analysis literature) and is an offset vector. The expectation of is:

The covariance matrix of is calculated as:


This covariance matrix, which captures the correlations among medications, is automatically learned during the training process. Given these confidence scores, we transform them into probabilities. Specifically, the probability of using medication is calculated as

To this end, we obtain the entire CNN architecture which takes an admission note as input and produces the prediction probabilities of discharge medications. Next, we discuss how to learn the model parameters including word embedding vectors, weight vectors and bias terms from physician-labeled training data. Let denote training examples where is the admission note of the -th example and (where is the number of unique medications) is a binary vector representing the ground-truth discharge medications labeled by physicians. denotes that the -th medication was used. Let be a -dimensional prediction vector where is the probability that medication is placed on patient and is the mapping induced by CNN. We define a loss function to measure the discrepancy between the prediction and the ground-truth . A commonly used loss function is the cross entropy loss:

We then minimize this loss to obtain the optimal weight parameters of the CNN model using a gradient descent algorithm, which iteratively performs the following two steps until convergence: (1) taking derivatives of the loss function with respect to all weight parameters using a back-propagation procedure; (2) moving each weight parameter by a small step along its negative-gradient direction. In model training, batch normalization [ioffe2015batch] is performed before every non-linear transform; dropout [srivastava2014dropout] is performed on the hidden units after concatenation; and L2 regularization is applied on all learnable weight parameters except bias terms. These techniques help to prevent over-fitting and speed up training.

Given the learned model, we use it to make predictions on previously unseen patient visits: (1) calculating the probability of each medication; (2) picking up the medications whose probabilities are larger 0.5 as discharge medications.

Setup and Evaluation

Baseline models: we compare the CNN model against three classification models, including support vector machine [cortes1995support] (SVM), random forest [ho1995random] (RF) and logistic regression [cox1958regression] (LR). Unlike CNN, these models lack the mechanism to automatically learn semantic representations of texts or capture correlations among medications. The input features of these models are term-frequency and inverse document frequency (TF-IDF) vectors extracted from the admission notes. TF-IDF is widely used in natural language processing and text classification.

As observed in clinical practice, discharge medications are closely related to admission medications. Sometimes, they are even largely overlapped. One may wonder whether it is sufficient to predict discharge medications solely based on admission medications, without the need of other types of admission information such as past medical history and chief complaint. To answer this question, we compare with another baseline, which only uses admission medications as input and uses a multi-layer perceptron (MLP) to predict the discharge medication. For each note, we extract the admission medications from the section titled “Admission medications” or “Meds on admission” and encode them into a -dimensional binary vector where denotes that this note has the -th admission medication and is the number of unique admission-medications. is fed into the MLP for discharge medication prediction.

Experimental setup: CNN is implemented with TensorFlow [abadi2016tensorflow] and its weight parameters are optimized using the Adam [kingma2014adam] method, a variant of the stochastic gradient descent (SGD) algorithm. The dataset is split into 3 parts: 80% for training, 10% for validation and 10% for testing. The hyper-parameters are tuned using grid search on the validation set. In CNN, we set three sets of filters. Filters’ window size in each set is 3, 4, 5 respectively. Each set contains 64 filters. The learning rate in Adam is set to 0.01. The keep rate in Dropout [srivastava2014dropout] is set to 0.3. The L2 regularization parameter is set to 0.1. The TF-IDF feature dimension is set to 1500 for SVM and RF and is set to 2500 for LR. In SVM, we use the radius basis function (RBF) kernel where the scale parameter is set to 0.1. The tradeoff parameter between hinge loss and margin size is set to . In RF, the number of trees is set to 200; the number of features to consider when looking for the best split is set to 80; the minimum number of samples required to be at a leaf node is set to 1. In LR, the L2 regularization parameter is set to 1.

Evaluation metrics: To evaluate model performance, we measure class(medication)-wise precision, recall and F1 scores on the test set and the micro and macro averages of these scores across all medication classes. The micro average is obtained by taking the weighted average of class-wise scores where the weights are proportional to the frequencies of medication classes. The macro average is calculated as the unweighted average of the class-wise scores. Macro-average gives equal weight to each medication class, whereas micro average gives equal weight to each data example. Since the frequencies of medication classes are highly skewed (as shown in Figure 1), micro-average – which is in favor of frequent classes – may underestimate the error in infrequent classes. The macro-average score alleviates this drawback by treating each class equally and can better reveal model’s performance on infrequent classes.


Table 2 shows the precision (P), recall (R) and F1-score (F) of different methods for each antihypertensive medication averaged over 5 runs with random dataset split (standard deviations provided in Supplementary Table 6). The last two lines show the micro- and macro-averaged scores over all medications. As can be seen, CNN achieves much better micro and macro average F1 than the baseline methods. Between the two averages, CNN’s improvement on macro average is more significant. On 7 medications, CNN achieves the best F1 scores. The only exception is furosemide, where RF outperforms CNN. CNN’s improvement over the baselines is mainly on the recall scores while its precision scores are comparable with the baselines. Among the baselines, MLP which only uses admission medications as inputs performs the worst in terms of the micro and macro average F1. SVM and RF which are non-linear models perform better than LR which is a linear model.

Medication CNN MLP SVM RF LR
Metoprolol 0.73 0.87 0.79 0.64 0.96 0.77 0.74 0.79 0.76 0.74 0.89 0.81 0.74 0.85 0.79
Furosemide 0.59 0.85 0.70 0.62 0.42 0.46 0.70 0.64 0.67 0.73 0.67 0.70 0.74 0.62 0.68
Lisinopril 0.56 0.51 0.53 0.63 0.43 0.49 0.56 0.44 0.49 0.70 0.35 0.46 0.66 0.29 0.40
Amlodipine 0.59 0.45 0.49 0.11 0.08 0.09 0.61 0.34 0.43 0.72 0.29 0.41 0.78 0.10 0.18
Atenolol 0.58 0.27 0.32 0.00 0.00 0.00 0.45 0.23 0.30 0.70 0.14 0.24 0.52 0.03 0.06
Hctz 0.41 0.23 0.26 0.00 0.00 0.00 0.35 0.21 0.26 0.61 0.04 0.07 0.60 0.02 0.04
Diltiazem 0.62 0.37 0.46 0.00 0.00 0.00 0.45 0.21 0.28 0.73 0.12 0.20 0.85 0.04 0.07
Carvedilol 0.60 0.56 0.57 0.00 0.00 0.00 0.51 0.28 0.36 0.74 0.27 0.40 0.79 0.08 0.15
Micro Avg 0.63 0.70 0.65 0.51 0.54 0.51 0.65 0.58 0.60 0.72 0.60 0.61 0.72 0.53 0.55
Macro Avg 0.59 0.51 0.52 0.25 0.24 0.23 0.55 0.39 0.44 0.71 0.35 0.41 0.71 0.25 0.30
Table 2: Medication-wise precision (P), recall (R) and F1-score (F) for CNN and 4 baseline models averaged over 5 runs. From top to bottom, medications are shown in descending order of their frequencies. The overall performance is measured using micro- and macro-average.
Query NN Query NN Query NN Query NN
artery troponin pressure quinapril fibrillation diltiazem lopressor metoprolol
glucose blood renal amlodipine sclera yellow vessel triple
aortic mitral lisinopril pindolol diarrhea nonbloody angina echocardiograms
edema myxedema graft mqwmi erythema cellulitis amlodipine norvasc
ventricular aneurismal lasix furosemide cardiac echoes incision open
Table 3: A subset of (query) words together with their nearest neighbor (NN). The “nearness” between words is measured as the Euclidean distance between their corresponding embedding vectors.

One major reason that CNN outperforms other baseline models is that it uses a hierarchy of hidden layers to capture semantics in the notes at multiple granularities: word-level, n-gram level and note-level. We perform various visualizations to verify this. First, we examine whether the word embedding vectors are able to capture word-level semantics. For each word , we compute the Euclidean distance between the embedding vector of and that of any other word, then retrieve the nearest neighboring word that has the smallest distances with . Table 3 shows the nearest neighbor of 20 exemplar words. Next, we visualize the filters in the convolutional layer and check whether they are able to capture semantics at the -gram level. To visualize a filter, we apply it to all -grams whose sizes match the window size of this filter and pick out the ones that yield the largest feature values. Table 4 shows the top -grams for 4 filters of window size 3, and the other 4 filters of window size 4. Finally, we examine whether the dense layer vectors which represent the entire note are able to capture note-level semantics. We project these vectors from their original high-dimensional space into a two-dimensional space using the t-SNE [maaten2008visualizing] tool. As shown in Figure 3, each dot represents a note. In each sub-plot titled with a medication name, red dots denote the notes that are associated with this medication and black dots denote the notes that are not associated with this medication.

Another source of improvement of the CNN model over the baselines is its ability in capturing the correlation among medications. To verify this, we compare the medication-correlations learned by our model and those computed from the training data. Let (equation (1)) denote the covariance matrix learned by the model. The correlation between medication and is defined as

On the other hand, we can measure the strength of association between the two medications using the point-wise mutual information (PMI) which is computed based on the co-occurrence statistics of the two medications:

, and are the number of admissions where and are used together, is used, is used, respectively. By definition, PMI quantifies the mutual dependence between two variables and can thus characterize the correlations between these variables. The results are shown in Table 5 where for each medication, we compute its correlation and PMI scores with all other medications (which are ranked in descending order of the corresponding scores).

Window Size 3
Filter 1 Filter 2
edema varicosities glucose hypertension esrd dialysis
bilateral varicosities blood history esrd fistula
bilaterally varicosities patient syndrome esrd gastric
edema varicosities neuro black stools prior
superficial varicosities bilat procedures hemodialysis placed
Filter 3 Filter 4
xanthalesma admission labs coronary artery saphenous
blood discharge labs coronary artery bypass
blood mchc labs valve disease replacement
blood notdone ctropnt varicosities bilat post
ctropnt discharge labs coronary disease pulse
Window Size 4
Filter 5 Filter 6
short breath work symptoms combination dilated cardiomyopathy alcohol
distant breath sounds focal disease ischemic cardiomyopathy placement
decreased breath sounds obese alcohol hypertensive cardiomyopathy etoh
short breath male history congestive heart failure cardiac
including phenylephrine paced function diastolic heart failure fall
Filter 7 Filter 8
coronary artery bypass grafting stopping congestive heart failure
artery bypass grafting lima history congestive heart failure
artery bypass grafts lima causing congestive heart failure
artery bypass graft lima mild congestive heart failure
coronary artery bypass grafts presented congestive heart failure
Table 4: Visualization of filters. For each filter, we show the top 5 -grams that yield the largest feature values under this filter.
Metoprolol Furosemide Lisinopril Amlodipine
Furosemide 0.45 Furosemide 0.02 Carvedilol 0.54 Carvedilol 0.12 Atenolol 0.07 Carvedilol 0.08 Hctz 0.56 Hctz 0.14
Lisinopril -0.16 Lisinopril -0.10 Metoprolol 0.45 Metoprolol 0.02 Hctz 0.07 Hctz 0.07 Atenolol 0.37 Carvedilol -0.14
Amlodipine -0.27 Diltiazem -0.21 Amlodipine -0.26 Diltiazem -0.17 Carvedilol 0.06 Atenolol 0.04 Diltiazem 0.36 Lisinopril -0.18
Carvedilol -0.35 Amlodipine -0.22 Lisinopril -0.26 Lisinopril -0.17 Diltiazem -0.12 Metoprolol -0.10 Carvedilol -0.01 Atenolol -0.18
Hctz -0.35 Hctz -0.24 Diltiazem -0.28 Atenolol -0.28 Metoprolol -0.16 Furosemide -0.17 Furosemide -0.26 Metoprolol -0.22
Atenolol -0.45 Atenolol -1.40 Atenolol -0.32 Amlodipine -0.28 Furosemide -0.26 Amlodipine -0.18 Metoprolol -0.27 Furosemide -0.28
Diltiazem -0.47 Carvedilol -1.64 Hctz -0.50 Hctz -0.72 Amlodipine -0.41 Diltiazem -0.26 Lisinopril -0.41 Diltiazem -0.62
Atenolol Hctz Diltiazem Carvedilol
Hctz 0.75 Hctz 0.24 Atenolol 0.75 Atenolol 0.24 Hctz 0.74 Hctz 0.06 Furosemide 0.54 Furosemide 0.12
Diltiazem 0.71 Lisinopril 0.04 Diltiazem 0.74 Amlodipine 0.14 Atenolol 0.71 Furosemide -0.17 Diltiazem 0.11 Lisinopril 0.08
Amlodipine 0.37 Amlodipine -0.18 Amlodipine 0.56 Lisinopril 0.07 Amlodipine 0.36 Metoprolol -0.21 Atenolol 0.06 Amlodipine -0.14
Lisinopril 0.07 Furosemide -0.28 Lisinopril 0.07 Diltiazem 0.06 Carvedilol 0.11 Lisinopril -0.26 Lisinopril 0.06 Hctz -0.43
Carvedilol 0.06 Diltiazem -0.30 Carvedilol -0.09 Metoprolol -0.24 Lisinopril -0.12 Atenolol -0.30 Amlodipine -0.01 Diltiazem -0.75
Furosemide -0.32 Metoprolol -1.40 Metoprolol -0.35 Carvedilol -0.43 Furosemide -0.28 Amlodipine -0.62 Hctz -0.09 Metoprolol -1.64
Metoprolol -0.45 Carvedilol -1.93 Furosemide -0.50 Furosemide -0.72 Metoprolol -0.47 Carvedilol -0.75 Metoprolol -0.35 Atenolol -1.93
Table 5: Medication correlation (CORR) scores learned by our model and point-wise mutual information (PMI) scores computed from training data.
Figure 3: T-SNE visualization of the latent vectors (denoted by dots) in the dense layer. Under each subplot titled with a medication, red dots denote the notes labeled with this medication and black dots denote those that are not.


As shown in Table 2, on average, CNN outperforms the baseline models substantially. The reasons are two-fold. First, CNN has the ability to capture the semantics of admission notes at different granularities while the baselines methods lack such mechanisms. CNN learns the semantics of words, n-grams and entire notes using word-embedding layer, convolutional layer and dense layer respectively.

As shown in Table 3, for each query word, it has a strong clinical correlation with its nearest neighbor (NN) (which has the smallest Euclidean distance with the query word in the embedding space). For example, for “artery ” and its NN “troponin”, they are correlated in the following way: in patients with coronary artery disease, the level of troponin is elevated. “aortic” and “mitral” are correlated because the aortic valve and the mitral valve are the most commonly replaced valves. The correlation between “angina” and “echocardiograms” is: echocardiogram is used to identify the cause of angina. This demonstrates that the learned embedding vectors are able to well capture the semantics of words.

In the convolutional layer, each filter is able to capture a specific local semantic. As shown in Table 4, the top -grams under a convolutional filter have strong semantic ties. For example, the top -grams under Filter 1-4 are about varicosities, renal disease, lab tests and coronary disease respectively. The top -grams under Filter 5-8 are about breathing problems, cardiomyopathy and heart failure respectively. Interestingly, grams that do not share any common words but possess related semantics are grouped under the same filter. For example, in Filter 2, the three grams “hypertension esrd dialysis”, “black stools prior”, “procedures hemodialysis placed” do not share any words in common, but their semantics are closely related: “black stools” is a common symptom of “esrd” (end-stage renal disease); “hemodialysis” is a common medical procedure of treating “esrd”. Filter 8 demonstrates the necessity of using filters with different window sizes. While these -grams are all about “congestive heart failure” (CHF), their difference in the first word reveals the subtlety in semantics: the 5 grams are about the ending, history, starting, severity and existence of CHF respectively. If we only use filters of window size 3, we can only capture one single semantic “congestive heart failure”. But using filters of window size 4 enables us to capture more fine-grained semantics.

The note-level representation vector obtained in the dense layer is able to capture the global semantics of the entire note. As visualized in Figure 3, for notes that are associated with the same discharge medication, their representation vectors are close to each other. For example, in the first subplot, the notes are clearly clustered into two groups, which correspond to “with metoprolol” and “without metoprolol” respectively. The similar phenomenon is seen in other plots as well. This indicates that these concatenation vectors are very informative for predicting discharge medications. In addition, from these plots, we can identify a few clinical insights. First, from the subplots titled with “metoprolol” and “furosemide”, we can see the red points have substantial overlap, which indicates that these two medications tend to be used together. Second, from the plots titled with “amlodipine” and “atenolol”, we can see that these two medications have minimal overlap, indicating that they are seldom used together.

The other major reason that the CNN model outperforms the baselines is because it is able to capture the correlation among medications. As can be seen from Table 5, the rankings based on correlation are very consistent with those based on PMI. For example, for all medications except lisinopril, the most correlated medication found according to correlation is the same as that found according to PMI. This indicates that the CNN model can effectively capture the correlations among medications.

Comparing the F1 scores on individual medications, we can see that CNN achieves larger improvements on less frequent medications such as atenolol and diltiazem. On frequent mediations such as metoprolol and furosemide, CNN is on par with the baseline methods. As a consequence, CNN achieves more improvement on macro average F1 which does not take into account medication frequency. For the micro average F1 where the individual F1 scores are weighted using the frequency of medications, CNN’s improvement over the baselines is less significant. We conjecture that CNN’s better performance on infrequent medications lies in its ability to capture medication correlations. The prediction of a medication depends on two factors: (i) how strongly the medication is relevant to the input admission note; (ii) how strongly this medication is correlated with other medications. For infrequent medications where a high-quality model measuring (i) is difficult to train due to the lack of training examples, (ii) becomes very important for making the prediction correct. CNN has the machinery to effectively capture medication correlations, hence works better on infrequent medications.

MLP achieves the worst F1 on 5 individual medications and the worse micro average F1. The reason is it only uses admission medications as inputs while the rest of methods also leverage other admission information such as past medical history and chief complaint. This indicates that the discharge medications are remarkably different from the admission medications and other types of information must be effectively leveraged to make accurate predictions. For all models, better F1 scores are achieved on medications with larger frequencies. This is reasonable since larger training data typically leads to better predictive performance in machine learning.


While CNN yields better performance than other strong baseline models, we discuss a few of its limitations. First of all, the gap between CNN’s performances on frequent and infrequent medication classes is still large, though it has been improved compared with the baselines. For example, the F1 scores achieved by CNN on two most frequent medications are 0.79 and 0.70 respectively, which are significantly better than those on infrequent medications such as atenolol and hctz. In future work, we plan to come up with methods to bridge this gap.

Another limitation of our method is that it is purely data-driven and does not incorporate human knowledge. In clinical practice, physicians refer to guidelines made by professional associations to prescribe medications. Such guidelines can be incorporated into the CNN model to further improve the prediction accuracy, which we plan to investigate in future.

In our current approach, only medical information is leveraged to predict the discharge medications. Non-clinical factors, such as insurance type, cost of medications, influence the prescription of medications as well, which should be incorporated in the prediction model.

The notes in MIMIC-III are highly noisy and our current pre-processing steps do not completely deal with these noises. For example, the heading strings (Table 1) used to identify different types of admission information are not exhaustive, which results in a lot of missing information. For the next step, we are going to manually deal with these corner cases and include them into the training set.


We find that it is possible to accurately predict discharge medications only using the information available at admission time. Such predictions can provide valuable information for physicians to perform treatment planning. On 8 medications, the CNN model achieves a (micro-averaged) precision of 0.63 for a recall of 0.70.

The CNN model outperforms the best baseline model for over 20% in terms of the macro-averaged F1-score. The performance gain is attributed to CNN’s two abilities that are not owned by the baseline methods. First, CNN is able to learn semantic representations of texts. We perform detailed visualizations of the individual model-components, including word embeddings, convolutional filters and dense layers. These visualizations show that the CNN model is able to distill semantics with different granularities from the raw texts. Second, CNN is able to capture the correlations among medications thanks to the mechanism of sharing common latent factors. This ability is the other major reason that CNN performs better than the baselines, especially on infrequent medications, where the captured correlation remedies the lack of training examples.

Although our solution is motivated from a specific task, it is potentially generic for other clinical predictive tasks. For example, by switching target label from medications to diseases, CNN can be used to aid comorbidity diagnosis.


Author contributions statement

P.X., C.C. and E.X. conceived the study. Y.Y., P.X. and E.X. designed the study. Y.Y. and P.X. wrote the main manuscript text. Y.Y. prepared all figures and tables. X.G. and C.C. helped writing the medical part of the manuscript. C.L. and H.Z. helped with model implementation and data preparation.

Additional Information

Competing Interests

The author(s) declare no competing financial interests.

Supplementary Information

Table 6 shows the standard deviations of medication-wise precision, recall and F1-score of all models in 5 runs.

Medication CNN MLP SVM RF LR
Metoprolol 0.02 0.03 0.01 0.02 0.04 0.01 0.01 0.01 0.00 0.00 0.01 0.00 0.01 0.01 0.01
Furosemide 0.01 0.03 0.01 0.10 0.18 0.05 0.01 0.02 0.01 0.01 0.01 0.01 0.01 0.02 0.02
Lisinopril 0.04 0.03 0.02 0.04 0.13 0.10 0.02 0.02 0.01 0.01 0.01 0.01 0.02 0.01 0.01
Amlodipine 0.09 0.13 0.09 0.23 0.16 0.19 0.02 0.03 0.03 0.04 0.03 0.03 0.06 0.02 0.03
Atenolol 0.10 0.14 0.14 0.00 0.00 0.00 0.03 0.01 0.00 0.06 0.01 0.02 0.08 0.01 0.01
Hctz 0.21 0.20 0.21 0.00 0.00 0.00 0.04 0.02 0.02 0.04 0.01 0.02 0.23 0.01 0.02
Diltiazem 0.05 0.06 0.06 0.00 0.00 0.00 0.09 0.05 0.06 0.18 0.05 0.07 0.14 0.02 0.03
Carvedilol 0.11 0.02 0.06 0.00 0.00 0.00 0.08 0.04 0.05 0.06 0.01 0.02 0.13 0.03 0.05
Table 6: Standard deviations of medication-wise precision (P), recall (R) and F1-score (F) for CNN and 4 baseline models averaged over 5 runs.
Comments 0
Request Comment
You are adding the first comment!
How to quickly get a good reply:
  • Give credit where it’s due by listing out the positive aspects of a paper before getting into which changes should be made.
  • Be specific in your critique, and provide supporting evidence with appropriate references to substantiate general statements.
  • Your comment should inspire ideas to flow and help the author improves the paper.

The better we are at sharing our knowledge with each other, the faster we move forward.
The feedback must be of minimum 40 characters and the title a minimum of 5 characters
Add comment
Loading ...
This is a comment super asjknd jkasnjk adsnkj
The feedback must be of minumum 40 characters
The feedback must be of minumum 40 characters

You are asking your first question!
How to quickly get a good answer:
  • Keep your question short and to the point
  • Check for grammar or spelling errors.
  • Phrase it like a question
Test description