This project aims to provide vehicle recommendations using unsupervised learning via clustering. It is built with Python, Flask, and scikit-learn.
- app.py: Main application file that includes the Flask API for vehicle recommendations.
- generate_vehicles.py: Script to generate a dataset of vehicles.
-
Clone the repository:
git clone https://github.com/Yassim-B/deep-vehicle-suggest.git cd VehicleSuggestionSystem
-
Create a virtual environment and activate it:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install the required packages:
pip install -r requirements.txt
-
Generate the dataset:
python generate_vehicles.py
-
Start the Flask application:
python app.py
-
The API will be available at
http://127.0.0.1:5000/
.
-
GET /coucou: Test endpoint to check if the API is running.
- Example:
curl http://127.0.0.1:5000/coucou
- Example:
-
POST /recommander: Endpoint to get vehicle recommendations based on user input.
- Request body example (JSON):
{ "sieges": 5, "consommation": 8.5, "prix": 30000, "design": 4, "kilometrage_maxi": 50000, "motorisation": "Essence" }
- Response example:
{ "count": 50, "vehicles": [ { "Marque": "Toyota", "Modele": "Corolla", "Sieges": 5, "Consommation": 8.0, "Prix": 25000, "Design": 4.5, "Motorisation": "Essence", "Kilometrage": 45000, "Distance": 0.12345 }, ... ] }
- Request body example (JSON):
The app.py
file contains the main Flask application which handles the following:
-
Data Loading and Preprocessing:
- Loads vehicle data from
vehicles.csv
. - Fills missing values with the mean of their respective columns.
- Encodes the categorical variable
Motorisation
usingLabelEncoder
. - Standardizes numerical features.
- Loads vehicle data from
-
KMeans Clustering:
- Trains a KMeans model with 5 clusters using the preprocessed data.
-
Vehicle Recommendation:
- Defines a function to find the nearest vehicles to the user's preferences using Euclidean distances.
- Provides an endpoint
/recommander
to get recommendations.
The generate_vehicles.py
script generates a synthetic dataset of 1000 vehicles with random attributes and saves it
as vehicles.csv
.
Feel free to submit issues or pull requests if you have suggestions or improvements.