Built at Tech Arena Hackathon — NRIIT College, Guntur Team Gandiva · Rudro Prasad Panigrahi · Seera Kiran Kumar · Ponruru Promod · Sk. Muzamill
- About the Project
- Problem Statement
- Features
- Tech Stack
- Project Structure
- Getting Started
- API Reference
- ML Pipeline
- Dataset
- How It Works
- Screenshots
- Known Issues & Fixes
- Roadmap
- Team
- License
The Reusable Product Price Predictor is an AI/ML-powered web application that estimates the fair resale price of used products based on their specifications and usage history.
Currently supports Cars — with a reusable architecture designed to extend to:
| Category | Status |
|---|---|
| 🚗 Cars | ✅ Live |
| 📱 Mobiles | 🔜 Coming soon |
| 🏍️ Bikes | 🔜 Coming soon |
| 🪑 Furniture | 🔜 Coming soon |
Built with a FastAPI backend, a Streamlit frontend, and a Random Forest Regressor ML model trained on real CarDekho resale data.
In online resale platforms like OLX, Facebook Marketplace, and similar sites:
- 📊 65–75% of users face confusion about fair pricing
- 📉 50–60% of products are listed at inflated or inconsistent prices
- ✅ Only 25–35% of listings are at a genuinely fair market value
This leads to:
- Buyers overpaying or losing trust in the platform
- Sellers struggling to price competitively or losing money
- Delayed, inefficient transactions
Our solution: A machine learning model that takes product details as input and returns a data-backed predicted price — giving sellers a fair anchor and buyers a trust signal.
- 🔮 Real-time price prediction via REST API
- 🌐 Simple web UI built with Streamlit — no installation needed for end users
- ✅ Input validation using Pydantic schemas
- 💾 Persisted ML model — trained once, reused on every request
- 🧩 Modular & reusable — swap datasets and models to support new categories
- 🚀 Cloud-ready — deployable on Render or any cloud platform
- 📄 Auto-generated API docs via FastAPI's
/docs(Swagger UI)
| Layer | Technology |
|---|---|
| Frontend | Streamlit |
| Backend / API | FastAPI, Uvicorn |
| Input Validation | Pydantic |
| Machine Learning | Scikit-learn (Random Forest Regressor) |
| Data Processing | Pandas, NumPy |
| Dataset | CarDekho CSV (Kaggle) |
| API Testing | Postman, Swagger UI (/docs) |
| Deployment | Render (Cloud) / Localhost |
car-price-api/
│
├── 📄 main.py # FastAPI app — entry point, routes & server config
├── 📄 model.py # Model loading logic & prediction function
├── 📄 schema.py # Pydantic input schema (request body validation)
├── 📄 train.py # ML training script — run once to generate .pkl files
├── 📄 streamlit_app.py # Streamlit frontend — user interface
│
├── 📊 cardekho_data(1).csv # Raw CarDekho resale dataset
├── 🤖 random_forest_model.pkl # Trained Random Forest model (generated by train.py)
├── 📋 feature_columns.pkl # Feature column names (generated by train.py)
│
├── 📄 requirements.txt # Python dependencies
├── 📄 runtime.txt # Python version for deployment (e.g. python-3.10.x)
├── 📄 README.md # You are here
└── 📁 __pycache__/ # Python bytecode cache (auto-generated)
Make sure you have the following installed:
1. Clone the repository
git clone https://github.com/your-username/car-price-api.git
cd car-price-api2. Create and activate a virtual environment
# Create virtual environment
python -m venv venv
# Activate — Windows
venv\Scripts\activate
# Activate — macOS / Linux
source venv/bin/activate3. Install dependencies
pip install -r requirements.txt4. Train the ML model (only needed once — generates the .pkl files)
python train.pyAfter this step you should see:
✅ random_forest_model.pkl
✅ feature_columns.pkl
uvicorn main:app --reloadThe API will be live at:
http://127.0.0.1:8000
Visit the interactive API docs at:
http://127.0.0.1:8000/docs
Open a new terminal (keep the FastAPI server running in the first one), then:
streamlit run streamlit_app.pyThe app will open automatically in your browser at:
http://localhost:8501
Predicts the resale price of a used car.
Request Body
{
"Car_Name": "maruti swift",
"Year": 2019,
"Present_Price": 7.5,
"Kms_Driven": 35000,
"Seller_Type": "Dealer",
"Transmission": "Manual",
"Owner": 0
}Field Descriptions
| Field | Type | Description |
|---|---|---|
Car_Name |
string |
Name/model of the car |
Year |
integer |
Year of purchase (e.g. 2019) |
Present_Price |
float |
Current ex-showroom price in lakhs |
Kms_Driven |
integer |
Total kilometres driven |
Seller_Type |
string |
"Dealer" or "Individual" |
Transmission |
string |
"Manual" or "Automatic" |
Owner |
integer |
Number of previous owners (0, 1, 2, 3) |
Success Response — 200 OK
{
"prediction_price": 5.47
}💡
prediction_priceis in lakhs (₹)
Error Responses
| Status Code | Meaning | Fix |
|---|---|---|
405 Method Not Allowed |
Sent a GET request instead of POST | Change request method to POST |
422 Unprocessable Entity |
Missing or invalid input fields | Check all fields match the schema above |
Raw Data (CSV)
↓
Data Preprocessing
- Handle missing values
- Drop irrelevant columns
↓
Feature Encoding
- Label encode categorical fields
- (Seller_Type, Transmission)
↓
Train / Test Split
- 80% Training | 20% Testing
↓
Model Training
- Random Forest Regressor
- Handles non-linear relationships
- Robust to outliers
↓
Model Evaluation
- R² Score, MAE, RMSE
↓
Save Model
- random_forest_model.pkl
- feature_columns.pkl
↓
FastAPI Integration
- Load .pkl on startup
- Preprocess input → Predict → Return price
Why Random Forest?
- Handles non-linear relationships between features and price
- Robust against overfitting on structured/tabular data
- High accuracy without extensive hyperparameter tuning
- Works well with mixed feature types (numeric + categorical)
- Source: CarDekho Dataset on Kaggle
- File:
cardekho_data(1).csv - Records: ~300 used car listings
Key columns used for training:
| Column | Description |
|---|---|
Car_Name |
Model name of the car |
Year |
Year of manufacture |
Selling_Price |
Target variable — actual resale price |
Present_Price |
Current market/showroom price |
Kms_Driven |
Total distance driven |
Fuel_Type |
Petrol / Diesel / CNG |
Seller_Type |
Dealer or Individual |
Transmission |
Manual or Automatic |
Owner |
Number of previous owners |
User fills form on Streamlit
↓
POST request → FastAPI /predict
↓
Pydantic schema validates input
↓
model.py loads random_forest_model.pkl
↓
Input is preprocessed (encoded & aligned to feature_columns)
↓
Model predicts resale price
↓
{ "prediction_price": X.XX } returned
↓
Streamlit displays the estimated price to the user
| # | Error | Cause | Fix |
|---|---|---|---|
| 1 | pip upgrade failed |
Outdated pip version | Run python -m pip install --upgrade pip |
| 2 | venv not activating |
Wrong directory or OS command | Use venv\Scripts\activate (Windows) or source venv/bin/activate (Mac/Linux) |
| 3 | 405 Method Not Allowed |
Sending GET to a POST endpoint | Use POST method in Postman or hit /docs Swagger UI |
| 4 | 422 Unprocessable Entity |
Wrong field names or missing data | Double-check request body matches schema exactly |
| 5 | random_forest_model.pkl not found |
Model not trained yet | Run python train.py first |
| 6 | feature_columns.pkl not found |
Same as above | Run python train.py first |
- Car price prediction (Phase 1 + Phase 2)
- FastAPI backend with Pydantic validation
- Streamlit frontend
- Postman API testing (HTTP 200 ✅)
- Cloud deployment on Render
- Mobile phone resale price predictor
- Bike resale price predictor
- Furniture resale price predictor
- Category selector on the frontend
- Price history chart / trend view
- Confidence interval / price range output
Built with ❤️ by Team Gandiva at the Tech Arena Hackathon, NRIIT College, Guntur.
| Name | Role |
|---|---|
| 👑 Rudro Prasad Panigrahi | Team Leader |
| Seera Kiran Kumar | Frontend dev |
| Ponruru Promod | Member |
| Sk. Muzamill | Member |
This project is open source and available under the MIT License.
⭐ If this project helped you, please give it a star!
Made with ☕ and 🔥 by Team Gandiva