Construction of various predictive models on a dataset of hospitalized heart failure patients
Explore the docs »
Report Bug
·
Request Feature
Table of Contents
In this project, I've applied machine learning methods to a dataset from hospitalized decompensated heart failure patients to construct predictive models. This dataset is provided by Zhang et al. on the PhysioNet website 1 and contains 168 features for 2008 patients. An additional dataset contains all the medications administered to these patients during their hospital stay. Originally, the data was used to predict if patients would be readmitted to the emergency department within 6 months after discharge.
Here, I've used the data to predict the duration of hospital stay using features that are expected to be available shortly after patient admission (clinical presentation, lab tests, and drug order). For this task, I've used three distinct methods:
- linear_regression_svm_random_forest_sklearn.ipynb: In this script, I've used non-neural network machine learning methods from scikit-learn, including regularized linear regressors, support vector machine regressors, random forest regressors, and a super ensemble of all these methods using a voting regressor.
- nn_pytorch.ipynb: In this script, I've used a TabularModel neural network structure using PyTorch to perform the prediction.
- nn_tensorflow_with_model_optimization.ipynb: In this script, I've used TensorFlow to build and optimize a neural network regressor. The optimization is performed in a step-by-step experimentation process and its results can be viewed using TensorBoard.
References:
Zhang, Z., Cao, L., Zhao, Y., Xu, Z., Chen, R., Lv, L., & Xu, P. (2022). Hospitalized patients with heart failure: integrating electronic healthcare records and external outcome data (version 1.3). PhysioNet. https://doi.org/10.13026/5m60-vs44
Zhang Z, Cao L, Chen R, Zhao Y, Lv L, Xu Z, Xu P. Electronic healthcare records and external outcome data for hospitalized patients with heart failure. Sci Data. 2021 Feb 5;8(1):46. doi: 10.1038/s41597-021-00835-9. PMID: 33547290; PMCID: PMC7865067
- Python v3.7.15
To access the data, you must sign up on the PhysioNet website and sign a Data Use Agreement to access the data files. After accessing the files, download the ZIP file.
- Upload the ZIP file to your Google Drive account.
- Replace the paths in the following lines to reflect the file location in your Drive:
drive.mount('/content/gdrive')
!unzip gdrive/MyDrive/databases/hospitalized-patients-with-heart-failure-integrating-electronic-healthcare-records-and-external-outcome-data-1.3.zip
patient_data = pd.read_csv('/content/hospitalized-patients-with-heart-failure-integrating-electronic-healthcare-records-and-external-outcome-data-1.3/dat.csv', index_col = 0) treatment_data = pd.read_csv('/content/hospitalized-patients-with-heart-failure-integrating-electronic-healthcare-records-and-external-outcome-data-1.3/dat_md.csv', index_col = 0) dict_data = pd.read_csv('/content/hospitalized-patients-with-heart-failure-integrating-electronic-healthcare-records-and-external-outcome-data-1.3/dataDictionary.csv', index_col = 0)
- Run the code. All dependencies (numpy, pandas, sklearn, seaborn) are preinstalled on Colab.
This project is an example of applying linear, support vector machine, random forest, and voting (linear + svm + random forest) regressors to predict a quantitaive measure of value from biomedical data.
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE.txt
for more information.
Amin Sadeghi - masadeghi6@gmail.com
Project Link: https://github.com/masadeghi/EHRsample