-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
82 lines (53 loc) · 2 KB
/
app.py
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
import streamlit as st
import pickle
import numpy as np
import pandas as pd
import sklearn
with open('scaler.pkl','rb') as file:
scaler = pickle.load(file)
with open('rf_house_price_model.pkl','rb') as file:
model = pickle.load(file)
st.title('Deployment of ML model..')
st.subheader('Testing of deployment')
st.divider()
tab1, tab2, tab3 = st.tabs(['Single prediction','Bulk prediction', 'Selection of Model'])
with tab1:
st.subheader('House information:')
size = st.text_input('House size (in sqft)')
lot_size = st.text_input('Lot size (in sqft)')
bath = st.number_input('No. of bathroom', 1, 4)
bed = st.number_input('No. of bedroom', 1, 5)
zip = st.selectbox("Zip code",[98144, 98106, 98107, 98199])
startPredict = st.button('Estimate Price')
if startPredict==True:
size = int(size)
lot_size = int(size)
zip = int(zip)
data = np.array([bed, bath, size, lot_size, zip])
# st.write(data)
data = scaler.transform(data.reshape(1,-1))
# st.write(data)
result = model.predict(data)
st.write(f"Predicted price: {result}")
st.divider()
with tab2:
file = st.file_uploader('Upload testing data')
if file is not None:
test_data = pd.read_csv(file)
st.dataframe(test_data)
test_data = scaler.transform(test_data)
result = model.predict(test_data)
st.write("Predicted results")
st.write(result)
st.divider()
with tab3:
select_model = st.selectbox('Choose model',['RF','DT','DNN'])
if select_model == 'RF':
with open('rf_house_price_model.pkl','rb') as file:
model_1 = pickle.load(file)
elif select_model == 'DT':
with open('dt_house_price_model.pkl','rb') as file:
model = pickle.load(file)
elif select_model == 'DNN':
with open('svm_house_price_model.pkl','rb') as file:
model = pickle.load(file)