Xantoss commited on
Commit
2c5c0ce
·
verified ·
1 Parent(s): 7ee5a52

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -41
app.py CHANGED
@@ -1,41 +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()
 
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"),
29
+ gr.Textbox(label="Type de bâtiment (ex: Hotel)"),
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()