Back to the doors
Local time—·

ML Development

One algorithm at a time, each on a real dataset: from cleaning and exploring the data to training, tuning and judging the model honestly against a baseline.

Regression · Healthcare

Insurance Cost Predictor

Linear Regression · medical insurance charges

Predicts a person's yearly medical insurance charges from age, BMI, smoking and region across 1,338 policies. With feature engineering, R² rose from 0.78 to 0.87 and the average error fell from $4,181 to $2,755.

  • scikit-learn
  • Feature engineering
  • R² · MAE · RMSE

Classification · History

Titanic Survival

Logistic Regression · 891 passengers

Predicts who survived the Titanic from class, sex, age and fare. Beats the always-“died” baseline of 61.5% with 79.3% test accuracy and a ROC-AUC of 0.85, then explores decision thresholds and regularisation.

  • Classification
  • Threshold tuning
  • ROC-AUC

Classification · Medical

Breast Cancer Diagnosis

k-Nearest Neighbours · 569 tumour samples

Classifies breast tumours as malignant or benign from 30 cell-nucleus measurements. A k-NN written from scratch matches scikit-learn at 95.6%; tuning k reaches a ROC-AUC of 0.97, and an experiment shows how noisy features hurt distance-based models.

  • Built from scratch
  • Hyperparameter tuning
  • Recall-focused

Classification · Medical

Diabetes Prediction

Decision Tree · 768 patients

Predicts diabetes from 8 clinical measurements. Shows how an unrestricted tree memorises its data (100% on training, 68% on test, 111 leaves), then prunes it with cross-validation to a small tree whose rules a doctor can read.

  • Overfitting
  • Pruning
  • Explainable rules

Classification · Business

Customer Churn

Random Forest · 7,043 telecom customers

Predicts which customers are about to leave. Builds a forest by hand from bootstrapped trees (78.5% accuracy, AUC 0.82, on par with scikit-learn), then tunes it to a cross-validated ROC-AUC of 0.85 and picks a threshold that catches more churners.

  • Bagging from scratch
  • Grid search
  • Imbalanced data

Classification · Computer vision

Handwritten Digit Recognition

Naive Bayes · 1,797 digit images

Recognises handwritten digits from 8×8 pixel images. Compares Gaussian, Multinomial and Bernoulli Naive Bayes, then adds PCA to lift accuracy from 82.9% to 94.9% on digits it has never seen.

  • Image classification
  • PCA
  • Model comparison

Classification · Food & drink

Wine Quality

Support Vector Machine · 1,599 red wines

Picks out the rare good wines (a taster score of 7 or more) from 11 chemical measurements. Shows why SVMs need scaling (F1 0.03 → 0.41), tunes C and gamma, then uses class weights and a chosen threshold to find 61% of the good wines instead of 33%, at a test ROC-AUC of 0.84.

  • RBF kernel
  • Class weights
  • Threshold tuning

Classification · Census

Income Prediction

Gradient Boosting · 32,561 census records

Predicts who earns more than $50K a year. Builds boosting from scratch to show small trees correcting each other's mistakes, then beats logistic regression and a random forest with 87% accuracy and a test ROC-AUC of 0.92, using early stopping, tuning and a check across groups.

  • Boosting from scratch
  • Early stopping
  • XGBoost

Clustering · Retail

Mall Customer Segments

K-Means · 200 shoppers

Groups mall customers by income and spending with no labels to learn from. A k-means written from scratch, the elbow method and silhouette scores settle on 5 segments (silhouette 0.555), each profiled and named, such as “high income, low spending”, and checked against three other clustering methods.

  • Unsupervised
  • Elbow & silhouette
  • Segmentation

Dimensionality reduction · Food & drink

Wine Cultivar Map

PCA · 178 wines, 13 measurements

Shrinks 13 chemical measurements into 2 that keep 55% of the variance and still separate the three grape cultivars on a flat map. A PCA written from scratch matches scikit-learn exactly, and a classifier on just 5 components reaches 97.8% against 98.3% with all 13 columns.

  • PCA from scratch
  • Scaling
  • Visualisation

Classification · Finance

Credit Card Default

Neural network · 30,000 card clients

Predicts which clients will miss next month's payment. A network written from scratch with backpropagation learns a curved boundary a straight line can't (94.7% against 84%); on the real data, scaling, a tuned 128-64-32 network and a chosen threshold catch 57% of defaulters at a test ROC-AUC of 0.77, matched in Keras.

  • Backprop from scratch
  • scikit-learn MLP
  • Keras