Skip to content
0

Reducing hospital readmissions

πŸ“– Background

You work for a consulting company helping a hospital group better understand patient readmissions. The hospital gave you access to ten years of information on patients readmitted to the hospital after being discharged. The doctors want you to assess if initial diagnoses, number of procedures, or other variables could help them better understand the probability of readmission.

They want to focus follow-up calls and attention on those patients with a higher probability of readmission.

Your challenge Create a report that covers the following:

What is the most common primary diagnosis by age group? Some doctors believe diabetes might play a central role in readmission. Explore the effect of a diabetes diagnosis on readmission rates. On what groups of patients should the hospital focus their follow-up efforts to better monitor patients with a high probability of readmission?

πŸ’Ύ The data

You have access to ten years of patient information (source):

Information in the file
  • "age" - age bracket of the patient
  • "time_in_hospital" - days (from 1 to 14)
  • "n_procedures" - number of procedures performed during the hospital stay
  • "n_lab_procedures" - number of laboratory procedures performed during the hospital stay
  • "n_medications" - number of medications administered during the hospital stay
  • "n_outpatient" - number of outpatient visits in the year before a hospital stay
  • "n_inpatient" - number of inpatient visits in the year before the hospital stay
  • "n_emergency" - number of visits to the emergency room in the year before the hospital stay
  • "medical_specialty" - the specialty of the admitting physician
  • "diag_1" - primary diagnosis (Circulatory, Respiratory, Digestive, etc.)
  • "diag_2" - secondary diagnosis
  • "diag_3" - additional secondary diagnosis
  • "glucose_test" - whether the glucose serum came out as high (> 200), normal, or not performed
  • "A1Ctest" - whether the A1C level of the patient came out as high (> 7%), normal, or not performed
  • "change" - whether there was a change in the diabetes medication ('yes' or 'no')
  • "diabetes_med" - whether a diabetes medication was prescribed ('yes' or 'no')
  • "readmitted" - if the patient was readmitted at the hospital ('yes' or 'no')

Acknowledgments: Beata Strack, Jonathan P. DeShazo, Chris Gennings, Juan L. Olmo, Sebastian Ventura, Krzysztof J. Cios, and John N. Clore, "Impact of HbA1c Measurement on Hospital Readmission Rates: Analysis of 70,000 Clinical Database Patient Records," BioMed Research International, vol. 2014, Article ID 781670, 11 pages, 2014.

0. Preliminaries

# Import necessary libraries..
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
from patsy import dmatrices
import statsmodels.api as sm
from scipy.stats import ttest_ind
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import ConfusionMatrixDisplay, classification_report

1. Data Preprocessing

1.1. Load and Inspect Data

# Load hospital readmissions data..
df = pd.read_csv('data/hospital_readmissions.csv')
df.columns = df.columns.str.capitalize() # Capitalize column/variable names..
# Check the first and last 5 rows..
display(df[:5])
df[-5:]
# See info about the data..
df.info()

We note that our data has 7 numeric (i.e. continuous) and 10 categorical variables.

# See summary statistics for for numeric columns of our data..
df.describe()
# Check for missing (i.e. NaN) values..
df.isna().sum() # Luckily we have no missing values πŸ˜€
# Let's also check for duplicated rows in df..
df.duplicated().sum() # Luckily we have no duplicated values either πŸ˜€

1.2 Visualize Data

β€Œ
β€Œ
β€Œ