URL: Webpage
Welcome to the Car Price Prediction project! This repository provides a complete pipeline for predicting used car prices using machine learning, including data cleaning, visualization, model training, API deployment, and a user-friendly Streamlit web app.
CAR-PRICE-PREDICTION-WITH-MACHINE-LEARNING/
│
├── Api/ # FastAPI backend for model inference
│ └── main.py
│
├──Models/
│ ├── linear_regression_model.pkl
│ ├── random_forest_model.pkl
│ └── xgboost_model.pkl
│
├── Streamlit_app/ # Streamlit frontend for user interaction
│ └── app.py
│
├── Data/ # Datasets
│ ├── car_data.csv
│ └── cleaned_car_data.csv
│
├── Notebooks/ # Jupyter notebooks for EDA, cleaning, training
│ ├── data_clean.ipynb
│ ├── data_visualization.ipynb
│ └── model_training.ipynb
│
├── requirements.txt
├── render.yaml # (Optional) Render deployment config
└── README.md
git clone https://github.com/your-username/CAR-PRICE-PREDICTION-WITH-MACHINE-LEARNING.git
cd CAR-PRICE-PREDICTION-WITH-MACHINE-LEARNINGInstall Python 3.12+ and pip, then:
pip install -r requirements.txtcd Api
uvicorn main:app --reload --host 0.0.0.0 --port 8000Open a new terminal:
cd Streamlit_app
streamlit run app.py- Go to http://localhost:8501 in your browser.
- Enter car details and get instant price predictions from multiple models.
- See feature importances and compare model performances.
- Data Cleaning: Remove outliers, filter non-car entries, handle missing values.
- Visualization: Explore data distributions and relationships with Seaborn and Matplotlib.
- Model Training: Train and compare Linear Regression, Random Forest, and XGBoost models.
- API: FastAPI backend serves predictions and model confidences.
- Frontend: Streamlit app with car name suggestions, input validation, and attractive UI.
- Model Selection: Automatically selects the best model based on confidence (R² score).
- Deployment Ready: Easily deploy both backend and frontend on Render or similar platforms.
Car_Name: Name of the car (with suggestions in the UI)Year: Year of purchaseSelling_Price: Price at which the car is being sold (target)Present_Price: Current ex-showroom priceDriven_kms: Kilometers drivenFuel_Type: Petrol, Diesel, CNG, etc.Selling_type: Dealer or IndividualTransmission: Manual or AutomaticOwner: Number of previous owners
| Model | MAE | MSE | R² Score (%) |
|---|---|---|---|
| Linear Regression | 1.36 | 3.1 | 92.44 |
| Random Forest | 1.19 | 3.1 | 92.43 |
| XGBoost | 1.58 | 5.6 | 86.35 |
Random Forest is selected as the best model by default.
- Push your code to GitHub.
- Create two Render web services:
- One for the FastAPI backend (
Api/) - One for the Streamlit frontend (
Streamlit_app/)
- One for the FastAPI backend (
- Set the correct start commands:
- FastAPI:
uvicorn main:app --host 0.0.0.0 --port 10000 - Streamlit:
streamlit run app.py --server.port 10001 --server.address 0.0.0.0
- FastAPI:
- Set environment variables if needed (e.g., API URL for frontend).
- See
render.yamlfor an example configuration.
- data_clean.ipynb: Data cleaning, outlier detection (IQR method), and preprocessing.
- data_visualization.ipynb: Distribution plots, scatter plots, and correlation heatmaps.
- model_training.ipynb: Model training, evaluation, and feature importance plots.
Contributions are welcome! Please open an issue or submit a pull request.
- Streamlit for the frontend.
- FastAPI for the backend.
- scikit-learn, XGBoost for machine learning.
- Render for easy deployment.
For questions or suggestions, please open an issue or contact the maintainer.
Happy Predicting! 🚗