This project is a sophisticated, interactive web application designed to provide a deep, practical understanding of linear and non-linear regression techniques, focusing specifically on different cost functions and the impact of hyperparameters.
It serves as an excellent educational tool for students to visualize abstract concepts like L1 vs. L2 penalties and the mechanics of Gradient Descent.
You can check out a live deployment of this tool here: https://regression-visualisation.onrender.com/
- Dual Regression Modes: Supports both classic linear regression and advanced non-linear fitting (polynomial and sine wave).
-
L1 Regression Visualization: For linear models, users can manually adjust the slope (
$m$ ) and intercept ($c$ ) to see the direct, real-time calculation of the L1 Penalty (Least Absolute Deviations). This demonstrates L1's robustness to outliers. - Gradient Descent Simulation: For polynomial and sine models, the tool uses the Gradient Descent algorithm with an L2 Cost Function (Least Squares Error) to find the best-fit curve.
-
Hyperparameter Tuning: Provides granular control over the key machine learning parameters for the Gradient Descent process:
- Order: The degree of the polynomial to be fit.
-
Learning Rate (
$\mathbf{10^{-x}}$ ): Control the step size of the optimizer using a logarithmic scale, ranging from$10^{0}$ to$10^{-10}$ . - Training Rounds: Control the number of iterations for the optimization process (up to 10,000 rounds).
This application is built using a minimal web stack, making it easy to deploy and understand:
- Backend: Python (Flask)
- Scientific Computing: NumPy for array manipulation and calculation.
- Visualization: Matplotlib for generating the regression plots.
- Frontend: HTML, JavaScript, and Tailwind CSS (or similar utility-first framework).
To run this application locally, you will need Python installed.
git clone https://github.com/ayushxpatne/regression-visualisation.git
cd regression-visualisationIt is recommended to use a virtual environment for dependency management.
python3 -m venv venv
source venv/bin/activate # On macOS/Linux
# venv\Scripts\activate # On WindowsInstall the required Python packages (assuming Flask, numpy, and matplotlib are necessary).
pip install flask numpy matplotlibpython app.pyThis tool was designed to explore regression penalties and optimize the core logic.
Transparency Note: The frontend code (HTML/CSS/Flask structure and dynamic JavaScript functions for the user interface) was developed and refined with the assistance of Claude 4.5 during the iterative building process.
If you find this tool helpful for teaching or learning, please consider starring the repository.