This project builds a regression model to predict the selling price of used cars based on features like age, current price, kilometers driven, fuel type, seller type, transmission type, and ownership history.
The dataset includes the following columns:
- Year: Year of manufacture
- Present_Price: Price at the time of selling
- Kms_Driven: Distance driven
- Fuel_Type: Petrol / Diesel / CNG
- Seller_Type: Dealer / Individual
- Transmission: Manual / Automatic
- Owner: Number of previous owners
- Selling_Price: Target variable
- Removed irrelevant columns like Car_Name
- Created new feature: Age_Car = 2024 - Year
- Converted categorical features to numerical values
- Replaced string labels with numeric codes
- Scatter plots of all features vs. Selling_Price
- Histograms for numerical columns
- Bar plots for categorical distributions
- Linear Regression using train_test_split with multiple test sizes
- Evaluation metrics used:
- MAE (Mean Absolute Error)
- MSE (Mean Squared Error)
- RMSE (Root Mean Squared Error)
- R² Score
- Applied power transformation on features (powers 1 to 9)
- Found the best transformation (e.g., Owner^9)
- Re-trained model with transformed features
- Performed K-Fold (5 splits) cross-validation to ensure stability
- Used final model coefficients to predict price of a car with custom input manually
| Metric | Before Tuning | After Tuning |
|---|---|---|
| MAE | 1.100 | 0.861 |
| MSE | 2.784 | 1.427 |
| RMSE | 1.695 | 1.194 |
| R² Score | 0.822 | 0.946 ✅ |
📌 The final model showed improved performance and generalization after removing outliers and applying transformations.
Regression-Model-Project/ ├── Data/cardata.csv ├── Linear-Regression-Project.ipynb ├── README.md ├── LICENSE ├── .gitignore
- Python 3.x
- Jupyter Notebook
- pandas, numpy
- matplotlib
- scikit-learn
To predict a new car's price:
`python
age = 10 present_price = 11.23 kms_driven = 42000 fuel_type = 2 # Petrol seller_type = 1 # Dealer transmission = 0 # Manual owner = 1
selling_price = intercept + (c1 * age) + (c2 * present_price) + ...
📬 Contact
Developed with 💻 and ☕ by Pouya Rahdan
🔗 GitHub: github.com/pouyarahdan
📄 License
MIT License. See LICENSE for details.