Spaces:
Runtime error
Runtime error
SameerR007
commited on
Commit
·
fb4cefc
1
Parent(s):
2f43586
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
import pickle
|
4 |
+
movies_data=pickle.load(open("movies_data.pkl","rb"))
|
5 |
+
similarity=pickle.load(open("similarity.pkl","rb"))
|
6 |
+
def recommend(movie):
|
7 |
+
movie_index=movies_data[movies_data['title']==movie].index[0]
|
8 |
+
distances=similarity[movie_index]
|
9 |
+
movies_list_index=sorted(list(enumerate(distances)),reverse=True,key=lambda x:x[1])[1:6]
|
10 |
+
recom_movies=[]
|
11 |
+
for i in movies_list_index:
|
12 |
+
recom_movies.append(movies_data.iloc[i[0]].title)
|
13 |
+
return(recom_movies)
|
14 |
+
|
15 |
+
def main():
|
16 |
+
st.title("Movie Recommendar system")
|
17 |
+
movies_list=movies_data['title']
|
18 |
+
selected=st.selectbox('Which movie have you seen',movies_list)
|
19 |
+
|
20 |
+
if st.button("Recommend"):
|
21 |
+
recommendations=recommend(selected)
|
22 |
+
for i in recommendations:
|
23 |
+
st.write(i)
|
24 |
+
|
25 |
+
if __name__=='__main__':
|
26 |
+
main()
|