
ML-From-Scratch
Plain Python and NumPy code that implements classic machine learning models so you can read how they work.
- Stars
- 33.3k
- Forks
- 5.5k
- Licence
- MIT
- Language
- Python
- Last update
- 3.1 years ago
- Type
- Learning resource
No commits in over a year — check for forks or alternatives before adopting.
What it is
This project contains simple, from-scratch Python implementations of fundamental machine learning models and algorithms, built on NumPy. Its stated purpose is not speed or optimization but showing the inner workings of each method in a transparent, accessible way. The README says it aims to cover topics from linear regression to deep learning, and it includes runnable examples such as polynomial regression, a CNN digit classifier, DBSCAN clustering, and a GAN.
- Run the polynomial regression example to watch a model fit temperature data
- Run the DBSCAN example to see density-based clustering on the moons dataset
- Run the genetic algorithm example to see a target string evolved from random candidates
- Read the CNN or DQN code to understand how layers and reinforcement learning agents are built
Great for
- Students who want to see how algorithms like regression or neural networks work internally
- Developers who learn better by reading code than by calling a library
- People studying machine learning who want to step through the math in code
- Teachers preparing examples that show algorithm internals
Not ideal for
- Production systems that need speed or scale, because the README says efficiency is not the goal
- People who only want a ready-made library to call with minimal code
- Beginners with no Python experience, since the examples assume some comfort with the language and ML concepts
How to get it
- 1
Clone and build from source
You'll need: Python · Git
Clone the repository
git clone https://github.com/eriklindernoren/ML-From-ScratchEnter the project folder
cd ML-From-ScratchInstall the package
python setup.py install - 2
Run it
- Clone the repository and change into its folder
- Run the install command from the README
- Run an example such as python mlfromscratch/examples/polynomial_regression.py
- Read the matching source file under mlfromscratch to see how the model is implemented
- 3
Get the most out of it
- Start with the polynomial regression example, since it is the first one in the README and is the simplest to follow
- Compare the printed layer tables in the CNN and GAN examples with the code that builds them
- Modify the genetic algorithm target string parameter to see how the search behaves
- Use the examples as a reference when reading the Implementations section of the README
Downloads
Strengths
- Written in plain Python and NumPy, so the logic is visible rather than hidden in a framework
- Includes several runnable examples with printed model summaries and training output
- Released under the MIT license
Trade-offs
- The README states it is not designed for optimized or efficient computation
- The README excerpt provided gives limited detail on installation requirements and which parts are complete
- Last push in the metadata is October 2023, so it may not reflect recent changes
How it compares
| Project | Stars | Type | Level | Updated | Best for |
|---|---|---|---|---|---|
| ML-From-Scratch (this) | 33.3k | Learning resource | beginner | 3.1 years ago | Students who want to see how algorithms like regression or neural networks work internally |
| mit-deep-learning | 10.5k | Learning resource | beginner | 2.8 years ago | Students following MIT deep learning courses |
| awesome-datascience | 30.3k | Curated list | beginner | 6 days ago | Beginners who want a guided set of links to start learning data science |
| Made-With-ML | 49.9k | Learning resource | intermediate | 8 months ago | Software engineers who want to learn how ML models get deployed and maintained |
| python-machine-learning-book | 12.7k | Learning resource | beginner | 4 months ago | Readers who own the 1st edition and want to run its code |
| AI-Expert-Roadmap | 31.3k | Learning resource | beginner | 1.2 years ago | Beginners who are unsure what to learn next in AI or data science |
Stats synced from GitHub. The assessment above was drafted with AI from the project's README on 2026-10-29 and may miss recent changes — check the README before relying on a command. MIT licence: free to use, modify and distribute, including commercially, as long as you keep the copyright notice.