Free course · Advanced · 9 parts · ~50 min

Machine Learning from Scratch

Nine models and methods — gradient descent to decision trees — every one implemented in pure numpy on real NBA data.

No scikit-learn. Nine tutorials that implement the core of applied machine learning — gradient descent, ridge and logistic regression, train/test discipline, cross-validation, ROC curves, k-NN, decision trees, k-means — from first principles, in numpy, against real basketball data.

The order is a genuine curriculum: each step uses machinery the previous one built. By the end you will have written, not imported, an entire introductory ML course — and you will know exactly what every library call you make afterwards is doing.

What you'll be able to do

  • Implement gradient descent and watch it land on the closed-form answer
  • Build logistic regression and evaluate it like a professional: splits, k-fold, ROC/AUC
  • Write k-NN, a decision tree and k-means clustering from bare numpy
  • Explain regularization by having implemented it
Download the course bundle - every script + dataset, one ZIP

The bundle contains each part's finished script, the shared helpers, and the sample data they read, with a README listing the run order - the whole course works offline.

The syllabus

Pace: Strictly sequential through part 6; the last three are siblings you can reorder. Give it three focused weeks.

  1. Gradient Descent From Scratch: How Models Actually LearnAdvanced · ~5 minThe engine under everything here: follow the gradient downhill.
  2. Ridge Regression From Scratch: Taming Collinear FeaturesAdvanced · ~5 minRegularization as a dial you implemented, not a checkbox you ticked.
  3. Logistic Regression From Scratch: Predicting a Win, Not a NumberAdvanced · ~7 minFrom predicting numbers to predicting wins - the sigmoid changes the game.
  4. Train/Test Split and the Confusion Matrix: Grading a Classifier HonestlyAdvanced · ~6 minThe discipline: never grade a model on the data that taught it.
  5. K-Fold Cross-Validation: A Score You Can TrustAdvanced · ~5 minOne split can lie; five folds lie less.
  6. ROC Curves and AUC From ScratchAdvanced · ~6 minThresholds are choices; ROC shows every one of them at once.
  7. k-Nearest Neighbors From ScratchAdvanced · ~6 minNo training at all - prediction by neighborhood vote.
  8. A Decision Tree From ScratchAdvanced · ~5 minInterpretable splits, built greedily - see exactly why it predicts.
  9. K-Means Clustering From Scratch: Find Team ArchetypesAdvanced · ~5 minNo labels needed: let the data cluster itself.

Check yourself

Five questions, graded on the page, nothing recorded anywhere - pick an answer and the explanation appears.

1. Gradient descent updates parameters by…

2. Ridge regression adds what to the loss?

3. Logistic regression outputs…

4. Why does test-set discipline exist?

5. An AUC of 0.5 means the model…

Where next: Randomness, Inference & Simulation.