# Machine-Learning-Models-from-Scratch
๐ง Machine Learning Models from Scratch --- This repository demonstrates the mathematical intuition and implementation of essential machine learning algorithms built entirely from scratch using Python and NumPy. The goal is to bridge the gap between theoretical understanding and practical model development โ showing how core ML algorithms truly work behind the scenes.
โจ By studying and experimenting with this repository, you will gain a solid intuition about how modern AI models build upon these foundational algorithms โ transforming raw mathematics into intelligent systems.
This project aims to rebuild key ML algorithms without using scikit-learn โ focusing on how they work mathematically and programmatically.
Each model is explained step-by-step through theory, code, and visualization.
- ๐ Linear Regression โ Predicting continuous values using gradient descent.
- ๐ Logistic Regression โ Binary classification using sigmoid and cost function.
- ๐ฏ K-Means Clustering โ Unsupervised grouping based on Euclidean distance.
The notebook explanation.ipynb includes:
- Mathematical formulation and derivation.
- Visual representation of training process.
- Python implementation from scratch.
- Comparison with scikit-learn results
Run any model directly:
- python src/linear_regression.py
- python src/logistic_regression.py
- python src/kmeans.py
Or open the interactive notebook: jupyter notebook explanation.ipynb
-
Linear Regression shows clear trends fitting with gradient convergence.
-
Logistic Regression demonstrates classification boundaries with sigmoid activation.
-
K-Means visualizes centroid movement and cluster assignment.
This project covers:
-
Gradient Descent Optimization
-
Sigmoid Function and Binary Cross-Entropy
-
Euclidean Distance and Centroid Updates
-
Regression Metrics: MSE, RMSE, Rยฒ Score
Muhammad Feby Khoiru Sidqi
Data Angineer | Python Developer | AI Enthusiast | Education Research
โข ๐ง Email:[email protected] โข ๐ LinkedIn : mfebykhoirusidqi โข ๐ GitHub : https://github.com/mfebykhoirusidqi/Machine-Learning-Models-from-Scratch
If you like this project, please โญ star this repository and share it with others. Contributions, ideas, and suggestions are always welcome!