A simple yet effective linear regression model that predicts car prices based on mileage. This project implements gradient descent optimization from scratch to train the model.
- Data Scaling: Normalizes input features to [0, 1] range for better training
- Gradient Descent: Trains the model using batch gradient descent
- Visualization: Plots both scaled and non-scaled regression lines
- CSV Storage: Saves trained parameters for later use
- CLI Flags: Easy control over training and visualization modes
# Clone/navigate to the project directory
cd ft_linear_regression
# Install dependencies
pip install matplotlib numpy
# Prepare your data
# Ensure you have a Daten.csv file with format:
# mileage,price
# 10000,15000
# 20000,12000
# ...python train.pypython train.py --drawscaledpython train.py --drawpython predict.py <mileage>- Data Loading: Reads mileage and price data from
Daten.csv - Scaling: Normalizes mileage values to [0, 1] range
- Training: Applies gradient descent to minimize prediction error
- Visualization: Plots actual data points and the fitted regression line
- Storage: Saves
theta0andtheta1parameters totheta.csv
- Learning Rate: 0.1 (controls step size during training)
- Iterations: 1000 (number of gradient descent steps)
theta.csv: Stores trained parameters (theta0, theta1, dataset_min, dataset_max)- Visualization plots: Show regression fit on your data
ft_linear_regression/
├── train.py # Training script
├── predict.py # Prediction script
├── Daten.csv # Input data
├── theta.csv # Trained parameters
└── README.md # This file