Welcome to the AI & Machine Learning From Scratch series! This repository is dedicated to breaking down and building foundational Artificial Intelligence and Machine Learning models, algorithms, and neural networks from first principles.
Instead of treating modern frameworks like black boxes, this series explores how the math, algorithms, optimization routines, and backpropagation actually work under the hood using pure Python, NumPy, and PyTorch fundamentals.
| # | Topic | Notebook | Colab | Description | Tech Stack | Status |
|---|---|---|---|---|---|---|
| 1 | Linear Regression | NeuralNetwork/LinearRegression/ |
Single-variable linear regression predicting marks from study hours | PyTorch (nn.Module), Pandas, Matplotlib |
✅ Completed | |
| 2 | Neural Network from Scratch | NeuralNetwork/numpy_mnist.ipynb |
Multi-class digit classification on the MNIST dataset | Pure NumPy, Math & Linear Algebra | ✅ Completed | |
| 3 | Logistic Regression | Coming Soon |
— | Binary and multiclass classification with sigmoid & cross-entropy loss | NumPy / PyTorch | ⏳ In Progress |
| 4 | Multi-Layer Perceptron (MLP) | Coming Soon |
— | Fully-connected deep neural networks with activation functions & backpropagation | NumPy / PyTorch | 📅 Planned |
| 5 | Optimizers From Scratch | Coming Soon |
— | Implementing Gradient Descent, Momentum, RMSprop, and Adam | Pure Python & NumPy | 📅 Planned |
| 6 | Convolutional Neural Networks (CNN) | Coming Soon |
— | Convolutions, pooling, feature maps, and computer vision classification | PyTorch | 📅 Planned |
| 7 | Transformers & Attention | Coming Soon |
— | Self-attention mechanism, Multi-head attention, and Encoder-Decoder architecture | PyTorch | 📅 Planned |
Make sure you have Python 3.10+ installed on your system.
git clone https://github.com/prachin77/From-Scratch.git
cd From-Scratch# Windows
python -m venv venv
venv\Scripts\activate
# macOS / Linux
python3 -m venv venv
source venv/bin/activatepip install torch numpy pandas matplotlib scikit-learn jupyterjupyter notebookNavigate to any notebook (e.g. NeuralNetwork/LinearRegression/linear_nn.ipynb) and run the cells interactively!
Community contributions and discussions are welcome! Whether you are catching a typo, implementing a new algorithm, optimizing a function, or suggesting a topic:
- Have a question about how backpropagation or gradient descent works?
- Want to suggest the next topic or model to implement?
- Head over to the Discussions tab to share ideas, ask questions, and learn together.
- If you find a bug, mathematical inaccuracy, or broken link:
- Go to the Issues tab.
- Click New Issue.
- Provide a clear description of the problem, code snippet, and steps to reproduce.
- Fork this repository to your GitHub account.
- Clone your fork locally:
git clone https://github.com/prachin77/From-Scratch.git
- Create a new branch for your feature or fix:
git checkout -b feature/topic-name-or-fix
- Make your changes:
- Keep notebooks clean and well-commented.
- Include mathematical intuition and markdown explanations where appropriate.
- Ensure any heavy datasets or raw files are added to
.gitignore.
- Commit your changes:
git add . git commit -m "Add: [Topic/Algorithm] implementation from scratch"
- Push to your fork:
git push origin feature/topic-name-or-fix
- Open a Pull Request (PR) against the
mainbranch with a description of what you added or improved.
This repository is open-source and available under the MIT License.
⭐ If you find this series helpful, consider giving it a star!