Hand-rolled ML that refuses to call a library one-liner
This repo rebuilds popular ML algorithms from scratch in Python so you can see the matrix math that third-party library one-liners usually hide.

What it does
This repository is a collection of classic machine learning algorithms—linear and logistic regression, k-means clustering, anomaly detection, and multilayer perceptrons—implemented in plain Python. Each method ships with an interactive Jupyter Notebook demo that runs in the browser, letting you adjust training data and watch the predictions and charts update in real time. The math explanations are largely borrowed from Andrew Ng’s introductory course, so the pedagogy is familiar.
The interesting bit
The project is a deliberate exercise in pedagogy: it refuses to wrap third-party library one-liners and instead rebuilds each algorithm from scratch so you can trace the math step by step. Everything is explicitly labeled “homemade” and scoped for learning, not for shipping.
Key highlights
- Covers supervised, unsupervised, and basic neural-network topics with from-scratch Python code.
- Browser-based demos via Jupyter NBViewer and Binder mean you can experiment without installing anything locally.
- Each algorithm folder includes math theory, further reading links, and a reference implementation file.
- Includes datasets such as MNIST, Fashion MNIST, and Iris for immediate hands-on testing.
- Scope is strictly educational; the README warns against using any of this in production.
Caveats
- Explicitly not intended for production use; these are learning exercises, not optimized libraries.
Verdict
Ideal for students or developers who want to understand the mechanics behind predictions before trusting a library abstraction. Skip it if you need optimized, production-ready ML infrastructure.
Frequently asked
- What is trekhleb/homemade-machine-learning?
- This repo rebuilds popular ML algorithms from scratch in Python so you can see the matrix math that third-party library one-liners usually hide.
- Is homemade-machine-learning open source?
- Yes — trekhleb/homemade-machine-learning is open source, released under the MIT license.
- What language is homemade-machine-learning written in?
- trekhleb/homemade-machine-learning is primarily written in Jupyter Notebook.
- How popular is homemade-machine-learning?
- trekhleb/homemade-machine-learning has 24.7k stars on GitHub.
- Where can I find homemade-machine-learning?
- trekhleb/homemade-machine-learning is on GitHub at https://github.com/trekhleb/homemade-machine-learning.