Skip to content

tanishcode-12/CarIQ

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

🚗 CarIQ — AI-Powered Used Car Analytics

A sleek multi-page Streamlit web app that predicts used car prices using a trained Random Forest model, surfaces budget-filtered listings, and equips buyers with four smart tools — depreciation calculator, fuel cost estimator, ownership cost breakdown, and side-by-side car comparison with radar charts.


📌 Overview

Buying a used car in India means navigating opaque pricing, hidden running costs, and no easy way to compare options. CarIQ solves this by combining ML-powered price prediction with interactive market analytics — so you know exactly what a car is worth, what it will cost to run, and how it stacks up against alternatives.

The app spans three pages with a shared gold-on-dark design system and seamless cross-page navigation.

🔗 GitHub Repository: tanishcode-12/used_car_app


✨ Features

  • 🔮 AI Price Predictor — Enter a car, kilometres driven, and manufacturing year to instantly get a predicted market price, ±8% confidence range, and comparison vs brand average — powered by a pre-trained RandomForestRegressor.
  • 💰 Budget Finder — Filter 1,553 listings by max budget, fuel type, transmission, and brand; sorted by price, mileage, or KMs with up to 20 results shown.
  • 📊 Price Analysis Dashboard — Eight interactive Plotly charts covering price distribution, KMs vs price scatter, fuel-type averages, transmission box plots, depreciation curve, top brands, ownership tiers, and mileage histogram. Your predicted car is highlighted live across every chart.
  • 📉 Depreciation Calculator — Enter what you paid and when; get estimated current value (15%/year model), total loss, and a deal verdict (great / fair / overpriced) vs market average.
  • Fuel Cost Calculator — Calculate trip fuel cost and compare across all fuel types for the same journey.
  • 🏠 Ownership Cost Estimator — Breaks down yearly spend into fuel, insurance, servicing, and tyres, with a donut chart breakdown.
  • ⚖️ Side-by-Side Car Comparison — Compare any two cars across 9 features with win/loss highlighting, a score bar, and a normalised radar chart.
  • 🌙 Premium Dark UI — Gold-accent design system with Bebas Neue + Outfit fonts, animated cards, custom Plotly theme, and fuel/transmission tag chips.

🗂️ Project Structure

📦 used_car_app/
├── 🚀 app.py                                        # Entry point — redirects to Page 1
├── 🎨 styles.py                                     # SHARED_CSS — full design system (dark theme, cards, charts)
├── 🤖 train_model.py                                # Model training script — outputs model.pkl
├── 📋 dataset.csv                                   # Master dataset of 1,553 used car listings
├── 🧠 model.pkl                                     # Trained RandomForestRegressor (serialised)
└── 📁 pages/
    ├── 🔮 1_Price_Prediction_&_Recommendation.py    # Budget Finder + AI Price Predictor
    ├── 📊 2_Price_Analysis_Graphs.py                # 8 interactive market analysis charts
    └── 🧰 3_Car_Tools.py                            # Depreciation · Fuel · Ownership · Compare

⚙️ Installation

🧰 Prerequisites

  • 🐍 Python 3.8 or higher
  • 📦 pip

🪜 Steps

📥 Clone the repository

git clone https://github.com/tanishcode-12/used_car_app.git
cd used_car_app/used_car_app

📦 Install dependencies

pip install streamlit pandas scikit-learn plotly

▶️ Run the app

streamlit run app.py

🌐 Open in browser

The app will automatically open at http://localhost:8501

⚠️ Make sure dataset.csv and model.pkl are in the same directory as app.py before launching.

🤖 Retrain the Model (Optional)

If you update dataset.csv, regenerate the model with:

python train_model.py

This produces a fresh model.pkl trained on the updated data.


