Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Car Price Prediction

Car Price Prediction is a machine learning project that predicts used car prices based on vehicle attributes such as year, kilometers driven, fuel type, transmission, owner type, and other structured listing details.

The project applies data cleaning, feature engineering, exploratory data analysis, preprocessing pipelines, model training, cross-validation, and regression model evaluation to estimate used car prices.


Project Overview

Used car prices depend on several factors such as vehicle age, mileage, fuel type, transmission, owner history, and market demand. Manual price estimation can be inconsistent and subjective.

This project uses machine learning to build a data-driven car price prediction model. The goal is to estimate used car prices more accurately using historical listing data and vehicle specifications.


Problem Statement

Estimating the selling price of a used car is challenging because different technical and market-related factors influence the final price.

The objective of this project is to develop a machine learning regression model that predicts used car prices based on structured car listing data.


Objectives

  • Analyze used car listing data
  • Clean and preprocess raw car data
  • Handle missing values and inconsistent entries
  • Remove outliers using the IQR method
  • Engineer useful features such as car age, log-transformed kilometers, and high-mileage flag
  • Perform exploratory data analysis
  • Train and compare multiple regression models
  • Evaluate models using RMSE, MAE, and R² score
  • Select the best-performing model based on evaluation results

Dataset

The dataset used in this project is:

honda_car_selling.csv

The dataset contains used car listing details.

Dataset Features

Feature Description
Year Manufacturing year of the car
Kms Driven Total kilometers driven
Fuel Type Type of fuel used by the car
Transmission Manual or automatic transmission
Owner Type Ownership history of the car
Price Target variable representing selling price

Feature Engineering

Several useful features were created from the original dataset:

Engineered Feature Description
Age Calculated as 2025 - Year
log_kms Log-transformed kilometers driven using log(1 + Kms Driven)
high_mileage Binary flag indicating whether a car has high mileage
Encoded categorical features Fuel type, transmission, owner type, and other categorical variables converted using One-Hot Encoding

Data Preprocessing

The following preprocessing steps were performed:

  • Removed unwanted characters from numeric columns
  • Converted price and kilometers driven into numeric format
  • Handled missing values using median and mode imputation
  • Removed duplicate and inconsistent rows
  • Removed outliers using the IQR method
  • Standardized column names
  • Applied One-Hot Encoding for categorical variables
  • Scaled numerical features using StandardScaler
  • Built preprocessing pipelines to avoid data leakage

Machine Learning Models

The following regression models were trained and compared:

  • Linear Regression
  • Ridge Regression
  • Lasso Regression
  • Random Forest Regressor
  • HistGradientBoosting Regressor

Model Evaluation

The models were evaluated using:

Metric Description
MAE Mean Absolute Error
MSE Mean Squared Error
RMSE Root Mean Square Error
R² Score Measures how well the model explains price variation

Final Model

The final selected model is:

Linear Regression

Linear Regression performed best among the tested models based on evaluation metrics such as RMSE, MAE, and R² score. The dataset showed strong linear relationships between important features such as car age, kilometers driven, and price, making Linear Regression suitable for this project.


Tools and Libraries Used

  • Python
  • Jupyter Notebook
  • Pandas
  • NumPy
  • Matplotlib
  • Seaborn
  • Scikit-learn

Project Structure

Car-Price-Prediction/
│
├── README.md
├── requirements.txt
├── .gitignore
│
├── data/
│   ├── README.md
│   └── honda_car_selling.csv
│
├── notebooks/
│   ├── README.md
│   └── car_price_prediction.ipynb
│
├── reports/
│   ├── README.md
│   ├── car_price_prediction_report.pdf
│   └── car_price_prediction_presentation.ppt
│
└── images/
    ├── README.md
    ├── price_distribution.png
    ├── log_price_distribution.png
    ├── correlation_heatmap.png
    ├── kms_driven_vs_price.png
    └── age_vs_price.png

Key Visualizations

Price Distribution

This graph shows the distribution of original used car prices in the dataset.

Price Distribution

Log Price Distribution

This graph shows the distribution of car prices after applying log transformation. Log transformation helps reduce skewness and makes the target variable more suitable for regression models.

Log Price Distribution

Pairwise Correlation Heatmap

This heatmap shows the correlation between numerical features such as kilometers driven, price, and age. It helps identify relationships between variables.

Correlation Heatmap

Kilometers Driven vs Price

This scatter plot shows the relationship between kilometers driven and car price. It helps analyze how mileage affects used car resale value.

Kms Driven vs Price

Age vs Price

This scatter plot shows the relationship between car age and selling price. Older cars generally tend to have lower prices.

Age vs Price


How to Run Locally

1. Clone the repository

git clone https://github.com/Althafk7171/Car-Price-Prediction.git
cd Car-Price-Prediction

2. Install required libraries

pip install -r requirements.txt

3. Open Jupyter Notebook

jupyter notebook

4. Run the notebook

Open:

notebooks/car_price_prediction.ipynb

Run all cells to reproduce the analysis and model results.


Results

The project compared Linear Regression, Ridge Regression, Lasso Regression, Random Forest Regressor, and HistGradientBoosting Regressor.

Linear Regression achieved the best performance among the tested models based on evaluation metrics such as RMSE, MAE, and R² score.

Key factors influencing used car prices include:

  • Vehicle age
  • Kilometers driven
  • Fuel type
  • Transmission type
  • Ownership history

Reports

This repository includes:

  • Final project report
  • Project presentation
  • Jupyter Notebook
  • Dataset
  • Visualization images

Limitations

  • The model is trained on historical used car listing data.
  • Real-time market demand, offers, and location-based pricing are not included.
  • The dataset may not include all brands and car models.
  • The model performance depends on the quality and size of the dataset.
  • The project currently focuses on notebook-based prediction and does not include a deployed web application.

Future Scope

  • Deploy the model using Streamlit or Flask
  • Add real-time used car market data
  • Include more car brands and models
  • Add features such as engine power, service history, accident records, and location
  • Try advanced boosting models such as XGBoost and CatBoost
  • Add hyperparameter tuning
  • Build a user-friendly car price prediction web app
  • Add feature importance visualization

Contributor

  • Muhammed Althaf K

License

This project is developed for academic and learning purposes.


About

Machine learning project for predicting used car prices using vehicle features such as year, kilometers driven, fuel type, transmission, owner type, and Linear Regression.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages