@techNmak: I want to highlight a resource that I think is genuinely valuable for anyone learning machine learning: ML-From-Scratch…
Summary
A GitHub repository implementing fundamental machine learning algorithms from scratch using plain NumPy, designed to help learners understand the inner workings of algorithms by focusing on clarity over performance. It covers supervised, unsupervised, deep learning, and reinforcement learning topics.
View Cached Full Text
Cached at: 07/12/26, 12:54 PM
I want to highlight a resource that I think is genuinely valuable for anyone learning machine learning: ML-From-Scratch.
Most of us learn ML by using libraries like scikit-learn or PyTorch, which is the right way to build things quickly, but it can leave gaps in understanding why an algorithm works. This repository takes the opposite approach => every algorithm is implemented in plain NumPy, prioritizing clarity over performance, so you can trace the underlying math directly.
It covers a wide range of the curriculum you’d expect to see in an ML course - linear and logistic regression, decision trees, random forest, gradient boosting, XGBoost, SVM, and naive bayes on the supervised side; k-means, DBSCAN, PCA, and Gaussian mixture models on the unsupervised side. It also goes further, with a small deep learning framework (convolutional, pooling, batch normalization, dropout, and RNN layers), a working GAN, and a Deep Q-Network trained on CartPole-v1.
If you’ve completed a course on these algorithms and want to solidify your understanding by reading working implementations end to end, I’d recommend spending time with this repository.
It’s a good complement to theory => 32k stars, MIT licensed, and entirely in Python.
Here’s the GitHub Repo: http://github.com/eriklindernoren/ML-From-Scratch…
eriklindernoren/ML-From-Scratch
Source: https://github.com/eriklindernoren/ML-From-Scratch
Machine Learning From Scratch
About
Python implementations of some of the fundamental Machine Learning models and algorithms from scratch.
The purpose of this project is not to produce as optimized and computationally efficient algorithms as possible but rather to present the inner workings of them in a transparent and accessible way.
Table of Contents
Installation
$ git clone https://github.com/eriklindernoren/ML-From-Scratch
$ cd ML-From-Scratch
$ python setup.py install
Examples
Polynomial Regression
$ python mlfromscratch/examples/polynomial_regression.py
Figure: Training progress of a regularized polynomial regression model fitting
temperature data measured in Linköping, Sweden 2016.
Classification With CNN
$ python mlfromscratch/examples/convolutional_neural_network.py
+---------+
| ConvNet |
+---------+
Input Shape: (1, 8, 8)
+----------------------+------------+--------------+
| Layer Type | Parameters | Output Shape |
+----------------------+------------+--------------+
| Conv2D | 160 | (16, 8, 8) |
| Activation (ReLU) | 0 | (16, 8, 8) |
| Dropout | 0 | (16, 8, 8) |
| BatchNormalization | 2048 | (16, 8, 8) |
| Conv2D | 4640 | (32, 8, 8) |
| Activation (ReLU) | 0 | (32, 8, 8) |
| Dropout | 0 | (32, 8, 8) |
| BatchNormalization | 4096 | (32, 8, 8) |
| Flatten | 0 | (2048,) |
| Dense | 524544 | (256,) |
| Activation (ReLU) | 0 | (256,) |
| Dropout | 0 | (256,) |
| BatchNormalization | 512 | (256,) |
| Dense | 2570 | (10,) |
| Activation (Softmax) | 0 | (10,) |
+----------------------+------------+--------------+
Total Parameters: 538570
Training: 100% [------------------------------------------------------------------------] Time: 0:01:55
Accuracy: 0.987465181058
Figure: Classification of the digit dataset using CNN.
Density-Based Clustering
$ python mlfromscratch/examples/dbscan.py
Figure: Clustering of the moons dataset using DBSCAN.
Generating Handwritten Digits
$ python mlfromscratch/unsupervised_learning/generative_adversarial_network.py
+-----------+
| Generator |
+-----------+
Input Shape: (100,)
+------------------------+------------+--------------+
| Layer Type | Parameters | Output Shape |
+------------------------+------------+--------------+
| Dense | 25856 | (256,) |
| Activation (LeakyReLU) | 0 | (256,) |
| BatchNormalization | 512 | (256,) |
| Dense | 131584 | (512,) |
| Activation (LeakyReLU) | 0 | (512,) |
| BatchNormalization | 1024 | (512,) |
| Dense | 525312 | (1024,) |
| Activation (LeakyReLU) | 0 | (1024,) |
| BatchNormalization | 2048 | (1024,) |
| Dense | 803600 | (784,) |
| Activation (TanH) | 0 | (784,) |
+------------------------+------------+--------------+
Total Parameters: 1489936
+---------------+
| Discriminator |
+---------------+
Input Shape: (784,)
+------------------------+------------+--------------+
| Layer Type | Parameters | Output Shape |
+------------------------+------------+--------------+
| Dense | 401920 | (512,) |
| Activation (LeakyReLU) | 0 | (512,) |
| Dropout | 0 | (512,) |
| Dense | 131328 | (256,) |
| Activation (LeakyReLU) | 0 | (256,) |
| Dropout | 0 | (256,) |
| Dense | 514 | (2,) |
| Activation (Softmax) | 0 | (2,) |
+------------------------+------------+--------------+
Total Parameters: 533762
Figure: Training progress of a Generative Adversarial Network generating
handwritten digits.
Deep Reinforcement Learning
$ python mlfromscratch/examples/deep_q_network.py
+----------------+
| Deep Q-Network |
+----------------+
Input Shape: (4,)
+-------------------+------------+--------------+
| Layer Type | Parameters | Output Shape |
+-------------------+------------+--------------+
| Dense | 320 | (64,) |
| Activation (ReLU) | 0 | (64,) |
| Dense | 130 | (2,) |
+-------------------+------------+--------------+
Total Parameters: 450
Figure: Deep Q-Network solution to the CartPole-v1 environment in OpenAI gym.
Image Reconstruction With RBM
$ python mlfromscratch/examples/restricted_boltzmann_machine.py
Figure: Shows how the network gets better during training at reconstructing
the digit 2 in the MNIST dataset.
Evolutionary Evolved Neural Network
$ python mlfromscratch/examples/neuroevolution.py
+---------------+
| Model Summary |
+---------------+
Input Shape: (64,)
+----------------------+------------+--------------+
| Layer Type | Parameters | Output Shape |
+----------------------+------------+--------------+
| Dense | 1040 | (16,) |
| Activation (ReLU) | 0 | (16,) |
| Dense | 170 | (10,) |
| Activation (Softmax) | 0 | (10,) |
+----------------------+------------+--------------+
Total Parameters: 1210
Population Size: 100
Generations: 3000
Mutation Rate: 0.01
[0 Best Individual - Fitness: 3.08301, Accuracy: 10.5%]
[1 Best Individual - Fitness: 3.08746, Accuracy: 12.0%]
...
[2999 Best Individual - Fitness: 94.08513, Accuracy: 98.5%]
Test set accuracy: 96.7%
Figure: Classification of the digit dataset by a neural network which has
been evolutionary evolved.
Genetic Algorithm
$ python mlfromscratch/examples/genetic_algorithm.py
+--------+
| GA |
+--------+
Description: Implementation of a Genetic Algorithm which aims to produce
the user specified target string. This implementation calculates each
candidate's fitness based on the alphabetical distance between the candidate
and the target. A candidate is selected as a parent with probabilities proportional
to the candidate's fitness. Reproduction is implemented as a single-point
crossover between pairs of parents. Mutation is done by randomly assigning
new characters with uniform probability.
Parameters
----------
Target String: 'Genetic Algorithm'
Population Size: 100
Mutation Rate: 0.05
[0 Closest Candidate: 'CJqlJguPlqzvpoJmb', Fitness: 0.00]
[1 Closest Candidate: 'MCxZxdr nlfiwwGEk', Fitness: 0.01]
[2 Closest Candidate: 'MCxZxdm nlfiwwGcx', Fitness: 0.01]
[3 Closest Candidate: 'SmdsAklMHn kBIwKn', Fitness: 0.01]
[4 Closest Candidate: ' lotneaJOasWfu Z', Fitness: 0.01]
...
[292 Closest Candidate: 'GeneticaAlgorithm', Fitness: 1.00]
[293 Closest Candidate: 'GeneticaAlgorithm', Fitness: 1.00]
[294 Answer: 'Genetic Algorithm']
Association Analysis
$ python mlfromscratch/examples/apriori.py
+-------------+
| Apriori |
+-------------+
Minimum Support: 0.25
Minimum Confidence: 0.8
Transactions:
[1, 2, 3, 4]
[1, 2, 4]
[1, 2]
[2, 3, 4]
[2, 3]
[3, 4]
[2, 4]
Frequent Itemsets:
[1, 2, 3, 4, [1, 2], [1, 4], [2, 3], [2, 4], [3, 4], [1, 2, 4], [2, 3, 4]]
Rules:
1 -> 2 (support: 0.43, confidence: 1.0)
4 -> 2 (support: 0.57, confidence: 0.8)
[1, 4] -> 2 (support: 0.29, confidence: 1.0)
Implementations
Supervised Learning
- Adaboost
- Bayesian Regression
- Decision Tree
- Elastic Net
- Gradient Boosting
- K Nearest Neighbors
- Lasso Regression
- Linear Discriminant Analysis
- Linear Regression
- Logistic Regression
- Multi-class Linear Discriminant Analysis
- Multilayer Perceptron
- Naive Bayes
- Neuroevolution
- Particle Swarm Optimization of Neural Network
- Perceptron
- Polynomial Regression
- Random Forest
- Ridge Regression
- Support Vector Machine
- XGBoost
Unsupervised Learning
- Apriori
- Autoencoder
- DBSCAN
- FP-Growth
- Gaussian Mixture Model
- Generative Adversarial Network
- Genetic Algorithm
- K-Means
- Partitioning Around Medoids
- Principal Component Analysis
- Restricted Boltzmann Machine
Reinforcement Learning
Deep Learning
- Neural Network
- Layers
- Activation Layer
- Average Pooling Layer
- Batch Normalization Layer
- Constant Padding Layer
- Convolutional Layer
- Dropout Layer
- Flatten Layer
- Fully-Connected (Dense) Layer
- Fully-Connected RNN Layer
- Max Pooling Layer
- Reshape Layer
- Up Sampling Layer
- Zero Padding Layer
- Model Types
Contact
If there’s some implementation you would like to see here or if you’re just feeling social, feel free to email me or connect with me on LinkedIn.
Similar Articles
@techNmak: This GitHub repo is a goldmine if you want to deeply understand AI/ML, not just use it. Maths, CS & AI Compendium. Free…
A free, intuition-first open textbook and GitHub repo covering maths, CS, and AI from fundamentals to cutting-edge topics, with an MCP server for AI assistants.
@0x0SojalSec: Want to truly stand out in AI/ML not just use the tools, but understand and improve them? understand why gradient desce…
A tweet promoting a curated collection of math and deep learning resources for understanding the foundations behind models like Claude, including linear algebra, real analysis, optimization, and representation theory.
All fundamental knowledge in ML Course by Andrew NG that I noted and create into a repo github [R]
A user shares a GitHub repository containing detailed lecture notes for all 10 chapters of Andrew Ng's Machine Learning Specialization, written in LaTeX and automatically compiled to PDF.
@DanKornas: Stop learning ML math from random tabs. Mathematics for Machine Learning is a curated GitHub collection of books, paper…
A curated GitHub collection (Mathematics for Machine Learning) that organizes books, papers, video lectures, and math basics for learning the math behind machine learning, covering linear algebra, calculus, probability, statistics, and more.
@mdancho84: some guy consolidated over 400 curated resources on AI and ML then put it on GitHub. Here it is (for free):
A compilation of over 400 curated AI and machine learning resources has been posted on GitHub for free.