And an (obvious) upfront disclaimer: This is a learning project. This is not for actual use.
DAD is a database consisting of patient demographics, comorbidities, interventions and the length of stay for the de-identified 10% sample of hospital admissions. DAD (2014-15) has an enhanced dataset with variables that were created at Western to act as flags for ICD-10 and CCI groupings, to make using the file easier.
Here is an experiment with the DAD enhanced dataset to create a Random forest model for predicting the total length of hospital stay (TLOS) in less than 100 lines of code. Random forests are an ensemble classifier, that operates by building multiple decision trees at training time and outputting the class that is the mode of the classes (classification) or mean prediction (regression) of the individual trees. This is a learning project for Apache Spark and Spark ML using pyspark. The accuracy of the model taking all derived categorical variables is low.
I have access to Apache Spark @ CC. If you are installing Spark in your computer you may have to change the following:
SparkContext.setSystemProperty('spark.executor.memory', '48g') SparkContext.setSystemProperty('spark.driver.memory', '6g')
Some of the commonly tweaked parameters can be changed here:
RF_NUM_TREES = 3 RF_MAX_DEPTH = 4 RF_MAX_BINS = 12
Uncomment the following line to include only variables that you need.
# df.select([c for c in df.columns if c in ['TLOS_CAT', 'COLNAME', 'COLNAME']]).show()
Parts of this material are based on the Canadian Institute for Health Information Discharge Abstract Database Research Analytic Files (sampled from fiscal years 2014-15). However, the analysis, conclusions, opinions and statements expressed herein are those of the author(s) and not those of the Canadian Institute for Health Information.
- Kedro for multimodal machine learning in healthcare - January 25, 2023
- Using OpenFaaS containers in Kubeflow - December 14, 2022
- Six things data scientists in healthcare should know - November 3, 2021