Authors: Michael Eirikson, Raymond Wang, Alexander Wen
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.
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.
- Clone this GitHub repo.
- Start Docker Desktop.
- In terminal navigate to the project root folder and run this command:
docker compose up. - In the terminal output for the above command look for a URL beginning with
http://127.0.0.1:8888/lab?token=. - Open the URL from step 4 in a browser.
Once the Jupyter Docker Image can be accessed, follow these steps to run the analysis.
- Open the terminal in the Jupyter environment.
- Navigate to the
diabetes_predictionfolder. - Run the command
make cleanto remove residual files. - Run the command
make allto run all of the Python and Quarto scripts used to create the report. - Navigate to
reports/cdc_diabetes_prediction_report.pdfto view the report.
To safely close the docker container:
- In terminal press
Crtl+C - Once the container has stopped enter this terminal command to remove the container
docker-compose rmtypeyto confirm
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.ipynbnotebook and click Run > Run All Cells
To update the environment and docker image follow these steps
- 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- Install any new libraries
- If conda fails to resolve dependencies try updating
environment.ymland 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
- If conda fails to resolve dependencies try updating
conda install <package>- Update
environment.ymlwith
conda export --from-history > environment.yml- Create new
conda-linux-64.lockfile
conda-lock -k explicit --file environment.yml -p linux-64-
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.ymlfile
- The docker publish workflow will trigger and build and push a new docker image to DockerHub, then update the image tag in
-
Launch the new container with
docker-compose upTo 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.
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.