-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
30 lines (23 loc) · 847 Bytes
/
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
import pandas as pd
import streamlit as st
import pickle
def recommend(movie):
movie_index =movies[movies['title'] == movie].index[0]
distances = similarity[movie_index]
movies_list = sorted(list(enumerate(distances)), reverse=True, key=lambda x: x[1])[1:6]
recommended_movies=[]
for i in movies_list:
movie_id=i[0]
recommended_movies.append(movies.iloc[i[0]].title)
return recommended_movies
movie_dict = pickle.load(open('movies.pkl','rb'))
movies=pd.DataFrame(movie_dict)
similarity=pickle.load(open('similarity.pkl','rb'))
st.title('movie recommender system')
option=st.selectbox(
'Choose a movie to find similar ones', movies['title'].values
)
if st.button('Recommend'):
recommendations=recommend(option)
for i in recommendations:
st.write(i)