DiabPredict — Diabetes Risk Prediction

PythonPandasScikit-learnMatplotlibJupyter Notebook· 2 min read

A supervised machine learning project that predicts diabetes risk from standard health indicators (glucose level, BMI, age, blood pressure, and similar features), built as an exploratory-to-production pipeline: data exploration, feature engineering, model training, and an interactive results view.

The problem & constraints

Diabetes risk prediction is a well-studied classification problem, but the real work is in the details that determine whether a model is trustworthy: handling imbalanced classes (far fewer positive cases than negative in typical datasets), avoiding features that leak the label, and presenting results in a way a non-technical reader could still sanity-check.

Approach

  • Exploratory data analysis to understand feature distributions and correlations before touching any model.
  • Feature engineering on the raw health indicators to improve signal (handling missing/invalid values, scaling, and derived features).
  • Trained and compared multiple supervised classifiers using Scikit-learn, evaluating with metrics appropriate for an imbalanced medical dataset (not just raw accuracy).
  • Built an interactive visualization layer for results: ROC curve and confusion matrix, so model performance is inspectable rather than a single opaque score.

Trade-offs made

Decision

Interpretable, well-understood classifiers over a black-box ensemble: for a health-risk use case, being able to reason about why the model flags a case as high-risk mattered more than squeezing out marginal accuracy gains from a harder-to-interpret model.

Decision

ROC/confusion-matrix visualization over a single accuracy number: accuracy alone is misleading on imbalanced medical data; showing the full confusion matrix and ROC curve makes the model's actual trade-off between false positives and false negatives visible.

That trade-off is easier to feel than to read about. The threshold below is exactly the decision the callout above describes — move it and watch what each choice costs:

0.50
ROC curve · AUC 0.83 — false-alarm rate across the bottom, recall up the side; the dot is your threshold.
Confusion matrix at the current decision threshold.
FlaggedNot flagged
Diabetic72caught68missed
Not diabetic24false alarms236correctly cleared
77%Accuracy
51%Recall
75%Precision

At this threshold: 68 real cases missed, 24 false alarms.

Score one patient with the same model

Predicted risk 69%. Flagged for follow-up at this threshold.

Simulation — a cohort of 400 synthetic cases (35% diabetic), generated in your browser from a declared logistic model. The matrix, the curve and the metrics are computed live from it; none of them is a result measured on the original project's model.

Results

Delivered a working classification pipeline with an interactive dashboard for inspecting model performance (ROC curve, confusion matrix) rather than a single summary metric — the emphasis was on making results auditable, not just producing a number.

What I'd do differently

Add cross-validation with stratified folds from the start (rather than a single train/test split) to get a more reliable performance estimate on an imbalanced dataset, and compare against a calibrated probability output instead of raw class predictions.