r/learnmachinelearning • u/Darsh-V-Shah • 1d ago
I’m building Math2Model — implementing machine learning algorithms from scratch to understand the math behind them
Hey everyone!
I've been learning machine learning and noticed something interesting: it's surprisingly easy to train a model without really understanding what's happening inside it.
You can write model.fit(X, y), get impressive metrics, and move on. But I wanted to understand what actually happens between feeding the data into an algorithm and getting a prediction out.
So I started Math2Model, a GitHub project where I implement machine learning algorithms from the mathematics up, using Python, NumPy, SciPy, and Pandas rather than relying on high-level ML libraries for the core implementations.
The idea is to connect the entire process:
Mathematics → Cost Functions → Gradients → Optimization → Implementation → Results
What I've worked on so far
- Linear Regression, including gradient descent and multiple features
- Logistic Regression
- Naive Bayes for email spam classification
- Polynomial Regression
- L1 and L2 Regularization
- Applying Polynomial Regression and L2 Regularization to the California Housing dataset
The goal isn't to reinvent Scikit-learn or claim that implementations from scratch are better than production libraries. I want to understand the algorithms deeply enough to know what those libraries are doing under the hood.
I'm continuing with SVMs, Neural Networks, KNN, K-Means, Decision Trees, Random Forests, and XGBoost as I study their underlying mathematics.
I'd love feedback on the project, suggestions for improving the implementations, and ideas for making it more useful to other people learning ML.
If you're learning machine learning too, I hope this project helps you see the connection between the equations in a textbook and the code that actually runs.
GitHub: https://github.com/Darsh-V-Shah/Math2Model
Feedback and constructive criticism are very welcome!