Exploratory Data Analysis — A Machine Learning Approach to Predict Diabetic Patient Hospital Readmissions (contd..) — Part 7
By: Akshay Singh
Tags: Exploratory Data Analysis, Data Science

Exploratory Data Analysis — A Machine Learning Approach to Predict Diabetic Patient Hospital Readmissions (contd..) — Part 7

The EDA has been done through a mix of Tableau, Python Visualization libraries(matplotlib and seaborn) and MS Excel

Without further ado, let’s dive in. Our data set has 50 features. This would make our analysis pretty cumbersome and confusing if we don’t follow a structure. When introducing our data set (here), we had bucketed our features into different categories based on the aspect / type of information the feature was conveying, like patient identifiers, demographics, medical history, etc. We will be following the same category wise distribution of our features for exploring the variables.

The target variable: readmitted

In the data set, we have three levels of readmission: < 30, >30 & No Readmission

This makes it a multi-class classification problem. But, as envisaged in the problem statement, our aim is to predict less than 30-day readmissions. So, we will be combining the greater than 30 and NO readmission categories into a single class. This will essentially make it a binary classification problem.

‘>30’ and ‘NO’ readmission categories grouped as Class 0 and ‘< 30’ as Class 1; Readmission rate = 11.16%

Univariate Analysis of Predictor Variables — Pandas Profiling Library

For an initial understanding of the features present in our data set, we will use pandas-profiling library to understand the range of specific predictors, identifying each predictor’s type and compute the number or percentage of missing values for each predictor. Pandas-profiling enables users to quickly generate a very broad structured HTML file containing most of what we should know before deep diving into our EDA.

The overview part of the report provides us with the basic information — number of variables, number of variables, etc. It also outputs a list of warnings potentially indicating where to double-check the data and focus our cleaning efforts.

Pandas-Profiling Report

For our data set, we notice that pandas-profiling has indicated warnings against variables which have high cardinalities. We are also made aware of features such as citoglipton, examide which contain only one feature value in all the rows indicating absence of any predictive power of such features. Additionally, we notice that a few of our variables such as number_emergency, number_inpatient, number_outpatient have a large percentage of zero values.

Pandas-profiling also generates an EDA report for each specific variable including a small visualization describing the distribution of each variable. It also provides helpful indicators such as the percentage and number of missing values along with the descriptive statistics.

Let’s zoom in:

Patient identifiers — encounter_id, patient_nbr

encounter_id & patient_nbr

Patient demographics — Race, Gender, Age, Weight, payer_code

Race, Gender, Age, Weight, & payer_code

Admission and Discharge Details — admission_source_id, admission_type_id, discharge_disposition_id

admission_source_id, admission_type_id & discharge_disposition_id

Patient Medical History — number_outpatient, number_inpatient, number_emergency

number_outpatient, number_inpatient & number_emergency

Patient Admission Details — medical specialty, diag_1, diag_2, diag_3, time_in_hospital, number_diagnoses, num_lab_procedures, num_procedures, num_procedures, num_medications

medical_specialty & time_in_hospital

diag_1, diag_2 & diag_3

number_diagnoses, num_lab_procedures, num_procedures & num_medications

Clinical Results — max_glu_serum, A1Cresult

max_glu_serum & A1Cresult

Medication Details — Due to the large number of variables present in this category, only features of interest are reproduced here

Medication Details

Additionally, pandas-profiling also enables us to visualize other details of the features (by toggle details button) such as descriptive statistics, frequency, composition, etc. depending on the variable type. Let us use panda’s describe () function to achieve the same

Descriptive Statistics

Bivariate and Multivariate Analysis

Patient identifiers

We infer from the visualization that a patient can be admitted to the hospital more than once, which is identified by the unique encounter id for each admission.

patient_nbr & encounter_id

This in itself doesn’t convey much information. We should look at other features related to patient admission and discharge and see if there is any observable pattern. Other features related to patient admission / discharge can be identified as admission_source_id, admission_type_id, and discharge_disposition_id. Let us bring these features as well to the visualization.

Now, let’s put a filter on the Readmitted status to conclude any pattern for the cases of patients being readmitted within less than 30 days.

Eyeballing the resulting visualization, we note that, most of the cases of readmission are falling under admission_source_id = 7 (Emergency Room). For admission_type_id, majority of the patient records come from categories 1 (Emergency), 2 (Urgent) and 3 (Elective) and in that order. Most of the records have discharge_disposition_id as 1 (Discharged to home), followed by 18 (NULL), indicating records were not collected for these patients.

Patient demographics

Race: Majority of the population in the data set belongs to the ‘Caucasian’ Race followed by African American. The count of records per the readmitted status is also shown. We notice there is a category of ‘?’. We will deal with this in the Data Cleaning stage.

Race

Race Vs. Readmitted Status

Gender: The data is almost equally distributed among the two categories of Males and Females. Additionally, we can see some ‘Unknown / Invalid’ records, which will be taken care of in the Data Cleaning stage.

