- Machine Learning from Scratch – No Scikit-Learn or built-in regression functions.
- Gradient Descent Optimization – Supports multiple learning rates to optimize training.
- Data Normalization & Feature Scaling – Ensures stable convergence during training.
- Model Persistence – Saves trained parameters for future predictions.
- Visualization – Plots regression results and dataset for better interpretation.
- Command-Line Interface – Train and predict using simple CLI commands.
This project implements a simple linear regression model to predict car prices based on mileage. Using a gradient descent algorithm, the model optimizes theta0 (intercept) and theta1 (coefficient) to fit a linear function of the form:
estimatePrice(mileage) = theta0 + (theta1 * mileage)
Key Features:
✅ Implements gradient descent to iteratively improve accuracy.
✅ Normalizes features for better convergence.
✅ Saves trained model parameters in model.json for future predictions.
✅ Provides visualization tools to analyze dataset distribution and model fit.
✅ Supports command-line input for training and predictions.
git clone https://github.com/LuckyIntegral/linear_regression.git
cd linear_regressionpip install -r requirements.txtRun the training script to optimize model parameters:
python linear_regression/train.pyThis will generate a model file (model.json) storing the trained values of theta0 and theta1.
Use the trained model to predict the price of a car based on mileage:
python linear_regression/predict.pyThis script prompts the user for mileage input and returns an estimated car price.
Before training, analyze the dataset using built-in visualization tools:
python linear_regression/predict.pyThis will display a graph of the dataset, the regression line, and the user’s prediction.
.
├── README.md
├── data
│ └── data.csv
├── linear_regression
│ ├── predict.py
│ └── train.py
└── requirements.txt
- Add Polynomial Regression for non-linear relationships.
- Support Multiple Linear Regression with additional features.
- Improve Precision Score Calculation.
Vitalii Frants 📍 42 Vienna – AI & Algorithms 👉 GitHub