Spaces:
Sleeping
Sleeping
Upload 5 files
Browse files- LabelEncoder_adress.pkl +3 -0
- LabelEncoder_city.pkl +3 -0
- model.pkl +3 -0
- predict_page.py +79 -0
- requirements.txt +6 -0
LabelEncoder_adress.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fc8cee208165c874bc13c3596bb9f1196626a5914770a8b5a9df56d1e9b393f7
|
| 3 |
+
size 12960090
|
LabelEncoder_city.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0f31f870a9b899761525f3e0dfc5613bee0511d6ba149fdb154a6387411b86b0
|
| 3 |
+
size 683431
|
model.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5714fd218000fc20481039e8eb332ddd904987e9dd8b1221cb72edd5885a5012
|
| 3 |
+
size 3304964409
|
predict_page.py
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import joblib
|
| 4 |
+
import numpy as np
|
| 5 |
+
import ast
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
# Charger le modèle pré-entraîné
|
| 10 |
+
model = joblib.load("model.pkl")
|
| 11 |
+
# To load the encoder from the file
|
| 12 |
+
le_for_adres =joblib.load('LabelEncoder_adress.pkl')
|
| 13 |
+
le_for_city =joblib.load('LabelEncoder_city.pkl')
|
| 14 |
+
df = pd.read_excel("resultat.xlsx")
|
| 15 |
+
df = df.reset_index(drop=True)
|
| 16 |
+
|
| 17 |
+
villes = df['nom_commune'].unique()
|
| 18 |
+
|
| 19 |
+
# Créer une interface utilisateur Streamlit
|
| 20 |
+
st.title("Prédiction de la valeur foncière d'un bien immobilier")
|
| 21 |
+
st.write("Bienvenue dans notre outil de prédiction de la valeur foncière.")
|
| 22 |
+
|
| 23 |
+
# Formulaire pour saisir les caractéristiques du bien immobilier
|
| 24 |
+
st.header("Caractéristiques du bien immobilier necessaires pour la prédiction")
|
| 25 |
+
|
| 26 |
+
nom_commune = st.selectbox("Sélectionnez une ville", villes)
|
| 27 |
+
adresse_nom_voie_options = df[df['nom_commune'] == nom_commune]['adresse_nom_voie'].to_list()
|
| 28 |
+
|
| 29 |
+
adresse_nom_voie = st.selectbox("Sélectionnez une adresse", ast.literal_eval(adresse_nom_voie_options[0]))
|
| 30 |
+
|
| 31 |
+
#adresse_nom_voie = st.text_input("Adresse Nom Voie",value='RUE DE LA CHARPINE')
|
| 32 |
+
adresse_numero = st.number_input("Numéro de l'adresse", value=843)
|
| 33 |
+
code_postal = st.number_input("Code postal", value=1000)
|
| 34 |
+
type_local = st.selectbox("Type de local", ['Maison', 'Appartement'])
|
| 35 |
+
surface_reelle_bati = st.number_input("Surface", value=0)
|
| 36 |
+
nombre_pieces_principales = st.number_input("Nombre de pièces principales", value=0, step=1)
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
st.header("Information optionnelle ")
|
| 41 |
+
constructionYear = st.number_input("Année de construction", value=2017)
|
| 42 |
+
print("bbbbb")
|
| 43 |
+
# Bouton pour effectuer la prédiction
|
| 44 |
+
if st.button("Prédire la valeur foncière"):
|
| 45 |
+
|
| 46 |
+
df = pd.DataFrame({
|
| 47 |
+
'adresse_nom_voie': [adresse_nom_voie],
|
| 48 |
+
'adresse_numero': [adresse_numero],
|
| 49 |
+
'nom_commune': [nom_commune],
|
| 50 |
+
'code_postal': [code_postal],
|
| 51 |
+
'surface_reelle_bati': [surface_reelle_bati],
|
| 52 |
+
'nombre_pieces_principales': [nombre_pieces_principales],
|
| 53 |
+
'constructionYear': [constructionYear],
|
| 54 |
+
'type_local': [type_local],
|
| 55 |
+
|
| 56 |
+
})
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
df['type_local'] = df['type_local'].replace({"Appartement": 1, "Maison": 2})
|
| 60 |
+
df['nom_commune']=le_for_city.transform( df['nom_commune'])
|
| 61 |
+
df['adresse_nom_voie'] = le_for_adres.transform(df['adresse_nom_voie'])
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
# Reset the indices of both DataFrames
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
X_test = df.values
|
| 72 |
+
|
| 73 |
+
prediction = model.predict(X_test)
|
| 74 |
+
#prediction = np.expm1( model.predict(X_test, num_iteration=model.best_iteration))
|
| 75 |
+
|
| 76 |
+
st.subheader("Résultat de la prédiction")
|
| 77 |
+
st.write(f"La valeur foncière prédite est : { int(prediction[0])} euros")
|
| 78 |
+
|
| 79 |
+
# Astuce : Vous pouvez personnaliser davantage votre interface utilisateur Streamlit en ajoutant des graphiques, des informations supplémentaires, etc.
|
requirements.txt
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
streamlit
|
| 2 |
+
pandas
|
| 3 |
+
joblib
|
| 4 |
+
numpy
|
| 5 |
+
scikit-learn
|
| 6 |
+
lightgbm
|