Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from tensorflow.keras.models import load_model
|
| 3 |
+
import numpy as np
|
| 4 |
+
|
| 5 |
+
# Cargar el modelo Keras
|
| 6 |
+
model = load_model('model1_m1.h5')
|
| 7 |
+
|
| 8 |
+
# Funci贸n para preprocesar los datos de entrada
|
| 9 |
+
def preprocess_input(values):
|
| 10 |
+
# Aseg煤rate de que los valores est茅n en el formato correcto
|
| 11 |
+
return np.array([values], dtype=np.float32)
|
| 12 |
+
|
| 13 |
+
# Interfaz de usuario
|
| 14 |
+
st.title('Predicci贸n de Precios de Viviendas')
|
| 15 |
+
|
| 16 |
+
# Campos de entrada para cada par谩metro
|
| 17 |
+
price = st.number_input('Price', format="%.2f")
|
| 18 |
+
area = st.number_input('Area', format="%.2f")
|
| 19 |
+
bedrooms = st.number_input('Bedrooms', format="%.2f")
|
| 20 |
+
bathrooms = st.number_input('Bathrooms', format="%.2f")
|
| 21 |
+
stories = st.number_input('Stories', format="%.2f")
|
| 22 |
+
parking = st.number_input('Parking', format="%.2f")
|
| 23 |
+
mainroad_yes = st.number_input('Mainroad (1=Yes, 0=No)', format="%.2f")
|
| 24 |
+
guestroom_yes = st.number_input('Guestroom (1=Yes, 0=No)', format="%.2f")
|
| 25 |
+
basement_yes = st.number_input('Basement (1=Yes, 0=No)', format="%.2f")
|
| 26 |
+
hotwaterheating_yes = st.number_input('Hot Water Heating (1=Yes, 0=No)', format="%.2f")
|
| 27 |
+
airconditioning_yes = st.number_input('Air Conditioning (1=Yes, 0=No)', format="%.2f")
|
| 28 |
+
prefarea_yes = st.number_input('Preferred Area (1=Yes, 0=No)', format="%.2f")
|
| 29 |
+
furnishingstatus_semi_furnished = st.number_input('Furnishing Status (Semi-Furnished: 1, Unfurnished: 0)', format="%.2f")
|
| 30 |
+
furnishingstatus_unfurnished = st.number_input('Furnishing Status (Unfurnished: 1, Semi-Furnished: 0)', format="%.2f")
|
| 31 |
+
|
| 32 |
+
# Crear una lista con los valores ingresados
|
| 33 |
+
input_values = [
|
| 34 |
+
price, area, bedrooms, bathrooms, stories, parking,
|
| 35 |
+
mainroad_yes, guestroom_yes, basement_yes,
|
| 36 |
+
hotwaterheating_yes, airconditioning_yes, prefarea_yes,
|
| 37 |
+
furnishingstatus_semi_furnished, furnishingstatus_unfurnished
|
| 38 |
+
]
|
| 39 |
+
|
| 40 |
+
if st.button('Predecir Precio'):
|
| 41 |
+
# Preprocesar los datos de entrada
|
| 42 |
+
processed_input = preprocess_input(input_values)
|
| 43 |
+
|
| 44 |
+
# Realizar la predicci贸n
|
| 45 |
+
prediction = model.predict(processed_input)
|
| 46 |
+
|
| 47 |
+
# Mostrar el resultado
|
| 48 |
+
st.write(f'Valor: ${prediction[0][0]:.2f}')
|