-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
79 lines (59 loc) · 1.87 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
# Libraries
import streamlit as st
import requests
# Custom Files
from encoding import *
from customData import *
URL = 'https://barcelona-rent-predictor.onrender.com'
#Local Host -> 'http://127.0.0.1:8000' # API hosted site
# Header
st.set_page_config(
page_title="Barcelona Rents",
page_icon="🪙",
layout="wide"
)
# Intro
st.markdown("<h1 style = 'text-align:center;'> Welcome to Barcelona Rents 🪙 </h1>", unsafe_allow_html=True)
st.write('''###### Explore My Code Here: https://github.com/Grace-Hephzibah/BarcelonaRent-Predictor ''')
st.write('''###### Kaggle: https://www.kaggle.com/code/gracehephzibahm/prediction-of-rent-prices-in-barcelona ''')
st.divider()
# Data required for prediction
a,b,c = st.columns(3)
with a:
min_year = min(year_var)
year = st.number_input('Year', min_value = min_year)
with b:
min_trimester = min(trimester_var)
max_trimester = max(trimester_var)
trimester = st.number_input('Trimester',min_value = min_trimester, max_value = max_trimester)
with c:
district = st.selectbox('District', dist_encoding.keys())
d,e = st.columns(2)
with d:
neighbourhood = st.selectbox('Neighbourhood', neigh_encoding.keys())
with e:
avg_rent = st.selectbox('Average Rent Type', rent_encoding.keys())
# Preparing the request Body
request_body = {
"Year" : year,
"Trimester" : trimester,
"District" : district,
"Neighbourhood" : neighbourhood,
"Average_rent" : avg_rent
}
status_submit = st.button("Submit")
st.divider()
# Answer section
f, g, h = st.columns([1,2,4])
ans_val = 'Click Submit!'
with f:
st.write('<h3>Prediction : </h3>', unsafe_allow_html=True)
with g:
ans = st.empty()
ans.code(ans_val)
with h:
st.write(" ")
if status_submit:
response = requests.get(URL, json = request_body).json()
ans.code(response['prediction'])
st.divider()