|
|
import streamlit as st |
|
|
import numpy as np |
|
|
|
|
|
from tensorflow.keras.models import load_model |
|
|
from tensorflow.keras.losses import MeanSquaredError |
|
|
|
|
|
mse = MeanSquaredError() |
|
|
model = load_model('REG_houses.h5', custom_objects={'mse': mse}) |
|
|
|
|
|
|
|
|
|
|
|
def preprocess_input(values): |
|
|
|
|
|
return np.array([values], dtype=np.float32) |
|
|
|
|
|
|
|
|
st.title('Predicci贸n de Precios de Viviendas') |
|
|
|
|
|
|
|
|
|
|
|
area = st.number_input('Area', format="%.2f") |
|
|
bedrooms = st.number_input('Bedrooms', format="%.2f") |
|
|
bathrooms = st.number_input('Bathrooms', format="%.2f") |
|
|
stories = st.number_input('Stories', format="%.2f") |
|
|
parking = st.number_input('Parking', format="%.2f") |
|
|
mainroad_yes = st.number_input('Mainroad (1=Yes, 0=No)', format="%.2f") |
|
|
guestroom_yes = st.number_input('Guestroom (1=Yes, 0=No)', format="%.2f") |
|
|
basement_yes = st.number_input('Basement (1=Yes, 0=No)', format="%.2f") |
|
|
hotwaterheating_yes = st.number_input('Hot Water Heating (1=Yes, 0=No)', format="%.2f") |
|
|
airconditioning_yes = st.number_input('Air Conditioning (1=Yes, 0=No)', format="%.2f") |
|
|
prefarea_yes = st.number_input('Preferred Area (1=Yes, 0=No)', format="%.2f") |
|
|
furnishingstatus_semi_furnished = st.number_input('Furnishing Status (Semi-Furnished: 1, Unfurnished: 0)', format="%.2f") |
|
|
furnishingstatus_unfurnished = st.number_input('Furnishing Status (Unfurnished: 1, Semi-Furnished: 0)', format="%.2f") |
|
|
|
|
|
|
|
|
input_values = [ area, bedrooms, bathrooms, stories, parking, |
|
|
mainroad_yes, guestroom_yes, basement_yes, |
|
|
hotwaterheating_yes, airconditioning_yes, prefarea_yes, |
|
|
furnishingstatus_semi_furnished, furnishingstatus_unfurnished |
|
|
] |
|
|
|
|
|
if st.button('Predecir Precio'): |
|
|
|
|
|
processed_input = preprocess_input(input_values) |
|
|
|
|
|
|
|
|
prediction = model.predict(processed_input) |
|
|
|
|
|
|
|
|
st.write(f'Valor: ${prediction[0][0]:.2f}') |