Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

🚗 Used Car Price Prediction with Machine Learning

This project aims to accurately predict second-hand car prices using various regression algorithms. The complete end-to-end machine learning pipeline covers Exploratory Data Analysis (EDA), extensive feature preprocessing, feature scaling, model training across multiple linear and regularized regression techniques, and model evaluation.


📌 Project Highlights

  • Problem Type: Supervised Learning — Regression
  • Target Variable: Used Car Price (y)
  • Best Performing Model: Polynomial Regression (3rd Degree) with an $R^2$ Score of 0.98 (98%)
  • Key Workflow Steps: Data Cleaning $\rightarrow$ Feature Encoding $\rightarrow$ EDA & Visualization $\rightarrow$ Correlation Analysis $\rightarrow$ Train-Test Split $\rightarrow$ Feature Scaling $\rightarrow$ Model Benchmarking.

🛠️ Tech Stack & Tools

  • Language: Python 3.14
  • Data Manipulation: pandas, numpy
  • Data Visualization: matplotlib, seaborn
  • Machine Learning & Preprocessing: scikit-learn
  • Environment: Jupyter Notebook / PyCharm

🔄 End-to-End Workflow & Methodology

1. Data Cleaning & Feature Preprocessing

Before feeding the data into machine learning models, raw features were transformed through a rigorous preprocessing pipeline:

  • Data Type Conversions: Corrected misclassified data types across columns.
  • Date Parsing & Transformations: Derived actionable vehicle age/usage metrics from historical date columns.
  • Categorical Encoding:
    • Label Encoding: Applied to nominal binary/low-cardinality categorical variables.
    • Ordinal Encoding: Applied to ordinal categorical attributes preserving intrinsic rankings.

2. Exploratory Data Analysis (EDA) & Visualization

  • Distribution and outlier checks were performed across key numerical features (e.g., mileage, engine size, vehicle age).
  • Categorical distributions against price were inspected to uncover market pricing trends.

3. Correlation & Heatmap Analysis

  • Feature-to-feature and feature-to-target linear relationships were examined using a Pearson correlation matrix.
  • A Seaborn Heatmap was generated to detect potential multicollinearity and highlight features with strong predictive power toward the target price.

4. Data Splitting & Feature Scaling

  • Feature Matrix & Target Vector: Separated into independent variables ($X$) and dependent target variable ($y$).
  • Train-Test Split: Split into training and validation sets to ensure reliable model evaluation and prevent data leakage.
  • Feature Scaling: Applied StandardScaler to standardize feature scales for optimal performance in regularized models.

🤖 Models Trained & Performance Evaluation

Multiple linear regression variants and regularized algorithms were trained and benchmarked using standard evaluation metrics:

  • Mean Squared Error (MSE)
  • Mean Absolute Error (MAE)
  • Coefficient of Determination ($R^2$ Score)

Benchmark Results Overview

Algorithm Model Configuration Performance Summary
Linear Regression Baseline Ordinary Least Squares Baseline performance
Polynomial Regression Degree 3 Best Performance ($R^2 \approx 0.98$)
Ridge Regression L2 Regularization Reduced variance over standard linear model
Lasso Regression L1 Regularization Effective feature selection
ElasticNet Combined L1 + L2 Balanced penalty structure
RidgeCV Cross-validated L2 Alpha search Optimized hyperparameter tuning
LassoCV Cross-validated L1 Alpha search Optimized hyperparameter tuning
ElasticNetCV Cross-validated ElasticNet search Optimized hyperparameter tuning

Key Finding: Third-degree Polynomial Regression captured complex non-linear relationships between vehicle specifications (e.g., age vs. mileage vs. engine capacity interaction) and market price, outperforming standard linear and regularized baselines significantly.


📁 Project Structure

.
├── data/
│   └── used_cars.csv                 # Raw dataset (if applicable)
├── notebooks/
│   └── Car_Price_Prediction.ipynb    # Main notebook containing EDA, preprocessing & modeling
├── README.md                         # Project documentation
└── requirements.txt                  # Python dependencies

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages