masadeghi / EHRsample

Prediction of hospital stay duration in heart failure patients using machine learning.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Contributors Forks Stargazers Issues MIT License LinkedIn

Machine Learning Analysis of Structured Electronic Health Record Data

Construction of various predictive models on a dataset of hospitalized heart failure patients
Explore the docs »

Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Contributing
  5. License
  6. Contact

About The Project

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

(back to top)

Built With

  • Python v3.7.15

(back to top)

Getting Started

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.

Installation

  1. Upload the ZIP file to your Google Drive account.
  2. 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)
  3. Run the code. All dependencies (numpy, pandas, sklearn, seaborn) are preinstalled on Colab.

(back to top)

Usage

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.

(back to top)

Contributing

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!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Contact

Amin Sadeghi - masadeghi6@gmail.com

Project Link: https://github.com/masadeghi/EHRsample

(back to top)

About

Prediction of hospital stay duration in heart failure patients using machine learning.

License:MIT License


Languages

Language:Jupyter Notebook 100.0%