JaydeepR commited on
Commit
63fb4a7
·
1 Parent(s): 4a55e0c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +63 -0
app.py CHANGED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import streamlit as st
3
+ import pickle
4
+ import pandas as pd
5
+ import numpy as np
6
+
7
+ st.set_page_config(page_title="Viz Demo")
8
+
9
+ file_df = r"C:/Users/jraij/Downloads/df.pkl"
10
+ file_pipe = r"C:/Users/jraij/Downloads/pipeline.pkl"
11
+
12
+ with open(file_df,'rb') as file:
13
+ df = pickle.load(file)
14
+
15
+ with open(file_pipe,'rb') as file:
16
+ pipeline = pickle.load(file)
17
+
18
+
19
+ st.header('Enter your inputs')
20
+
21
+ # property_type
22
+ property_type = st.selectbox('Property Type',['flat','house'])
23
+
24
+ # sector
25
+ sector = st.selectbox('Sector',sorted(df['sector'].unique().tolist()))
26
+
27
+ bedrooms = float(st.selectbox('Number of Bedroom',sorted(df['bedRoom'].unique().tolist())))
28
+
29
+ bathroom = float(st.selectbox('Number of Bathrooms',sorted(df['bathroom'].unique().tolist())))
30
+
31
+ balcony = st.selectbox('Balconies',sorted(df['balcony'].unique().tolist()))
32
+
33
+ property_age = st.selectbox('Property Age',sorted(df['agePossession'].unique().tolist()))
34
+
35
+ built_up_area = float(st.number_input('Built Up Area'))
36
+
37
+ servant_room = float(st.selectbox('Servant Room',[0.0, 1.0]))
38
+ store_room = float(st.selectbox('Store Room',[0.0, 1.0]))
39
+
40
+ furnishing_type = st.selectbox('Furnishing Type',sorted(df['furnishing_type'].unique().tolist()))
41
+ luxury_category = st.selectbox('Luxury Category',sorted(df['luxury_category'].unique().tolist()))
42
+ floor_category = st.selectbox('Floor Category',sorted(df['floor_category'].unique().tolist()))
43
+
44
+ if st.button('Predict'):
45
+
46
+ # form a dataframe
47
+ data = [[property_type, sector, bedrooms, bathroom, balcony, property_age, built_up_area, servant_room, store_room, furnishing_type, luxury_category, floor_category]]
48
+ columns = ['property_type', 'sector', 'bedRoom', 'bathroom', 'balcony',
49
+ 'agePossession', 'built_up_area', 'servant room', 'store room',
50
+ 'furnishing_type', 'luxury_category', 'floor_category']
51
+
52
+ # Convert to DataFrame
53
+ one_df = pd.DataFrame(data, columns=columns)
54
+
55
+ #st.dataframe(one_df)
56
+
57
+ # predict
58
+ base_price = np.expm1(pipeline.predict(one_df))[0]
59
+ low = base_price - 0.22
60
+ high = base_price + 0.22
61
+
62
+ # display
63
+ st.text("The price of the flat is between {} Cr and {} Cr".format(round(low,2),round(high,2)))