ammar00200 commited on
Commit
a9410a4
·
verified ·
1 Parent(s): 7baf096

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +68 -0
app.py ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask,jsonify,render_template,request
2
+ import pickle
3
+ import pandas as pd
4
+ import pandas as pd
5
+ import numpy as np
6
+
7
+ # Open the file using 'with' statement
8
+ with open('popular1.pkl', 'rb') as f:
9
+ popular_df = pd.read_pickle(f)
10
+ with open('pt1.pkl', 'rb') as fi:
11
+ pt = pd.read_pickle(fi)
12
+ with open('banquet.pkl', 'rb') as fil:
13
+ banquets = pd.read_pickle(fil)
14
+ with open('similarity_scores1.pkl', 'rb') as file:
15
+ similarity_scores = pd.read_pickle(file)
16
+
17
+
18
+ app = Flask(__name__)
19
+
20
+ @app.route('/')
21
+ def index():
22
+ return render_template(
23
+ 'index.html',
24
+ banquet_img=list(popular_df['Jn12ke src'].values),
25
+ banquet_name=list(popular_df['Hall-Name'].values),
26
+ banquet_reviews=list(popular_df['num_ratings'].values),
27
+ banquet_rating=list(popular_df['Rating_x'].values),
28
+
29
+
30
+ )
31
+ @app.route('/recommend')
32
+ def recommend_ui():
33
+ return render_template(
34
+
35
+ 'Recommend.html'
36
+ )
37
+
38
+ @app.route('/banquet',methods=['post'])
39
+ def recommend():
40
+ user_input=request.form.get('user-input')
41
+
42
+ if user_input not in pt.index:
43
+ return "Banquet not found in the index"
44
+
45
+ index = np.where(pt.index ==user_input)[0][0]
46
+ similar_items = sorted(enumerate(similarity_scores[index]), key=lambda x: x[1], reverse=True)[1:5]
47
+
48
+ data = []
49
+ for i in similar_items:
50
+ item = []
51
+ temp_df = banquets[banquets['Hall-Name'] == pt.index[i[0]]]
52
+ item.extend(temp_df.drop_duplicates('Hall-Name')['Hall-Name'].values)
53
+ item.extend(temp_df.drop_duplicates('Hall-Name')['Address'].values)
54
+ item.extend(temp_df.drop_duplicates('Hall-Name')['Contact'].values)
55
+ item.extend(temp_df.drop_duplicates('Hall-Name')['Rating'].values)
56
+ item.extend(temp_df.drop_duplicates('Hall-Name')['Jn12ke src'].values)
57
+
58
+ data.append(item)
59
+
60
+ print(data)
61
+
62
+ return render_template('Recommend.html', data=data )
63
+
64
+
65
+ if __name__=="__main__":
66
+ app.run(debug=True)
67
+
68
+