Predicting disease risk from clinical data

Comparative machine learning frameworks for cardiovascular, metabolic, oncological and neurodevelopmental disease prediction. Independent projects, Jan to Mar 2026.

Live app and notebook

The interactive version of these projects: a multipage Streamlit app (Home, Diabetes, Breast cancer, Heart disease, Autism, Compare) plus the Colab notebook. This static page documents the analysis below; the app lets you rerun it with your own settings.

Live Streamlit app Diabetes Breast cancer Heart disease Autism Compare Open in Colab Notebook (.ipynb) GitHub repo

WhatLink
Live app (Streamlit Cloud)ml-healthcare-ai.streamlit.app
This website (GitHub Pages)harshini-suresha.github.io/ml-healthcare-app
Run notebook (Colab)Open in Colab
Notebook file (.ipynb)Download raw .ipynb · nbviewer preview
Repogithub.com/Harshini-Suresha/ml-healthcare-app

Run locally: pip install -r requirements.txt then streamlit run app.py. Multipage app: Home (app.py), shared code (ui_common.py, ml_core.py), pages in pages/ including the A-vs-B Compare diff view.

Projects at a glance

Each project follows the same path: exploratory data analysis, feature engineering, preprocessing, model development and quantitative evaluation.

Workflow map

Highlighted stage is the model. Stages follow each repository's description.

ProjectAreaApproachDataCode
Heart diseaseCardiovascularArtificial neural network (13-8-14-1), nonlinear classification303 patient records, 13 attributesHeart-disease
DiabetesMetabolicK-Nearest Neighbors, three-trial comparative studyKaggle diabetes dataset, 768 recordsDiabetes
Breast cancerOncologyKNN with cross-validated K versus tuned Logistic RegressionClinical diagnostic features, malignant vs benignBreast-Cancer-Prediction
Autism (ASD)NeurodevelopmentalLogistic Regression, XGBoost and SVM compared on a rebalanced dataset800 screening records, 22 columnsAutism-prediction

Diabetes: a three-trial KNN study

Same dataset every time. Each trial changed preprocessing, tuning or validation, so the accuracy change can be traced to a cause.

The dataset

768 patient records, 8 diagnostic features and a binary outcome. Zeros in five columns are not real measurements; they stand in for missing values.

FeatureMeaning
PregnanciesNumber of times pregnant
Glucose *Plasma glucose concentration
BloodPressure *Diastolic blood pressure (mm Hg)
SkinThickness *Triceps skin fold (mm)
Insulin *2-hour serum insulin (mu U/ml)
BMI *Body mass index (kg/m²)
DiabetesPedigreeFunctionGenetic likelihood of diabetes
AgeAge in years
Outcome1 diabetic, 0 non-diabetic

* a zero in this column means the value is missing.

Results by trial

Exploring the data: real statistics from the 768 records

Computed from the public copy of the dataset (768 rows, 9 columns). Pick a feature to update the histogram and box plot. Zeros in the five missing-as-zero columns are excluded from them.

Correlation matrix

Pearson r. Teal is positive, red is negative.

Correlation with Outcome

Zeros that mean missing

Share of 768 records. Insulin is missing for nearly half of them.

Explore the real records: scatter plot and live KNN

All 768 records. Pick two features, then click the plot to place a new patient. KNN votes among the k closest records. Records where a missing-as-zero feature is 0 are left out. Switch to standardized distances and watch the neighbours change: with raw units the feature with the larger numbers dominates.

● non-diabetic ● diabetic ◯ new patient

Raw versus standardized distances, measured on the real data

Leave-one-out KNN accuracy on all 768 records using all 8 features, shown below and recomputed live by the button. Each record is classified from the others. This uses no cleaning or train/test split, so it will not match the trial results below. Standardizing helps most at small k (for example k=3 and k=5); at larger k the two settle at about the same accuracy.

The trial journey, from your reported results

