AI in Medicine — Summer Course 2026
Conventional
Machine Learning
Build, evaluate, and interpret ML models for biomedical data —
from logistic regression to random forests in one session
28 July 2026
9:00–12:15
Google Colab
🧑💻
Your Instructor
Koay Hong Vin
Education
B.Eng. Electrical Engineering
PhD in Artificial Intelligence — Autonomous Vehicles
B.Eng. Electrical Engineering
PhD in Artificial Intelligence — Autonomous Vehicles
Current
Risk Modelling and Data Scientist
Ant International
Risk Modelling and Data Scientist
Ant International
01 / Concept
What is Machine Learning?
- Algorithms that learn from data — instead of being explicitly programmed with rules
- Classification — predict a category (malignant vs benign tumor)
- Regression — predict a number (disease progression score)
- Supervised learning — we have labeled examples to learn from. Both classification and regression are supervised.
- The golden rule — never evaluate on training data. Always hold out a test set.
02 / scikit-learn
scikit-learn — The ML Workhorse
- One API pattern — every model follows fit() → predict()
- Dozens of algorithms — logistic regression, decision trees, random forests, SVM, k-NN
- Built-in evaluation — accuracy, precision, recall, ROC curves, confusion matrices
- Preprocessing tools — scaling, encoding, imputation, feature selection
# The 4-step recipe
from sklearn import SomeModel
model = SomeModel()
model.fit(X_train, y_train)
preds = model.predict(X_test)
from sklearn import SomeModel
model = SomeModel()
model.fit(X_train, y_train)
preds = model.predict(X_test)
03 / Classification
Logistic Regression — Your First Model
- Despite the name — logistic regression is a classification algorithm
- Outputs a probability — "89% chance this tumor is malignant"
- Fast, interpretable, and often excellent — always try it first
- Dataset: Breast Cancer Wisconsin — 569 samples, 30 cell-nuclei features → predict malignant vs benign
04 / Evaluation
Is Our Model Any Good?
🎯
Confusion Matrix
Shows exactly where errors happen. False negatives (missed cancers) vs false positives (false alarms).
📈
ROC Curve & AUC
Tradeoff between sensitivity and specificity at every threshold. AUC = 1.0 is perfect; 0.5 is random.
⚖️
Precision & Recall
Precision: of predicted positives, how many are real?
Recall: of real positives, how many did we catch?
Recall: of real positives, how many did we catch?
🔬
Clinical Context
In cancer screening, recall > precision. Missing a cancer (false negative) is far worse than a false alarm.
05 / Overfitting
Overfitting vs Underfitting
📉
Underfitting
Model is too simple. Misses real patterns in the data. High bias, poor performance on both train and test sets.
🎯
Just Right
Model captures genuine patterns without memorizing noise. Good generalization — performs well on unseen data.
⚠️
Overfitting
Model is too complex. Memorizes training data including noise. Great on training, terrible on test. The most common ML mistake.
💊
In Medicine
An overfit model might learn that "patients with ID #47 all have cancer" — a coincidence, not a pattern. Devastating in clinical use.
06 / Trees
Decision Trees & Random Forest
- Decision Tree — flowchart-like model. Splits data by asking yes/no questions about features. Fully interpretable.
- Random Forest — an ensemble of 100+ decision trees, each trained on a random subset. Averages predictions → more robust.
- Feature importance — random forests tell you which features matter most. Vital for biomedical insight.
from sklearn.ensemble import RandomForestClassifier
rf = RandomForestClassifier(
n_estimators=100,
max_depth=5
)
rf.fit(X_train, y_train)
# Which features matter?
rf.feature_importances_
rf = RandomForestClassifier(
n_estimators=100,
max_depth=5
)
rf.fit(X_train, y_train)
# Which features matter?
rf.feature_importances_
07 / Validation
Cross-Validation — Trust but Verify
- One split isn't enough — a single train/test split can be lucky (or unlucky). Cross-validation fixes this.
- K-fold CV — split data into K parts. Train on K-1, test on 1. Repeat K times. Average the scores.
- Typical K = 5 or 10 — gives a robust estimate of real-world performance.
- In medicine — always report CV scores, not just one split. It shows whether your model is stable.
from sklearn.model_selection import cross_val_score
rf = RandomForestClassifier()
scores = cross_val_score(
rf, X, y, cv=5
)
# 5 scores, one per fold
scores # eg [0.96, 0.98, 0.95, ...]
scores.mean() # robust estimate
rf = RandomForestClassifier()
scores = cross_val_score(
rf, X, y, cv=5
)
# 5 scores, one per fold
scores # eg [0.96, 0.98, 0.95, ...]
scores.mean() # robust estimate
08 / Regression
Linear Regression — Predict a Number
- Dataset: Diabetes — 442 patients, 10 baseline variables → predict disease progression after 1 year
- R² (R-squared) — what fraction of variance does your model explain? 0 = useless, 1 = perfect
- Coefficients — each feature has a weight. Positive = increases prediction, negative = decreases it
- Clinical insight — BMI and blood pressure are the strongest predictors. This matches clinical knowledge → builds trust.
09 / Datasets
Our Biomedical Datasets
🔬
Breast Cancer Wisconsin
569 samples, 30 features from cell nuclei images. Predict malignant vs benign. The classic biomedical ML benchmark.
💉
Diabetes Dataset
442 patients, 10 baseline variables (BMI, BP, blood serum). Predict disease progression 1 year later. Real clinical data.
📦
Built into scikit-learn
Both datasets come pre-installed with scikit-learn. One line of code loads them — no downloading, no cleaning needed.
🏥
Why These Matter
These are the same datasets used in ML textbooks and research papers worldwide. You're learning on real, published data.
10 / Insight
Model Interpretation & Common Pitfalls
- Feature importance — random forests tell you which biomarkers matter most. This is often more valuable than the prediction itself.
- Coefficients — in logistic/linear regression, each coefficient says: "for every 1-unit increase in X, outcome changes by Y"
- Data leakage — accidentally using future information to predict the past. Example: scaling BEFORE splitting.
- Class imbalance — 99% benign, 1% malignant? A model that says "always benign" gets 99% accuracy but is clinically useless.
- Correlation ≠ causation — the model found that ice cream sales predict drownings. Doesn't mean ice cream causes drowning.
- Always ask: Would I trust this model with a patient's life? If not, what would make you trust it?
11 / Setup
How We'll Work
🌐
Google Colab
No installation. scikit-learn, NumPy, Pandas, and Matplotlib all pre-installed. Runs in your browser.
⌨️
Code-Along
I'll type, you follow. Every cell runs. You'll see models train in real time and predictions appear immediately.
✏️
Exercises
Build your own models. Compare algorithms. Decide which model you'd trust in a clinical setting.
💬
Ask Anytime
ML has jargon — if a term doesn't make sense, ask. Chances are others have the same question.
12 / Recap
The ML Pipeline
Split
Train/test before anything else
Fit
model.fit(X_train, y_train)
Evaluate
Confusion matrix, ROC, precision, recall
"Every ML pipeline is the same: split → fit → predict → evaluate. Master this pattern and you can use any algorithm."
🤖
Let's Build Models!
Open your notebook. Time to train your first classifier.