File size: 2,134 Bytes
3ad79dc
 
 
249a78a
 
 
 
30938c4
7179595
3ad79dc
 
 
 
 
 
 
 
 
 
64498a2
3ad79dc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64498a2
3ad79dc
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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})


# Funci贸n para preprocesar los datos de entrada
def preprocess_input(values):
    # Aseg煤rate de que los valores est茅n en el formato correcto
    return np.array([values], dtype=np.float32)

# Interfaz de usuario
st.title('Predicci贸n de Precios de Viviendas')

# Campos de entrada para cada par谩metro
#price = st.number_input('Price', format="%.2f")
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")

# Crear una lista con los valores ingresados
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'):
    # Preprocesar los datos de entrada
    processed_input = preprocess_input(input_values)
    
    # Realizar la predicci贸n
    prediction = model.predict(processed_input)
    
    # Mostrar el resultado
    st.write(f'Valor: ${prediction[0][0]:.2f}')