Spaces:
Sleeping
Sleeping
Xantos07
commited on
Commit
·
7ee5a52
1
Parent(s):
debb1e5
Add model and api system
Browse files- app.py +41 -0
- model.joblib +3 -0
- requirements.txt +4 -0
app.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from huggingface_hub import hf_hub_download
|
| 2 |
+
import joblib
|
| 3 |
+
import pandas as pd
|
| 4 |
+
import gradio as gr
|
| 5 |
+
|
| 6 |
+
# Charger le modele depuis Hugging Face
|
| 7 |
+
model_path = hf_hub_download(repo_id="Xantoss/energy_model", filename="model.joblib")
|
| 8 |
+
model = joblib.load(model_path)
|
| 9 |
+
|
| 10 |
+
# Fonction de prediction
|
| 11 |
+
def predict(PropertyGFATotal, PrimaryPropertyType, BuildingAge, NumberofFloors, NumberofBuildings, PctElec, PctSteam):
|
| 12 |
+
df = pd.DataFrame([{
|
| 13 |
+
"PropertyGFATotal": PropertyGFATotal,
|
| 14 |
+
"PrimaryPropertyType": PrimaryPropertyType,
|
| 15 |
+
"BuildingAge": BuildingAge,
|
| 16 |
+
"NumberofFloors": NumberofFloors,
|
| 17 |
+
"NumberofBuildings": NumberofBuildings,
|
| 18 |
+
"PctElec": PctElec,
|
| 19 |
+
"PctSteam": PctSteam
|
| 20 |
+
}])
|
| 21 |
+
prediction = model.predict(df)[0]
|
| 22 |
+
return f"{prediction:,.0f} kBtu"
|
| 23 |
+
|
| 24 |
+
# Interface Gradio
|
| 25 |
+
demo = gr.Interface(
|
| 26 |
+
fn=predict,
|
| 27 |
+
inputs=[
|
| 28 |
+
gr.Number(label="Surface totale (ft²)"),
|
| 29 |
+
gr.Textbox(label="Type de bâtiment (ex: Large Office)"),
|
| 30 |
+
gr.Number(label="Âge du bâtiment"),
|
| 31 |
+
gr.Number(label="Nombre d'étages"),
|
| 32 |
+
gr.Number(label="Nombre de bâtiments"),
|
| 33 |
+
gr.Slider(0, 1, step=0.01, label="Part Électrique"),
|
| 34 |
+
gr.Slider(0, 1, step=0.01, label="Part Vapeur")
|
| 35 |
+
],
|
| 36 |
+
outputs="text",
|
| 37 |
+
title="Prédiction énergétique de bâtiments",
|
| 38 |
+
description="Modèle de Gradient Boosting optimisé. Entrez les infos du bâtiment pour estimer la consommation (kBtu)."
|
| 39 |
+
)
|
| 40 |
+
|
| 41 |
+
demo.launch()
|
model.joblib
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:101f63be17c742ce4a4d70b5ddcb3fd8389bd04214fe82f87fabbd9a9a76a905
|
| 3 |
+
size 196516
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio
|
| 2 |
+
scikit-learn
|
| 3 |
+
pandas
|
| 4 |
+
huggingface_hub
|