Test accuracy (axis starts at 60). Most of the gain came from scaling and outlier filtering in trial 2.

Train minus test accuracy, in points. A wider gap means more memorization.

Best k per trial against train (grey) and test (teal) accuracy. Smaller k fits the training data tighter.

What changed in each trial

The train-test gap grew from 18.4 to 20.2 to 24.8 points while test accuracy rose. Trial 3 uses k=1, which memorizes the training set (100% train accuracy), so the 75.2% test figure is the one that counts.

Pipeline code


  

Breast cancer: KNN versus a tuned Logistic Regression

Predicts malignant versus benign from clinical diagnostic features. The focus is on how preprocessing and model configuration change performance, with both models chosen by cross-validation instead of by hand.

Workflow

Preprocessing

  • Missing values found and replaced with the column mean
  • Features and target separated
  • StandardScaler so every feature contributes comparably
  • Separate hold-out set for testing

K-Nearest Neighbors

  • Euclidean distance, so scaling matters
  • K chosen by cross-validation, not guessed
  • Small K fits tightly, large K smooths: the bias-variance trade-off

Logistic Regression

  • Linear probabilistic classifier
  • GridSearchCV tries every parameter combination
  • RepeatedStratifiedKFold keeps class proportions in each fold and repeats the split

Evaluation

  • Accuracy
  • Precision
  • Recall
  • F1-score
  • Confusion matrix
  • Classification report

Educational implementation, not for clinical diagnosis.

Heart disease: an artificial neural network

A feedforward network that classifies heart disease from 13 clinical attributes. 303 patient records, 54.5% with the disease, no missing values.

Architecture

Two ReLU hidden layers and a sigmoid output. Adam optimizer, binary cross-entropy, batch size 8, 100 epochs. Inputs standardized, 70/30 split.

Training over 100 epochs

Training accuracy climbs from 49.7% to 92.1% and loss falls from 0.693 to 0.259.

Test results: 91 held-out patients

Accuracy85.7%Precision82.7%
Recall91.5%F1-score86.9%

Recall is the strongest score: 43 of 47 patients with the disease were caught, 4 missed.

Beyond the network

  • Random forest feature ranking puts oldpeak, cp, thalach, ca and thal on top.
  • GridSearchCV on a random forest picked 300 trees, max depth 10, min split 2.
  • 5-fold cross-validation of logistic regression averages 82.5% accuracy.
  • age
  • sex
  • cp
  • trestbps
  • chol
  • fbs
  • restecg
  • thalach
  • exang
  • oldpeak
  • slope
  • ca
  • thal
Correlation matrix of all attributes and the target, from the notebook.
Correlation matrix of all attributes and the target, from the notebook.
Random forest feature importance, from the notebook.
Random forest feature importance, from the notebook.