Gender Vs Readmitted Status

Age: Majority of the patient records belong to the category of 50+ years. Looking at the second figure below, we notice that the proportion of patients being readmitted within 30 days shows a gradual upward trend with the increase in age brackets. This is also corroborated by our analysis of research papers and background project.

Age Vs Readmitted Status

Weight: Almost 97% of the records in our data set have ‘?’ value. This means the weight data has not been collected for these patient records. This is a little disappointing as we had gauged from the background project that BMI (an indicator of weight) plays a crucial role in diabetes prediction. We might have to drop this feature in the data cleaning stage.

payer_code: Highest claim for the patients with readmitted status comes from those having Medicare (MC) as payer code. (11.75%). That means, of all the patients who have Medicare as their payer, 11.75% are being readmitted in less than 30 days. This is the highest among all the payer codes such as Blue Cross, Self-Pay, etc.

Payer Codes Vs Readmitted Status

Admission and Discharge details

admission_source_id: The percentage of patients being readmitted is highest for the Admission source id of 7 (Emergency Room), followed by 1 (Physician referral).

admission_source_id Vs Readmitted Status

admission_type_id: The percentage of patients being readmitted is highest for the Admission type id of 1 (Emergency), followed by 2 (Urgent) and 3 (Elective)

admission_type_id vs Readmitted Status

discharge_disposition_id: Due to a large number of categories present in this feature, there is no discernible trend observed.

discharge_disposition_id Vs Readmitted Status

Patient Medical History

number_outpatient: There is no discernible trend observed as the percentage of readmitted patients fluctuates between high and low values.

number_outpatient Vs Readmitted Status

number_inpatient: As the number of inpatient visits increase, there is an upward trend in percentage of patients being readmitted.

number_inpatient Vs Readmitted Status

number_emergency: No observable trend with respect to the number of patients being readmitted.

number_emergency Vs Readmitted Status

Clinical Results

A1Cresult: A1C levels are a strong indicator of Glucose in the body. We notice that for a majority of the records in our data set, the readings are marked as ‘None’. This is a let-down as we had concluded from our research and background project that this is a strong predictor of diabetes in patients. Though, we will look at this in the later stages and see if there is any way we could replace these records with a logical value for our analysis.

A1Cresult Vs Readmitted Status

max_glu_serum: Similar to A1Cresult, majority of the records in the data set have this value recorded as ‘None’.

max_glu_serum Vs Readmitted Status

Patient Admission Details

number_diagnoses: The line graph shows the proportion of re-admittance for across each bin. We infer that as the number of diagnoses increase in the range of 2 to 11, there is a higher risk of re-admittance.

number_diagnoses Vs Readmitted Status

num_lab_procedures: As the number of lab procedures increase in the range of 10 to 80, the proportion of patients belonging to the re-admitted category also increases.

num_lab_procedures Vs Readmitted Status

num_procedures: As the number of procedures / number of non-lab procedures increases, the proportion of patients belonging to the readmitted category decreases.

num_procedures Vs Readmitted Status

num_medications: As the number of distinct medications increase in the range of 0 through 35, the proportion of patients belonging to the readmitted class also increases.

num_medications Vs Readmitted Status

time_in_hospital: We know from the characteristics of the data set that all the patient records are for patients who stayed in the hospital between 1 and 14 days. Looking at the line graph, we notice that for number of days > 2, there is an upward trend for proportion of patients who are being readmitted within 30 days.

time_in_hospital Vs Readmitted Status

Medical_specialty: A large number of categories are present for this feature in the data set. Also, a majority % of the records are labeled as ‘?’, indicating absence of data. As for these reasons, this feature does not have much predictive power and we will most likely drop it in our later analysis.

medical_specialty Vs Readmitted Status

diag_1, diag_2 and diag_3: These are the primary, secondary and additional diagnosis, which are coded as first three digits of ICD9 having 848, 923 and 954 distinct values respectively. These features will need to be dealt with in a special way in the feature engineering stage. There would be no point constructing the visualizations of these features at this stage as they won’t reveal much information due to the level of granularity of the data.

Medication Details

DiabetesMed: Out of the total number of patients who were prescribed diabetes medication, 11.63% of the patients were readmitted within 30 days.

diabetesMed Vs Readmitted Status

24 features of medication: In itself, the features of medication don’t mean much as they only indicate whether the dosage was kept Steady / Up / Down or not prescribed at all. We will be deriving a new feature from all these 24 features in the Feature Engineering phase of our analysis.

This brings us to the end of our Exploratory Data Analysis phase. A few other visualizations we could have incorporated in our analysis could be box-plots, pair-plot using seaborn library. I did try these visualizations on my Jupyter notebook, but since there was not much additional information being added on top of the above visualizations, I decided not to include here.

In the next stage of our project, we will start with Data Pre-Processing steps.