Comprehensive Machine Learning concepts & algorithms implemented from scratch using Python & numpy only. This repository is a collection of core machine learning algorithms built without any external ML libraries like Scikit-learn or TensorFlow. The goal is to gain a deep understanding of how these algorithms work under the hood — mathematically and programmatically.
- Implementing ML algorithms/models from scratch
- Learning the mathematical mehanism behind ML algorithms
- Learning the foundations of machine learning
- Teaching aid for ML courses
- Interview preparation
- Current Version: V1.0
machine-learning-algorithms-scratch/
├── assets/
│ └── images/
├── datasets/
│ ├── various datasets
│ └── in (.csv/.json/.xlsx) format files
├── supervised/
│ ├── classification
│ │ ├── decision-tree
│ │ ├── knn
│ │ ├── logistic-regression
│ │ ├── naive-bayes
│ │ ├── random-forest
│ │ └── svm
│ └── regression/
│ │ ├── decision-tree
│ │ ├── linear-regression
│ │ └── random-forest
├── unsupervised/
│ │ ├── clustering
│ │ │ ├── kmc
│ │ ├── dimensionality-reduction
│ │ │ ├── pca
│ │ │ └── lda
│ │ ├── association-rule-learning
│ │ └── anomaly-detection
├── semi-supervised
├── README
└── .gitignore # gitignore file
- Covers supervised, unsupervised and semi-supervised ML algorithms
- Pure Python and NumPy — no ML libraries
- Modular, clean, and reusable code
- Educational and beginner-friendly
- Knowledge Required : python, linear algebra, probability, statistics, numpy, matplotlib
- IDE (VS Code) or jupyter notebook or google colab
- Python 3
- Python 💻
- Numpy, Pandas, Matplotlib, Scikit-Learn🧩
git clone https://github.com/yourusername/machine-learning-algorithms-scratch.git
cd ml-algorithms-scratch
- Open .ipynb files inside each algorithm directory and run them to see training/inference steps, plots, and results.
-
✅ Supervised-Classification :- Logistic-Regression, SVM, KNN, Naive-Bayes, Decision-Tree, Random-Forest
-
✅ Supervised-Regression :- LR, MLR, Decision-Tree, Random-Forest
-
✅ Unsupervised-Clustering :- KMC
-
✅ Unsupervised-DimenReduction :- PCA
-
⏳ Upcoming : LDA, Adaboost, SVM (SVR & non-linear SVM, kernel-trick), GBM, Neural-Network from scratch, Perceptron
- Implement raw ML algorithms from scratch
- Re-implement ML algorithms using tensorflow
- Re-implement ML algorithms using scikit-learn
- Re-implement ML algorithms using pyTorch
Contributions are welcomed!
- Fork the repo.
- Create a branch:
git checkout -b feature/YourFeature
- Commit changes:
git commit -m 'Add some feature'
- Push to branch:
git push origin feature/YourFeature
- Open a Pull Request.
Distributed under the MIT License. See LICENSE.txt for more information.
- Special thanks to the open-source community / youtube for tools and resources.