A clean, production-ready version of the Car Price Prediction application. This project predicts vehicle prices for the Tunisian market using a trained Extra Trees machine learning model.
# Car Price Prediction - Clean Project
A clean, production-ready version of the Car Price Prediction application. This project predicts vehicle prices for the Tunisian market using a trained Extra Trees machine learning model.
## Quick Start
### Prerequisites
- Python 3.11+
- Node.js 16+
### Installation
1. **Install Python dependencies:**
```bash
pip install -r requirements.txt
```
2. **Install frontend dependencies:**
```bash
cd frontend
npm install
```
### Running the Application
**Terminal 1 - Start Backend:**
```bash
python app.py
```
Backend runs on
localhost
**Terminal 2 - Start Frontend:**
```bash
cd frontend
npm run dev
```
Frontend runs on
localhost
## Project Structure
```
Car-Prediction-Project-Clean/
├── app.py # Flask API server
├── predictor.py # ML prediction module
├── requirements.txt # Python dependencies
├── models/
│ ├── extra_trees_tuned.pkl # Trained model
│ └── encoders.pkl # Preprocessing encoders
└── frontend/
├── src/
│ ├── App.jsx
│ ├── main.jsx
│ ├── styles.css
│ └── components/
│ ├── PredictionForm.jsx
│ └── Results.jsx
├── index.html
├── package.json
└── vite.config.js
```
## API Endpoints
- `GET /health` - Health check
- `GET /api/brands` - Get supported brands
- `POST /api/predict` - Predict price for a single vehicle
- `POST /api/predict_batch` - Batch prediction
## Usage Example
```python
from predictor import CarPricePredictor
predictor = CarPricePredictor()
result = predictor.predict(
marque='BMW',
modele='Série 3',
annee=2021,
kilometrage=45000,
energie='Diesel',
boite_vitesses='Automatique',
puissance_fiscale=9
)
print(f"Estimated price: {result['prix_predit']:,.0f} DT")
```
## License
Educational and research purposes.
# CarPrediction