WissamH commited on
Commit
5ef5dcd
·
verified ·
1 Parent(s): aedccf4

Upload 4 files

Browse files
Files changed (4) hide show
  1. Dockerfile +10 -0
  2. api.py +115 -0
  3. model.joblib +3 -0
  4. requirements.txt +137 -0
Dockerfile ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.10
2
+
3
+ WORKDIR /app
4
+
5
+ COPY requirements.txt requirements.txt
6
+ RUN pip install -r requirements.txt
7
+
8
+ COPY . .
9
+
10
+ CMD ["uvicorn", "api:app", "--host", "0.0.0.0", "--port", "7860"]
api.py ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import joblib
2
+ import pandas as pd
3
+
4
+ from fastapi import FastAPI
5
+ from fastapi.responses import HTMLResponse
6
+ from pydantic import BaseModel
7
+
8
+
9
+ app = FastAPI(
10
+ title="API de prédiction de prix Getaround",
11
+ description="API permettant de prédire le prix de location par jour d’un véhicule",
12
+ version="1.0",
13
+ docs_url="/api-docs"
14
+ )
15
+
16
+ model = joblib.load("model.joblib")
17
+
18
+
19
+ class CarFeatures(BaseModel):
20
+ model_key: str
21
+ mileage: int
22
+ engine_power: int
23
+ fuel: str
24
+ paint_color: str
25
+ car_type: str
26
+ private_parking_available: bool
27
+ has_gps: bool
28
+ has_air_conditioning: bool
29
+ automatic_car: bool
30
+ has_getaround_connect: bool
31
+ has_speed_regulator: bool
32
+ winter_tires: bool
33
+
34
+
35
+ @app.get("/")
36
+ def accueil():
37
+ return {"message": "Bienvenue sur l'API de prédiction de prix Getaround"}
38
+
39
+
40
+ @app.post("/predict")
41
+ def predict(features: CarFeatures):
42
+ data = pd.DataFrame([features.model_dump()])
43
+ prediction = model.predict(data)[0]
44
+
45
+ return {
46
+ "prix_location_par_jour": round(prediction, 2)
47
+ }
48
+
49
+
50
+ @app.get("/docs", response_class=HTMLResponse)
51
+ def documentation():
52
+ return """
53
+ <html>
54
+ <head>
55
+ <title>Documentation API Getaround</title>
56
+ </head>
57
+ <body>
58
+ <h1>🚗 API de prédiction de prix Getaround</h1>
59
+
60
+ <p>
61
+ Cette API permet de prédire le prix de location par jour d’un véhicule
62
+ en fonction de ses caractéristiques.
63
+ </p>
64
+
65
+ <h2>Endpoints disponibles</h2>
66
+
67
+ <h3>GET /</h3>
68
+ <p><strong>Description :</strong> retourne un message de bienvenue.</p>
69
+ <p><strong>Entrée :</strong> aucune.</p>
70
+ <p><strong>Sortie attendue :</strong></p>
71
+ <pre>
72
+ {
73
+ "message": "Bienvenue sur l'API de prédiction de prix Getaround"
74
+ }
75
+ </pre>
76
+
77
+ <h3>POST /predict</h3>
78
+ <p><strong>Description :</strong> prédit le prix de location par jour d’un véhicule.</p>
79
+
80
+ <p><strong>Entrée requise :</strong> un objet JSON contenant les caractéristiques du véhicule.</p>
81
+
82
+ <pre>
83
+ {
84
+ "model_key": "Peugeot",
85
+ "mileage": 50000,
86
+ "engine_power": 120,
87
+ "fuel": "diesel",
88
+ "paint_color": "black",
89
+ "car_type": "sedan",
90
+ "private_parking_available": true,
91
+ "has_gps": true,
92
+ "has_air_conditioning": true,
93
+ "automatic_car": false,
94
+ "has_getaround_connect": true,
95
+ "has_speed_regulator": true,
96
+ "winter_tires": false
97
+ }
98
+ </pre>
99
+
100
+ <p><strong>Sortie attendue :</strong></p>
101
+
102
+ <pre>
103
+ {
104
+ "prix_location_par_jour": 100.35
105
+ }
106
+ </pre>
107
+
108
+ <h2>Tester l’API</h2>
109
+ <p>
110
+ Une documentation interactive Swagger est disponible ici :
111
+ <a href="/api-docs">/api-docs</a>
112
+ </p>
113
+ </body>
114
+ </html>
115
+ """
model.joblib ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:137085120fe0df9974f3d50888f0e3cc7d509a5fcd2acbccab10d9b0bd1ecc49
3
+ size 32843754
requirements.txt ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ altair==6.0.0
2
+ annotated-doc==0.0.4
3
+ annotated-types==0.7.0
4
+ anyio==4.13.0
5
+ appnope==0.1.4
6
+ argon2-cffi==25.1.0
7
+ argon2-cffi-bindings==25.1.0
8
+ arrow==1.4.0
9
+ asttokens==3.0.1
10
+ async-lru==2.3.0
11
+ attrs==26.1.0
12
+ babel==2.18.0
13
+ beautifulsoup4==4.14.3
14
+ bleach==6.3.0
15
+ blinker==1.9.0
16
+ cachetools==7.0.5
17
+ certifi==2026.2.25
18
+ cffi==2.0.0
19
+ charset-normalizer==3.4.7
20
+ click==8.3.2
21
+ comm==0.2.3
22
+ contourpy==1.3.3
23
+ cycler==0.12.1
24
+ debugpy==1.8.20
25
+ decorator==5.2.1
26
+ defusedxml==0.7.1
27
+ et_xmlfile==2.0.0
28
+ executing==2.2.1
29
+ fastapi==0.136.0
30
+ fastjsonschema==2.21.2
31
+ fonttools==4.62.1
32
+ fqdn==1.5.1
33
+ gitdb==4.0.12
34
+ GitPython==3.1.46
35
+ h11==0.16.0
36
+ httpcore==1.0.9
37
+ httpx==0.28.1
38
+ idna==3.11
39
+ ipykernel==7.2.0
40
+ ipython==9.12.0
41
+ ipython_pygments_lexers==1.1.1
42
+ ipywidgets==8.1.8
43
+ isoduration==20.11.0
44
+ jedi==0.19.2
45
+ Jinja2==3.1.6
46
+ joblib==1.5.3
47
+ json5==0.14.0
48
+ jsonpointer==3.1.1
49
+ jsonschema==4.26.0
50
+ jsonschema-specifications==2025.9.1
51
+ jupyter==1.1.1
52
+ jupyter-console==6.6.3
53
+ jupyter-events==0.12.0
54
+ jupyter-lsp==2.3.1
55
+ jupyter_client==8.8.0
56
+ jupyter_core==5.9.1
57
+ jupyter_server==2.17.0
58
+ jupyter_server_terminals==0.5.4
59
+ jupyterlab==4.5.6
60
+ jupyterlab_pygments==0.3.0
61
+ jupyterlab_server==2.28.0
62
+ jupyterlab_widgets==3.0.16
63
+ kiwisolver==1.5.0
64
+ lark==1.3.1
65
+ MarkupSafe==3.0.3
66
+ matplotlib==3.10.8
67
+ matplotlib-inline==0.2.1
68
+ mistune==3.2.0
69
+ narwhals==2.19.0
70
+ nbclient==0.10.4
71
+ nbconvert==7.17.1
72
+ nbformat==5.10.4
73
+ nest-asyncio==1.6.0
74
+ notebook==7.5.5
75
+ notebook_shim==0.2.4
76
+ numpy==2.4.4
77
+ openpyxl==3.1.5
78
+ packaging==26.1
79
+ pandas==3.0.2
80
+ pandocfilters==1.5.1
81
+ parso==0.8.6
82
+ pexpect==4.9.0
83
+ pillow==12.2.0
84
+ platformdirs==4.9.6
85
+ plotly==6.7.0
86
+ prometheus_client==0.25.0
87
+ prompt_toolkit==3.0.52
88
+ protobuf==7.34.1
89
+ psutil==7.2.2
90
+ ptyprocess==0.7.0
91
+ pure_eval==0.2.3
92
+ pyarrow==23.0.1
93
+ pycparser==3.0
94
+ pydantic==2.13.1
95
+ pydantic_core==2.46.1
96
+ pydeck==0.9.2
97
+ Pygments==2.20.0
98
+ pyparsing==3.3.2
99
+ python-dateutil==2.9.0.post0
100
+ python-json-logger==4.1.0
101
+ PyYAML==6.0.3
102
+ pyzmq==27.1.0
103
+ referencing==0.37.0
104
+ requests==2.33.1
105
+ rfc3339-validator==0.1.4
106
+ rfc3986-validator==0.1.1
107
+ rfc3987-syntax==1.1.0
108
+ rpds-py==0.30.0
109
+ scikit-learn==1.8.0
110
+ scipy==1.17.1
111
+ seaborn==0.13.2
112
+ Send2Trash==2.1.0
113
+ setuptools==82.0.1
114
+ six==1.17.0
115
+ smmap==5.0.3
116
+ soupsieve==2.8.3
117
+ stack-data==0.6.3
118
+ starlette==1.0.0
119
+ streamlit==1.56.0
120
+ tenacity==9.1.4
121
+ terminado==0.18.1
122
+ threadpoolctl==3.6.0
123
+ tinycss2==1.4.0
124
+ toml==0.10.2
125
+ tornado==6.5.5
126
+ traitlets==5.14.3
127
+ typing-inspection==0.4.2
128
+ typing_extensions==4.15.0
129
+ tzdata==2026.1
130
+ uri-template==1.3.0
131
+ urllib3==2.6.3
132
+ uvicorn==0.44.0
133
+ wcwidth==0.6.0
134
+ webcolors==25.10.0
135
+ webencodings==0.5.1
136
+ websocket-client==1.9.0
137
+ widgetsnbextension==4.0.15