Spaces:
Build error
Build error
File size: 3,430 Bytes
13f3e44 | 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 51 52 53 54 55 56 57 58 59 60 61 | import streamlit as st
import pandas as pd
import pickle
def run():
# Load All Files
with open('model.pkl', 'rb') as file:
model = pickle.load(file)
bedrooms = st.number_input(label='Input number of bedrooms', min_value=0.0, max_value=33.0)
bathrooms = st.number_input(label='Input number of bathrooms', min_value=0.0, max_value=8.0)
sqft_living = st.number_input(label='Input size of living room in sqft', min_value=290.0, max_value=13540.0)
sqft_lot = st.number_input(label='Input size of lot in sqft', min_value=520.0, max_value=1651359.0)
floors = st.selectbox(label='Choose number of floors', options=[1.0, 2.0, 1.5, 3.0, 2.5, 3.5])
waterfront = st.selectbox(label='Is there a waterfront?', options=[0, 1])
view = st.selectbox(label='How well is the view?', options=[0, 1, 2, 3, 4])
condition = st.selectbox(label='How well is the condition?', options=[1, 2, 3, 4, 5])
grade = st.number_input(label='What is the grade of the house?', min_value=1.0, max_value=13.0)
sqft_above = st.number_input(label='What is the size of the house apart from the basement?', min_value=290.0, max_value=9410.0)
sqft_basement = st.number_input(label='What is the size of the basement?', min_value=0.0, max_value=4820.0)
yr_built = st.number_input(label='When was the house built?', min_value=1900.0, max_value=2015.0)
yr_renovated = st.number_input(label='When was the house renovated?', min_value=0.0, max_value=2015.0)
zipcode = st.selectbox(label='Choose zipcode', options=[98178, 98125, 98028, 98136, 98074, 98053, 98003, 98198, 98146, 98038, 98007, 98115, 98107, 98126, 98019, 98103, 98002, 98133, 98040, 98092, 98030, 98119, 98112, 98052, 98027, 98117, 98058, 98001, 98056, 98166, 98023, 98070, 98148, 98105, 98042, 98008, 98059, 98122, 98144, 98004, 98005, 98034, 98075, 98116, 98010, 98118, 98199, 98032, 98045, 98102, 98077, 98108, 98168, 98177, 98065, 98029, 98006, 98109, 98022, 98033, 98155, 98024, 98011, 98031, 98106, 98072, 98188, 98014, 98055, 98039])
lat = st.number_input(label='Input the latitude', min_value=47.1559, max_value=47.7776)
long = st.number_input(label='Input the longitude', min_value=-122.519, max_value=-121.315)
sqft_living15 = st.number_input(label='What is the size of the living room in 2015?', min_value=399.0, max_value=6210.0)
sqft_lot15 = st.number_input(label='What is the size of the lot in 2015?', min_value=651.0, max_value=871200.0)
st.write('In the following is the result of the data you have input:')
data_inf = pd.DataFrame({
'bedrooms': [bedrooms],
'bathrooms': [bathrooms],
'sqft_living': [sqft_living],
'sqft_lot': [sqft_lot],
'floors': [floors],
'waterfront': [waterfront],
'view': [view],
'condition': [condition],
'grade': [grade],
'sqft_above': [sqft_above],
'sqft_basement': [sqft_basement],
'yr_built': [yr_built],
'yr_renovated': [yr_renovated],
'zipcode': [zipcode],
'lat': [lat],
'long': [long],
'sqft_living15': [sqft_living15],
'sqft_lot15': [sqft_lot15]
})
st.table(data_inf)
if st.button(label='Predict'):
# Data Dummy prediction
y_pred_inf = model.predict(data_inf)
st.metric(label="Here is a prediction of the house price:", value=y_pred_inf[0])
if __name__ == "__main__":
run()
|