• 1 min read

Diabetes Prediction

A Flask web app that predicts diabetes risk for women over 21 from eight health measurements, using a random forest.

Machine Learningscikit-learnFlaskHealthcareClassification

What it is

A team project to predict diabetes and pre-diabetes in women over 21. A user enters eight health measurements into a web form and a trained model returns a prediction.

The data has 768 patients with pregnancies, glucose, blood pressure, skin thickness, insulin, BMI, diabetes pedigree function and age. We replaced outliers with each column’s median, split the data into training and test sets, and compared seven models.

Results

Test set of 231 patients:

ModelAccuracyPrecision
Random forest81.8%91.1%
k-nearest neighbors78.8%93.2%
Logistic regression78.4%90.4%
Gaussian naive Bayes78.4%87.7%
Support vector machine77.1%94.5%
Decision tree67.5%78.8%
Neural network60.6%95.2%

The random forest was pickled and served through Flask, with a deploy config for Heroku. We also used LazyPredict to check a wider set of models quickly.

Back to top