An intelligent car price prediction application using Gradient Boosted Trees machine learning algorithm. This project features a beautiful Streamlit web interface for predicting car prices based on comprehensive vehicle specifications.
- Overview
- Features
- Demo
- Tech Stack
- Project Structure
- Installation
- Usage
- Model Details
- API Documentation
- Screenshots
- Future Enhancements
- Contributing
- License
- Contact
This machine learning project predicts the market value of cars based on 74 comprehensive features including vehicle specifications, engine details, and body characteristics. The model uses Gradient Boosting regression to provide accurate price estimates with confidence intervals.
- โ 91% Prediction Accuracy (Rยฒ score)
- โ 74 Features analyzed (15 numerical + 59 categorical)
- โ Real-time Predictions with interactive UI
- โ One-Hot Encoding for categorical variables
- โ No Feature Scaling required (tree-based model)
- Gradient Boosted Tree regression model
- Handles both numerical and categorical data
- One-hot encoding for categorical features
- High accuracy predictions (~91% Rยฒ)
- Robust to outliers and missing patterns
- Beautiful Streamlit Dashboard with custom CSS
- Smart Price Formatting ($10.9K instead of $10,911.14)
- Price Range Estimation (ยฑ10% confidence interval)
- Quick Presets - Load example cars instantly:
- Toyota Camry (Mid-range sedan)
- BMW 3-Series (Luxury sport)
- Honda Civic (Economy hatchback)
- Mercedes E-Class (Premium sedan)
- VW GTI (Sport turbo)
- Gradient Designs with modern UI/UX
- Real-time Validation for input fields
- Key Metrics Dashboard showing HP, MPG, Engine Size
- Responsive Layout for all screen sizes
- Estimated market value
- Exact price prediction
- Typical price range (lower/upper bounds)
- Key vehicle metrics summary
- Model confidence indicators
Try it yourself:
# Clone the repository
git clone https://github.com/Deathblu/car-price-predictor.git
cd car-price-predictor
# Install dependencies
pip install -r requirements.txt
# Run the app
streamlit run streamlit_app.pyLive Demo: [Deploy on Streamlit Cloud] (Coming Soon)
- Python 3.8+ - Core programming language
- scikit-learn - Gradient Boosting Regressor
- NumPy - Numerical computations
- Pandas - Data manipulation (during training)
- Joblib - Model serialization
- Streamlit - Interactive web interface
- Custom CSS - Enhanced UI/UX with gradients
- Jupyter Notebook - Model training and experimentation
- Git - Version control
car-price-predictor/
โ
โโโ streamlit_app.py # Main Streamlit application
โโโ final_model.pkl # Trained Gradient Boosting model
โโโ requirements.txt # Python dependencies
โโโ README.md # Project documentation
โ
โโโ notebooks/ # (Optional) Jupyter notebooks
โ โโโ model_selection.ipynb # Model development & training
โ
โโโ data/ # (Optional) Dataset folder
โ โโโ car_price.csv # Original dataset
โ
โโโ .gitignore # Git ignore file
- Python 3.8 or higher
- pip package manager
- Clone the repository
git clone https://github.com/Deathblu/car-price-predictor.git
cd car-price-predictor- Create virtual environment (recommended)
# Windows
python -m venv venv
venv\Scripts\activate
# macOS/Linux
python3 -m venv venv
source venv/bin/activate- Install dependencies
pip install -r requirements.txt- Verify installation
python -c "import streamlit; import joblib; import numpy; print('All dependencies installed!')"streamlit run streamlit_app.pyThe app will automatically open in your browser at http://localhost:8501
-
Choose a preset (optional) from the sidebar:
- Select from Toyota Camry, BMW 3-Series, Honda Civic, etc.
- Or enter custom values
-
Enter vehicle specifications:
- Numerical features: symboling, dimensions, weight, engine specs, etc.
- Categorical features: fuel type, transmission, body style, etc.
-
Click "Predict Price Now" button
-
View results:
- Estimated market value
- Exact prediction
- Price range
- Key metrics summary
Input: 2018 Toyota Camry
- Engine: 2.0L (1998cc), 140 HP
- Fuel: Gas, MPFI
- Body: Sedan, 4 doors
- Transmission: Standard, FWD
- Fuel Economy: 24 city / 30 highway MPG
Output: ~$18,500 (range: $16,650 - $20,350)
Gradient Boosted Trees (Gradient Boosting Regressor)
- โ Handles non-linear relationships
- โ Works with mixed data types
- โ No feature scaling required
- โ Robust to outliers
- โ High accuracy with proper tuning
symboling- Insurance risk ratingnormalized_losses- Normalized loss valuedrive_wheels- Drive wheels configurationlength- Vehicle length (inches)width- Vehicle width (inches)height- Vehicle height (inches)curb_weight- Weight (lbs)engine_size- Engine displacement (cc)bore- Engine borestroke- Engine strokecompression_ratio- Compression ratiohorsepower- Engine power (bhp)peak_rpm- Peak RPMcity_mpg- City fuel economyhighway_mpg- Highway fuel economy
- Fuel Type (2): diesel, gas
- Make (2): std, turbo
- Doors (2): two, four
- Aspiration (5): convertible, hatchback, sedan, wagon, hardtop
- Wheel Base (3): rwd, fwd, 4wd
- Engine Location (2): front, rear
- Body Style (22): alfa-romero, audi, bmw, chevrolet, dodge, honda, isuzu, jaguar, mazda, mercedes-benz, mercury, mitsubishi, nissan, peugot, plymouth, porsche, renault, saab, subaru, toyota, volkswagen, volvo
- Engine Type (6): dohc, ohcv, ohc, l, rotor, ohcf
- Cylinders (7): four, six, five, three, twelve, two, eight
- Fuel System (8): mpfi, 2bbl, mfi, 1bbl, spfi, 4bbl, idi, spdi
Total Features: 15 + 59 = 74 features
- Rยฒ Score: ~0.91 (91% accuracy)
- Training Method: Jupyter Notebook
- Serialization: Joblib (.pkl format)
# Example training code structure
from sklearn.ensemble import GradientBoostingRegressor
import pandas as pd
import joblib
# Load and preprocess data
df = pd.read_csv('car_pricedata.csv')
X = pd.get_dummies(df.drop('price', axis=1)) # One-hot encoding
y = df['price']
# Train model
model = GradientBoostingRegressor(
n_estimators=100,
learning_rate=0.1,
max_depth=5,
random_state=42
)
model.fit(X, y)
# Save model
joblib.dump(model, 'final_model.pkl')If you need to integrate the model as an API:
Endpoint: POST /predict
Request:
{
"features": [
1, 120, 88.6, 168.8, 64.1, 48.8, 2548, 130, 3.47, 2.68, 9.0, 111, 5000, 21, 27,
0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0,
0, 0, 0, 0, 0, 1, 0, 0, 0, 0
]
}Response:
{
"success": true,
"predicted_price": 18456.78
}
Interactive dashboard with numerical and categorical input fields. Clean, modern design with gradient accents and organized feature sections.
Beautiful results page showing estimated price in large gradient text ($10.9K format), exact value, price range (ยฑ10%), and key metrics cards for horsepower, fuel economy, and engine size.
Sidebar with preset car examples (Toyota Camry, BMW 3-Series, Honda Civic, etc.) for quick testing and demonstration of the model.
- Historical Price Trends - Show price changes over time
- Comparison Tool - Compare multiple cars side-by-side
- Image Upload - Predict from car images using CNN
- Market Analysis - Show similar cars and market trends
- Export Reports - Download PDF price reports
- API Access - RESTful API for integrations
- Mobile App - Native iOS/Android applications
- Real-time Data - Integration with live market data
Contributions are welcome! Here's how you can help:
- Fork the repository
- Create feature branch (
git checkout -b feature/AmazingFeature) - Commit changes (
git commit -m 'Add AmazingFeature') - Push to branch (
git push origin feature/AmazingFeature) - Open Pull Request
- Follow PEP 8 style guide
- Add comments for complex logic
- Update documentation for new features
- Test thoroughly before submitting
This project is licensed under the MIT License - see the LICENSE file for details.
Your Name
- GitHub: @Deathblu
- LinkedIn: [(https://www.linkedin.com/in/anurag-wanwe-17b8ab243/)]
- Email: [anuwanwe1463@gmail.com]
Project Link: https://github.com/yourusername/car-price-predictor
- Dataset source: [UCI Machine Learning Repository / Kaggle]
- Streamlit team for the amazing framework
- scikit-learn community for excellent ML tools
- Stack Overflow community for troubleshooting help
โญ Star this repo if you find it helpful!
Made with โค๏ธ and ๐ Python