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.
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
- 🔮 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+Outfitfonts, animated cards, custom Plotly theme, and fuel/transmission tag chips.
📦 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
- 🐍 Python 3.8 or higher
- 📦 pip
📥 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 plotlystreamlit run app.py🌐 Open in browser
The app will automatically open at http://localhost:8501
⚠️ Make suredataset.csvandmodel.pklare in the same directory asapp.pybefore launching.
If you update dataset.csv, regenerate the model with:
python train_model.pyThis produces a fresh model.pkl trained on the updated data.
- 🔮 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.
- 💰 Find budget cars — Switch to the Budget Finder tab, set your max budget and filters, and browse matching listings sorted by price or mileage.
- 📊 Explore the market — Navigate to Page 2 (Price Analysis) — your predicted car is highlighted as a green star across all 8 charts automatically.
- 🧰 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.
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 |
| 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 | Importance |
|---|---|
⚙️ engine(cc) |
46.4% — most influential |
⚡ mileage(kmpl) |
39.3% — second most influential |
🕐 car_age |
10.2% |
📍 kms_driven |
4.2% |
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
| 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 |
🙌 Contributions are welcome! Here's how you can help:
- 🍴 Fork the repository
- 🌿 Create a new branch (
git checkout -b feature/your-feature) - 💾 Make your changes and commit (
git commit -m 'Add your feature') - 📤 Push to the branch (
git push origin feature/your-feature) - 🔁 Open a Pull Request
✅ Please make sure your code is clean and well-commented.
Tanish — @tanishcode-12
⭐ If you found this project helpful, consider giving it a star on GitHub!