Training milestones

    Beyond accuracy: six scores from the confusion matrix

    Specificity (79.5%) is the weakest score: 9 healthy patients were flagged. The model leans toward catching disease.

    The patients: 303 records

    Box: middle half of patients, line: median, whiskers: min to max, each on its own scale.

    Figures from the notebook

    Autism spectrum disorder: screening-based classification

    800 records with ten screening-question scores plus demographic fields. About 20% are ASD-positive (161 of 800), so the data is heavily imbalanced and the evaluation accounts for it.

    Cleaning

    • Unknown ethnicity coded "?" (203 records) merged with "others"
    • yes/no turned into 1/0
    • 2 extreme result values removed (800 to 798)
    • ID, age_desc, used_app_before and austim dropped from the features

    Engineered features

    • sum_score: total of the ten screening scores
    • ageGroup: toddler, kid, teenager, young, senior
    • ind: autism, app-use and jaundice flags combined
    • Log transform of age to remove skew

    Training setup

    • 80/20 train-validation split
    • Random oversampling of the minority class on the training set only
    • StandardScaler fitted on the training data
    • Models: Logistic Regression, XGBoost, SVM (RBF)

    Model comparison

    ROC-AUC computed from predicted labels. XGBoost scores 1.00 on training data but 0.75 on validation, a clear sign of overfitting. SVM generalizes best (0.80); Logistic Regression has the smallest gap.

    Logistic Regression on 160 validation records

    Accuracy80.0%ASD recall75.0%
    ASD precision54.0%Missed9 of 36
    Cases by sum_score and ASD class. Higher screening totals mean a higher chance of ASD.
    Cases by sum_score and ASD class. Higher screening totals mean a higher chance of ASD.
    Cases by age group and ASD class, from the notebook.
    Cases by age group and ASD class, from the notebook.

    From 800 records to the training set

    ● no ASD ● ASD. Oversampling copies minority rows in the training set only, so the validation set stays untouched.

    How often each screening answer is 1

    Share of the 800 records scoring 1 on each question.

    Who is in the data

    Ethnicity, before merging "?" and "others"

    Who filled in the form

    Overfitting by model

    Training minus validation ROC-AUC. Smaller is better.

    Logistic Regression, six scores

    Figures from the notebook

    Findings and methods across the four projects

    Preparation beat tuning

    Diabetes. Scaling and outlier filtering lifted test accuracy 4.5 points (70.1% to 74.6%). Everything added in trial 3 gained 0.6 more, while the train-test gap widened to 24.8 points.

    Disease caught, some false alarms

    Heart. 85.7% accuracy and 91.5% recall on 91 held-out patients, with 4 cases missed. Final-epoch training accuracy of 92.1% is 6.3 points above test.

    Imbalance and overfitting

    Autism. Only 20% of records are ASD-positive. XGBoost scores 1.00 ROC-AUC on training data but 0.75 on validation; SVM generalizes best at 0.80.

    Selection by validation

    Breast cancer. K and the Logistic Regression settings are chosen with cross-validation and grid search instead of one lucky split.

    Methods side by side

    DiabetesBreast cancerHeartAutism
    ScalingStandardScaler, MinMaxScalerStandardScalerStandardScalerStandardScaler
    Missing valuesInf / NaN rows droppedMean imputationNone missing"?" recoded as Others
    OutliersFiltered, extremes removed––2 extreme results removed
    Class imbalanceClass balance checkedStratified foldsSMOTE exploredRandom oversampling
    Feature engineering–––Sum score, age group, log age
    ModelsKNNKNN, Logistic RegressionANN, plus RF, LR, SVM triedLR, XGBoost, SVM
    Tuning and validationk scan 1 to 14, 70/30 split over seedsCV for K, GridSearchCV, repeated stratified CVGridSearchCV (RF), 5-fold CV (LR)80/20 hold-out
    Reported scoresAccuracy, matrix, reportAccuracy, P, R, F1, matrix, reportAccuracy, P, R, F1, matrixROC-AUC, matrix

    How models are judged

    Predicted positivePredicted negative Has it
    TPcaught
    FNmissed
    Does not
    FPfalse alarm
    TNcorrectly cleared
    MetricFormulaWhat it answers
    Accuracy(TP + TN) / allHow often the model is right overall. Misleading when classes are unbalanced, as in the 500 / 268 diabetes data.
    PrecisionTP / (TP + FP)Of the patients flagged, how many truly have the condition.
    RecallTP / (TP + FN)Of the patients who have it, how many were caught. The key screening metric.
    F1-score2PR / (P + R)One number that balances precision and recall.
    Confusion matrixTP FP / FN TNWhere the errors fall, split by type.
    ROC-AUCarea under TPR vs FPRRanking quality across every decision threshold.

    Scores reported in the notebooks: accuracy, precision, recall and F1 (heart), ROC-AUC and a confusion matrix (autism), accuracy and a classification report (diabetes).

    Contact

    Questions about the projects, or want to collaborate?

    harshinisuresha7@gmail.comGitHub profile