🚀 Usage

  1. 🔮 Predict a price — On Page 1, pick a brand, model, enter kilometres driven and manufacturing year, then click Predict Price Now to get your estimate.
  2. 💰 Find budget cars — Switch to the Budget Finder tab, set your max budget and filters, and browse matching listings sorted by price or mileage.
  3. 📊 Explore the market — Navigate to Page 2 (Price Analysis) — your predicted car is highlighted as a green star across all 8 charts automatically.
  4. 🧰 Use the tools — On Page 3 (Car Toolkit), pick a tool from the radio buttons:
    • 📉 Depreciation — enter what you paid and get a deal verdict
    • ⛽ Fuel Cost — estimate trip costs and compare fuel types
    • 🏠 Ownership Cost — see your full yearly spend breakdown
    • ⚖️ Compare Cars — pick two cars for a side-by-side showdown

📁 Tip: Predict a price on Page 1 first — it unlocks live highlights on every chart in Page 2 and carries your car's data across the whole session.


📁 Data Files

📋 dataset.csv

Master dataset of 1,553 used car listings covering 28 brands and 219+ models manufactured between 2007 and 2023.

Column Type Description
🚘 car_name string Full car name including year and variant (e.g. 2020 Maruti Swift VXI)
📅 registration_year string Month-year of first registration (e.g. Jan-21)
🛡️ insurance_validity string Insurance type — Comprehensive, Third Party, Zero Dep, etc.
fuel_type string Petrol (1,013) · Diesel (516) · CNG (22)
💺 seats int Seating capacity — 4, 5, 6, 7, or 8
📍 kms_driven int Total odometer reading in km (range: 620 – 810,000)
👤 ownsership string First Owner (1,240) · Second Owner (240) · Third Owner (21)
🔧 transmission string Manual (835) · Automatic (668)
📅 manufacturing_year int Year of manufacture (2007 – 2023)
mileage(kmpl) float Fuel efficiency in km per litre
⚙️ engine(cc) int Engine displacement in cubic centimetres
💪 max_power(bhp) int Peak power output in BHP
🔩 torque(Nm) int Peak torque in Newton-metres
💰 price(in lakhs) float Listed price in Indian Rupees (lakhs) — target variable

🤖 Model Details

🌲 RandomForestRegressor — Price Prediction

Parameter Value
🧠 Model RandomForestRegressor
🌳 n_estimators 100
📏 max_depth None (fully grown trees)
🎲 random_state 42
✂️ Test Split 20%
📥 Input Features kms_driven, engine(cc), mileage(kmpl), car_age
🎯 Target price(in lakhs)
🔧 Feature Engineering car_age = 2026 − manufacturing_year

📊 Feature Importances

Feature Importance
⚙️ engine(cc) 46.4% — most influential
mileage(kmpl) 39.3% — second most influential
🕐 car_age 10.2%
📍 kms_driven 4.2%

💡 Prediction Logic

After prediction, CarIQ computes:

  • Confidence range — ±8% of predicted value (e.g. ₹10L → ₹9.2L–₹10.8L)
  • Brand comparison — predicted price vs average price of all cars of that brand
  • Deal verdict — ✅ Below avg / ⚠️ Near avg / 🔴 Above avg

📦 Dependencies

Library Purpose
🌐 streamlit Multi-page web app framework
🐼 pandas Dataset loading, filtering, and aggregation
🤖 scikit-learn RandomForestRegressor for price prediction
📊 plotly All 8 interactive charts (scatter, histogram, box, bar, radar, pie)
🥒 pickle Model serialisation and loading

🤝 Contributing

🙌 Contributions are welcome! Here's how you can help:

  1. 🍴 Fork the repository
  2. 🌿 Create a new branch (git checkout -b feature/your-feature)
  3. 💾 Make your changes and commit (git commit -m 'Add your feature')
  4. 📤 Push to the branch (git push origin feature/your-feature)
  5. 🔁 Open a Pull Request

✅ Please make sure your code is clean and well-commented.


👤 Author

Tanish@tanishcode-12


⭐ If you found this project helpful, consider giving it a star on GitHub!

About

End-to-end used car price prediction app using Random Forest and Streamlit

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages