-
Notifications
You must be signed in to change notification settings - Fork 5
/
app.py
49 lines (35 loc) · 1.19 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
# -*- coding: utf-8 -*-
"""
Created on Wed Aug 25 11:08:30 2021
@author: Chandramouli
"""
import pickle
import streamlit as st
def recommend(movie):
index = movies[movies['Title'] == movie].index[0]
distances = sorted(list(enumerate(similarity[index])), reverse=True, key=lambda x: x[1])
recommended_movie_names = []
for i in distances[1:6]:
recommended_movie_names.append(movies.iloc[i[0]].Title)
return recommended_movie_names
page_bg_img = '''
<style>
.stApp {
background-image: url("https://payload.cargocollective.com/1/11/367710/13568488/MOVIECLASSICSerikweb_2500_800.jpg");
background-size: cover;
}
</style>
'''
st.markdown(page_bg_img, unsafe_allow_html=True)
st.markdown('# Movie Recommendation System')
movies = pickle.load(open('movie_list.pkl','rb'))
similarity = pickle.load(open('similarity.pkl','rb'))
movie_list = movies['Title'].values
selected_movie = st.selectbox(
"Type or select a movie from the dropdown",
movie_list
)
if st.button('Show Recommendation'):
recommended_movie_names = recommend(selected_movie)
for i in recommended_movie_names:
st.subheader(i)