gdleds commited on
Commit
4e47a55
·
1 Parent(s): 31954ac
Files changed (3) hide show
  1. Dockerfile +24 -0
  2. README.md +87 -0
  3. requirements.txt +8 -0
Dockerfile ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Image de base
2
+ FROM python:3.10-slim
3
+
4
+ # Définir le répertoire de travail
5
+ WORKDIR /app
6
+
7
+ # Installer les dépendances système utiles (optionnel mais pratique pour scikit-learn, xgboost etc.)
8
+ RUN apt-get update && apt-get install -y \
9
+ build-essential \
10
+ libpq-dev \
11
+ && rm -rf /var/lib/apt/lists/*
12
+
13
+ # Copier requirements.txt et installer
14
+ COPY requirements.txt .
15
+ RUN pip install --no-cache-dir -r requirements.txt
16
+
17
+ # Copier ton code
18
+ COPY . .
19
+
20
+ # Exposer le port (HF attend généralement 7860, mais 8000 marche aussi)
21
+ EXPOSE 8000
22
+
23
+ # Lancer FastAPI avec Uvicorn
24
+ CMD ["uvicorn", "appfast:app", "--host", "0.0.0.0", "--port", "8000"]
README.md CHANGED
@@ -8,4 +8,91 @@ pinned: false
8
  license: apache-2.0
9
  ---
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
8
  license: apache-2.0
9
  ---
10
 
11
+ 🚗 Getaround Car Rental - API de Prédiction
12
+
13
+ Cette API permet de prédire le prix journalier de location d’un véhicule sur Getaround, en fonction de ses caractéristiques techniques (marque, type de carburant, puissance moteur, etc.).
14
+
15
+ Elle est basée sur un modèle XGBoost optimisé et hébergée sur Hugging Face Spaces avec FastAPI.
16
+
17
+ ⚡ Endpoints disponibles
18
+ 🔹 POST /predict
19
+
20
+ Prédit le prix de location journalier.
21
+
22
+ Méthode : POST
23
+
24
+ Entrée (JSON) :
25
+
26
+ {
27
+ "input": [[100000, 120, "diesel", "black", "estate", 1, 1, 0, 0, 1, 0, 1]]
28
+ }
29
+
30
+
31
+ Chaque valeur correspond aux features suivantes :
32
+
33
+ mileage → Kilométrage (ex: 100000)
34
+
35
+ engine_power → Puissance moteur (ex: 120)
36
+
37
+ fuel → Type de carburant (diesel, petrol, electric, hybrid)
38
+
39
+ paint_color → Couleur de la voiture
40
+
41
+ car_type → Type de voiture (estate, sedan, hatchback, etc.)
42
+
43
+ private_parking_available → Parking privé (0/1)
44
+
45
+ has_gps → GPS présent (0/1)
46
+
47
+ has_air_conditioning → Climatisation (0/1)
48
+
49
+ automatic_car → Automatique (0/1)
50
+
51
+ has_getaround_connect → Connect (0/1)
52
+
53
+ has_speed_regulator → Régulateur de vitesse (0/1)
54
+
55
+ winter_tires → Pneus hiver (0/1)
56
+
57
+ Sortie (JSON) :
58
+
59
+ {
60
+ "prediction": [119.5]
61
+ }
62
+
63
+ 🔹 GET /docs
64
+
65
+ Accès à la documentation interactive (Swagger UI).
66
+ 👉 Exemple : https://ton-espace.hf.space/docs
67
+
68
+ 🛠️ Stack technique
69
+
70
+ Python 3.10
71
+
72
+ FastAPI + Uvicorn
73
+
74
+ XGBoost
75
+
76
+ scikit-learn
77
+
78
+ Hugging Face Spaces
79
+
80
+ Stockage du modèle sur S3 (Amazon)
81
+
82
+ 🚀 Exemple avec curl
83
+ curl -X POST "https://ton-espace.hf.space/predict" \
84
+ -H "Content-Type: application/json" \
85
+ -d '{"input": [[100000, 120, "diesel", "black", "estate", 1, 1, 0, 0, 1, 0, 1]]}'
86
+
87
+ 📦 Déploiement local (optionnel)
88
+
89
+ Pour tester localement :
90
+
91
+ uvicorn appfast:app --reload --host 0.0.0.0 --port 8000
92
+
93
+
94
+ Puis tester avec :
95
+ 👉 http://127.0.0.1:8000/docs
96
+
97
+
98
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
requirements.txt ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ fastapi
2
+ uvicorn
3
+ boto3
4
+ joblib
5
+ scikit-learn
6
+ xgboost
7
+ pandas
8
+ python-dotenv