Commit
·
341258f
0
Parent(s):
demo pour le model de prediction de prix d'appartements
Browse files- .gitignore +3 -0
- app.py +31 -0
- requirements.txt +4 -0
.gitignore
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
venv/
|
2 |
+
*.joblib
|
3 |
+
.gradio/
|
app.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from joblib import load
|
3 |
+
import requests
|
4 |
+
import os
|
5 |
+
|
6 |
+
# Charger le modèle depuis Hugging Face
|
7 |
+
MODEL_URL = "https://huggingface.co/MarouaneAyech/AppartmentPricePredictor/resolve/main/model.joblib"
|
8 |
+
MODEL_PATH = "model.joblib"
|
9 |
+
|
10 |
+
if not os.path.exists(MODEL_PATH):
|
11 |
+
response = requests.get(MODEL_URL)
|
12 |
+
with open(MODEL_PATH, "wb") as f:
|
13 |
+
f.write(response.content)
|
14 |
+
|
15 |
+
model = load(MODEL_PATH)
|
16 |
+
|
17 |
+
# Fonction de prédiction
|
18 |
+
def predict(features):
|
19 |
+
features = [float(x) for x in features.split()]
|
20 |
+
return model.predict([features])[0]
|
21 |
+
|
22 |
+
# Interface utilisateur avec Gradio
|
23 |
+
interface = gr.Interface(
|
24 |
+
fn=predict,
|
25 |
+
inputs=gr.Textbox(label="Caractéristiques (séparées par des espaces)"),
|
26 |
+
outputs=gr.Textbox(label="Prix prédit"),
|
27 |
+
title="Prédicteur de prix d'appartement"
|
28 |
+
)
|
29 |
+
|
30 |
+
if __name__ == "__main__":
|
31 |
+
interface.launch()
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
joblib
|
3 |
+
requests
|
4 |
+
scikit-learn
|