-
Notifications
You must be signed in to change notification settings - Fork 9
/
main.py
199 lines (149 loc) · 4.92 KB
/
main.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
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
import streamlit as st
import pickle
from poi_trialmerged import FINAL
import pandas as pd
import streamlit.components.v1 as components
#import psycopg2
import folium
streamlit_style = """
<style>
@import url('https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,100;0,300;0,400;0,700;1,100&display=swap');
.hotel-bold {
font-weight: 600;
}
.hotel-font {
font-size: 20px;
background-color: #e6f9ff;
}
label.css-1p2iens.effi0qh3{
font-size: 18px;
}
p{
font-size: 18px;
}
li{
font-size: 18px;
}
#MainMenu{
visibility: hidden;
}
button.css-135zi6y.edgvbvh9{
font-size: 18px;
font-weight: 600;
}
</style>
"""
st.markdown(streamlit_style, unsafe_allow_html=True)
#import streamlit_folium
from streamlit_folium import folium_static
# Initialize connection.
# Uses st.experimental_singleton to only run once.
# @st.experimental_singleton
# def init_connection():
# return psycopg2.connect(**st.secrets["postgres"])
# conn = init_connection()
#importlib.import_module('FINAL')
st.markdown('Please find the GitHub Repository for this project [here](https://github.com/ishijo/Travel_Itinerary_Generator).')
st.image('./data/Cover-Img.png')
st.title('Personalised Travel Recommendation and Planner')
pickle_in = open("lol.pkl","rb")
load_lol=pickle.load(pickle_in)
def welcome():
return "Welcome All"
def output_main(Type,Duration,Budget,TYPE,Ques):
"""Let's Authenticate the Banks Note
This is using docstrings for specifications.
---
parameters:
- name: Type
in: query
type: string
required: true
- name: Duration
in: query
type: number
required: true
- name: Budget
in: query
type: number
required: true
- name: Ques
in: query
type: string
required: true
- name: .
in: query
type: number
required: true
responses:
200:
description: The output values
"""
#prediction=classifier.predict([[variance,skewness,curtosis,entropy]])
#print(load_lol)
output,info, map = FINAL(Type,Duration,Budget,TYPE,Ques)
print(output)
return [output,info,map]
def main():
@st.cache(allow_output_mutation=True)
def get_data():
return []
lis1 = ['Adventure and Outdoors','Spiritual','City Life', 'Cultural','Relaxing']
lis2 = ['Family','Friends','Individual']
Type = st.multiselect("Vacation type according to priority:",lis1)
Duration = st.slider("Duration (days)",min_value=1,max_value=40)
Duration = int(Duration)
Budget = st.slider("Budget (INR)",min_value=200,max_value=150000,step=500)
Budget = int(Budget)
col1, col2 = st.columns(2)
TYPE = col1.selectbox("Who are you travelling with?",lis2) ## already filled change
Ques = col2.radio("Is covering maximum places a priority?",['Yes',"No"])
## Condition-Error
cutoff = Budget/Duration
result=""
st.write(' ')
if st.button("What do you recommend?"):
try:
RESULT = output_main(Type,Duration,Budget,TYPE,Ques)
except:
if(cutoff<260):
st.subheader("Irrational. Try increasing your Budget or scaling down the Duration") # FORMAAT
else:
st.subheader("Irrational. Please check your Inputs")
return
get_data().append({"Type": Type, "Duration": Duration,
"Budget": Budget, "TYPE": TYPE, "Ques": Ques})
FINAL_DATA = pd.DataFrame(get_data()) #####
FINAL_DATA.to_csv('data/FinalData.csv') #####
Output = RESULT[0]
Info = RESULT[1]
Map = RESULT[2]
st.subheader('Your Inputs')
st.write('{}'.format(Info[0]))
col3, col4 = st.columns(2)
len(Info)
for i in range(1,len(Info)-5):
try:
col3.write('{}'.format(Info[i]))
except:
continue
for i in range(4,len(Info)-2):
try:
col4.write('{}'.format(Info[i]))
except:
continue
st.write('{}'.format(Info[-2]))
st.header('Suggested Itinerary')
st.markdown('<p class="hotel-font"><span class="hotel-bold">Suggested Hotel/Accomodation:</span> {}<p>'.format(Info[-1]),unsafe_allow_html=True)
st.write(' ')
for i in range(0,len(Output)):
st.write('{}'.format(Output[i])) ##
st_map = folium_static(Map)
#st.markdown(st_map)
# if st.button("Store data"):
# Before_df = pd.read_csv("data/MAIN_Data.csv")
# This_time_df = pd.read_csv('data/FinalData.csv')
# Before_df.append(This_time_df)
# Before_df.to_csv("data/MAIN_Data.csv",index=False)
if __name__=='__main__':
main()