I have deployed the trained models to a live interactive interface using Hugging Face Spaces. This allows for real-time predictions and demonstrates the model's practical utility.
Try the Live Demo
You can interact with the model directly through the interface above or by clicking the button below:
This project investigates the primary drivers of used car prices. By analyzing a comprehensive dataset of vehicle transactions, I developed a machine learning pipeline that not only predicts the exact market value of a car (Regression) but also segments vehicles into distinct price tiers (Classification). This dual approach provides actionable insights for digital car platforms and private sellers in an increasingly data-driven market.
My EDA process was iterative. As I progressed with the models, I refined the data to improve prediction accuracy. The goal was to transform "noisy" raw data into a clean dataset reflecting the real used car market.
Step A: Infrastructure Cleaning
Before the deep analysis, I removed the "technical noise":
Duplicates: Removed all duplicate rows to ensure unique observations.
Identifiers: Dropped the vin column as unique IDs do not contribute to price patterns.
Focus: Removed saledate to prioritize core physical attributes: age, mileage, and brand.
Step B: Smart Missing Data Handling
Used a "context-based" approach instead of general averages:
Mileage: Filled missing values using the median of their specific manufacturing year to avoid distorting data for older models.
Categorical Data: Labeled missing transmission values as "Unknown" to avoid biasing the model with guesses.
Initial Data Insights
Price Outliers: Found unrealistic prices (e.g., $150 for a 2010 model), likely representing entry errors or totaled vehicles.
Mileage Bias: Mean mileage was significantly higher than the median, indicating extreme outliers (nearly 1,000,000 miles).
High-Value Checks: Price range reaches $154,000; required visualization to verify genuine luxury cars versus errors.
Research Questions & Visualizations
Q1: Are there extreme values distorting the economic averages?
Price Outliers
Odometer Outliers
Insight: Removing outliers focused the data on the representative core of the market.
Q2: How does the vehicle's age affect its second-hand market value?
Age vs Price
Price Distribution per Year
Insight: The trend is smooth; as the year progresses, the logical price range increases gradually.
Q3: What is the impact of MMR (Market Report) on the target?
MMR Correlation
Decision: Due to the extremely high correlation with sellingprice, MMR was removed to ensure predictions rely on physical features rather than existing price indices.
Market Research Highlights
1. Market Concentration
Price Range Distribution
Most vehicles are concentrated in the $5,000 to $15,000 range, indicating a market dominated by mass-market, accessible vehicles.
2. The Maintenance Premium
Condition vs Price
There is a clear linear upward trend. The market sharply prices differences between quality levels; vehicles in excellent condition command a significant premium.
3. Depreciation Dynamics
Mileage vs Price
Value drops sharply within the first 60,000 miles, indicating rapid early-life depreciation.
Feature Engineering & Data Preparation
Strategic Clustering: Grouped brands into Market Clusters (Luxury, Mid-Range, Budget).
Feature Scaling: Applied StandardScaler to normalize numeric variables like mileage and age.
Unsupervised Learning: Applied K-Means clustering to identify distinct vehicle profiles based on age, mileage, and condition.
PCA Visualization: Used Principal Component Analysis to visualize how data naturally organizes into specific market segments.
Clustering PCA
Elbow Method
Modeling Strategy
Part 1: Regression (Exact Price Prediction)
My process followed an iterative approach, establishing a solid baseline before moving to advanced algorithms.
Phase 1: Baseline Model (Linear Regression)
Performance: MAE: $2809.89 | R²: 0.757
Limitation: Struggled with non-linear patterns like brand prestige.
Phase 2: Model Comparison
Evaluated Decision Tree, Random Forest, and Gradient Boosting.
Regression Comparison
Phase 3: The Champion (Gradient Boosting Regressor)
Final R² Score: 0.8317
Why it won: Best at capturing non-linear relationships (e.g., sharp price drops under 60k miles) and effectively integrating diverse data types.
Feature Importance
Feature Importance
Part 2: Classification (Market Tiers)
I reframed the problem into discrete categories to identify tier characteristics. Using Quantile Binning, I created three balanced classes: Low, Medium, and High.
Class Distribution
Classification Separation
Precision over Recall: In this context, Precision is more critical. Overpricing a "Budget" car as "Luxury" leads to a loss of trust and unsold inventory.
Segment Distinction: Excels at distinguishing tiers with minimal overlap and high discriminative power.
Confusion Matrix
ROC Curves
Final Conclusions
Iterative EDA was the most critical step; without removing outliers, models were consistently biased.
Ensemble Models significantly outperformed linear models due to the complexity of the car market.
Model Synergy: Integrating Gradient Boosting for exact value and Random Forest for market tiering provides a robust decision-support tool for pricing and inventory management.