This repository demonstrates how to implement linear regression from scratch in both Python and C++. It includes a dataset used for predicting food delivery times.
Food_Delivery_Time_Prediction.csv: Dataset containing features and the target variable for model training.Linear_regression.py: Python implementation of linear regression using gradient descent. The script loads the dataset, normalizes features, trains a model, evaluates performance (e.g., Mean Squared Error), and can plot results.Linear_Regression.cpp: C++ implementation of linear regression using a similar approach, with an emphasis on low‑level control and efficiency.
The Food_Delivery_Time_Prediction.csv dataset includes features such as order preparation time, delivery distance, and weather conditions. The target column is the delivery time. The goal is to learn how these factors influence delivery duration using linear regression.
Install dependencies (pandas, numpy, matplotlib if needed) and run:
python Linear_regression.pyThe script will load the dataset, train the model, and output training progress and evaluation metrics.
Compile and run the C++ version with a C++11 compiler:
g++ -std=c++11 Linear_Regression.cpp -o linear_regression
./linear_regressionThis will train the model using the dataset and print results to the console.
Building models from scratch in multiple languages helps deepen understanding of linear regression and machine learning fundamentals. Python offers rapid development and visualization, while C++ provides insight into memory management and performance optimization.
Feel free to explore and modify the code or dataset to experiment with feature engineering, learning rates, and optimization strategies.