Skip to content

Repository files navigation

cdc_diabetes_prediction

Authors: Michael Eirikson, Raymond Wang, Alexander Wen

Summary

Basic data analysis on predicting diabetes based on health and lifestyle features following sound data scientific workflows as part of the main project for DSCI 522 (Data Science Workflows), a course in the Master of Data Science program at the University of British Columbia.

About

In this project we explored a decision tree model and naive bayes for predicting diabetes. After concluding that the decision tree is stronger in this context, we then utilized f2-score as our scoring function due to the context of our problem placing higher severity on false negatives rather than false positives for detecting diabetes.

We conclude that the decision tree model was the best performing of the models tested, correctly detected 8309 of 10604 positive cases (recall rate is about 78%). This result does come at a fairly significant cost in terms of false positives (precision rate is about 29%) with 20054 false positives. Depending on the actual cost of false positive this may need significant improvement to be a viable screening model.

The full report of our findings can be found here.

Dependencies

Usage

Setting up the Environment

  1. Clone this GitHub repo.
  2. Start Docker Desktop.
  3. In terminal navigate to the project root folder and run this command: docker compose up.
  4. In the terminal output for the above command look for a URL beginning with http://127.0.0.1:8888/lab?token=.
  5. Open the URL from step 4 in a browser.

Running the Analysis

Once the Jupyter Docker Image can be accessed, follow these steps to run the analysis.

  1. Open the terminal in the Jupyter environment.
  2. Navigate to the diabetes_prediction folder.
  3. Run the command make clean to remove residual files.
  4. Run the command make all to run all of the Python and Quarto scripts used to create the report.
  5. Navigate to reports/cdc_diabetes_prediction_report.pdf to view the report.

Closing

To safely close the docker container:

  1. In terminal press Crtl+C
  2. Once the container has stopped enter this terminal command to remove the container docker-compose rm type y to confirm

Known Issues

On some apple silicon machines there is an issue with the kernel in jupyterlabs. The kernel may hang when started or when restarted or if sklearn functions use n_jobs>1.

If these are issues try:

  • safely closing the container as described above
  • restart the contrainer as described above
  • don't click on anything except to navigate to the cdc_diabetes_prediction_report.ipynb notebook and click Run > Run All Cells

Updating the environment and docker image

To update the environment and docker image follow these steps

  1. Make sure you have a clean, current version of the envrionment by running
conda activate cdc_diabetes_prediction
conda env update --file environment.yml --prune
  1. Install any new libraries
    • If conda fails to resolve dependencies try updating environment.yml and removing version numbers.
    • Note python must remain v 3.11 python=3.11.6
    • Note this is risky, different library version may cause issues builing the docker image
conda install <package>
  1. Update environment.yml with
conda export --from-history > environment.yml
  1. Create new conda-linux-64.lock file
conda-lock -k explicit --file environment.yml -p linux-64
  1. Commit and push branch to remote repo.

    • The docker publish workflow will trigger and build and push a new docker image to DockerHub, then update the image tag in docker-compose.yml
    • Once the workflow is complete, pull the branch to locally get the updated docker-comose.yml file
  2. Launch the new container with

docker-compose up

Running test suite

To run the test suite start with by running docker compose up as above. Then run pytest in the project root directory. More details can be found in the tests directory.

References and Acknowledgements

The dataset utilized is the CDC Behavioural Risk Factor Surveillance System (BRFSS) 2015 Diabetes Health Indicators dataset (UCI ID 891), containing 253,680 survey responses with 21 health-related features and a binary diabetes outcome (0 = no diabetes/pre-diabetes, 1 = diabetes). A cleaned version of this dataset has been prepared by Alex Teboul and be accessed through Kaggle under the Diabetes Health Indicators Dataset. Lastly, our project makes use of the ucimlrepo library to access the dataset more easily, further documentation for this tool is located at https://github.com/uci-ml-repo/ucimlrepo.

The full list of references for the project can be found in the References section of the CDC Diabetes Prediction report

The CDC Diabetes Prediction report is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Licence and the software code in this repository is licensed under the MIT license For all usage/remixes of this project pease provide attribution and link to this webpage.

About

Basic data analysis on predicting diabetes based on health and lifestyle features following sound data scientific workflows as part of the main project for DSCI 522 (Data Science Workflows), a course in the Master of Data Science program at the University of British Columbia.

Resources

Code of conduct

Contributing

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages