File size: 3,951 Bytes
861644b
dcf0d9b
861644b
 
 
8da7f3a
becf758
861644b
 
 
 
931c9b2
861644b
13ef3dd
861644b
0ceb0cb
931c9b2
 
dcf0d9b
bad8bf8
 
 
861644b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8aafa5b
a6230e3
 
861644b
 
867e7a8
861644b
 
35e8040
 
861644b
 
 
 
35e8040
 
 
 
861644b
 
 
 
 
 
 
 
 
35e8040
 
 
 
66eef12
861644b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1c0d5d4
 
 
 
 
861644b
 
 
 
 
ed792be
0d5ab99
ed792be
bad8bf8
 
 
5122299
dcf0d9b
ed792be
dcf0d9b
2d0ffb3
0d5ab99
f831fba
 
e66fe67
16ceabd
f831fba
e66fe67
 
2f31511
7021cf4
861644b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f996380
 
861644b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62b612c
861644b
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183

# importing libraries
import streamlit as st
import pandas as pd
import numpy as np
import pickle

np.random.seed(42)

st.markdown("<body style ='color:#E2E0D9;'></body>", unsafe_allow_html=True)

st.markdown("<h4 style='text-align: center; color: #1B9E91;'>House Price Prediction in Ames, Iowa</h4>", unsafe_allow_html=True)

st.markdown("<h5 style='text-align: center; color: #1B9E91;'>Optuna optimized LGBM model to estimate the range of house prices based on your selection. </h5>", unsafe_allow_html=True)

st.write("If you want to know the numbers that you picked for some of the features such as Overall Quality, Sale Conditions etc., please check the following link")
st.write("[link to the categorical encoding](https://github.com/aye-thuzar/CS634Project/edit/main/docs.md)")



#setting up the sliders and getting the input the sliders

name_list = [
 'OverallQual',
 'YearBuilt',
 'TotalBsmtSF',
 'GrLivArea',
 'MasVnrArea',
 'BsmtFinType1',
 'Neighborhood',
 'GarageType',
 'SaleCondition',
 'BsmtExposure']

description_list = [
 'What is the Overall material and finish quality?',
 'In which year was the Original construction date?',
 'What is the Total square feet of basement area?',
 'What is the Above grade (ground) living area in square feet?',
 'What is the Masonry veneer area in square feet?',
 'What is the Quality of the basement finished area?',
 'Where are the physical locations within Ames city limits?',
 'Where is the location of the Garage?',
 'What is the condition of the sale?',
 'What is the basement exposure: walkout or garden-level basement walls?'
 ]

min_list = [
 1.0,
 1950.0,
 0.0,
 0.0,
 334.0,
 1.0,
 1.0,
 1.0,
 1.0,
 0.0
]

max_list = [
 10.0,
 2010.0,
 2336.0,
 6110.0,
 4692.0,
 7.0,
 25.0,
 7.0,
 6.0,
 5.0,
]

count = 0

with st.sidebar:

    for i in range(len(name_list)):

            

        variable_name = name_list[i]
        globals()[variable_name] = st.slider(description_list[i] ,min_value=int(min_list[i]), max_value =int(max_list[i]),step=1)
      
    st.write("[Kaggle Link to Data Set](https://www.kaggle.com/competitions/house-prices-advanced-regression-techniques)")


data_df = {

 'OverallQual': [OverallQual],
 'YearBuilt': [YearBuilt],
 'TotalBsmtSF': [TotalBsmtSF],
 'GrLivArea':[GrLivArea],
 'MasVnrArea': [MasVnrArea],
 'BsmtFinType1': [BsmtFinType1],
 'Neighborhood': [Neighborhood],
 'GarageType': [GarageType],
 'SaleCondition': [SaleCondition],
 'BsmtExposure': [BsmtExposure]
}

data_df = pd.DataFrame.from_dict(data_df)

st.write("Please adjust the feature values using the slides on the left: ")
st.write(data_df.head())


#normalizing the data

diff = np.array(max_list)-np.array(min_list)
data_df = (data_df.values - np.array(min_list)) / diff

st.write("Normalized input data")
st.write(data_df)

# load trained model
lgbm_base = pickle.load(open('lgbm_base.pkl', 'rb'))
lgbm_opt = pickle.load(open('lgbm_opt_test.pkl', 'rb'))
xgb = pickle.load(open('xgb_model.pkl', 'rb'))



y_pred_xgb = xgb.predict(data_df)
y_pred_optimized = lgbm_opt.predict(data_df)

col1, col2, col3 , col4, col5 = st.columns(5)

with col1:
    pass
with col2:
    pass
with col4:
    pass
with col5:
    pass
with col3 :
    center_button = st.button('Calculate range of house price')



if center_button:

    import time

    #my_bar = st.progress(0)

    with st.spinner('Calculating....'):
        time.sleep(2)



    st.markdown("<h5 style='text-align: center; color: #1B9E91;'>The price range of your house is between:</h5>", unsafe_allow_html=True)


    col1, col2 = st.columns([3, 3])

    lower_number = "{:,.2f}".format(y_pred_xgb[0])
    higher_number = "{:,.2f}".format(y_pred_xgb[0])

    col1, col2, col3 = st.columns(3)

    

    with col1:
        st.write("")

    with col2:
        st.subheader("USD "+ str(lower_number))
        st.subheader("       AND ")

        st.subheader(" USD "+str(higher_number))


    with col3:
        st.write("")