Decision Tree Classifier for Hospital Readmission Prediction
This lab focuses on implementing a Decision Tree Classifier using PySpark. The workflow includes necessary imports from Spark MLlib for machine learning. The dataset, Diabetes Readmit, consists of approximately records aimed at identifying diabetic patients at risk of hospital readmission within days, using the readmit flag as the target variable.
Data preprocessing includes splitting into training and testing sets, encoding categorical variables like RACE using a Spark ML Pipeline (String Indexer followed by One Hot Encoder). Key features for the model are time in hospital, number of procedures, and diabetes medication status, consolidated into a vector using the Vector Assembler.
The Decision Tree Classifier is set with a max depth of ; however, a depth of 30\text{%} to 50\text{%} of the number of variables is generally recommended to prevent overfitting. After training, model evaluation shows training accuracy at and testing accuracy at , indicating overfitting and a need for parameter optimization to improve model generalization.