Spaces:
Build error
Build error
Commit ·
5360768
1
Parent(s): 2d50ace
Upload 9 files
Browse files- app.py +73 -0
- content.pkl +3 -0
- content_dict.pkl +3 -0
- cosine_similarity.pkl +3 -0
- recommend.pkl +3 -0
- requirements.txt +0 -0
- teamcolab_netflixmoviesandtvshowsclustering_shahrukh.py +0 -0
- tfidf.pkl +3 -0
- tfidf_matrix.pkl +3 -0
app.py
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
######################################################
|
| 2 |
+
# Importing necessary libraries
|
| 3 |
+
import streamlit as st
|
| 4 |
+
import pickle
|
| 5 |
+
import pandas as pd
|
| 6 |
+
|
| 7 |
+
#######################################################
|
| 8 |
+
# Loading the pickle file
|
| 9 |
+
content_dict= pickle.load(open('content_dict.pkl','rb'))
|
| 10 |
+
|
| 11 |
+
# Converting dictionary into pandas DataFrame
|
| 12 |
+
content= pd.DataFrame(content_dict)
|
| 13 |
+
|
| 14 |
+
# Loding the pickle file
|
| 15 |
+
similarity= pickle.load(open('cosine_similarity.pkl','rb'))
|
| 16 |
+
|
| 17 |
+
#######################################################
|
| 18 |
+
# Defining a function for recommendation system
|
| 19 |
+
def recommend(title, cosine_sim=similarity, data=content):
|
| 20 |
+
recommended_content=[]
|
| 21 |
+
# Get the index of the input title in the programme_list
|
| 22 |
+
programme_list = data['title'].to_list()
|
| 23 |
+
index = programme_list.index(title)
|
| 24 |
+
|
| 25 |
+
# Create a list of tuples containing the similarity score and index
|
| 26 |
+
# between the input title and all other programmes in the dataset
|
| 27 |
+
sim_scores = list(enumerate(cosine_sim[index]))
|
| 28 |
+
|
| 29 |
+
# Sort the list of tuples by similarity score in descending order
|
| 30 |
+
sim_scores = sorted(sim_scores, key=lambda x: x[1], reverse=True)[1:11]
|
| 31 |
+
|
| 32 |
+
# Get the recommended movie titles and their similarity scores
|
| 33 |
+
recommend_index = [i[0] for i in sim_scores]
|
| 34 |
+
rec_movie = data['title'].iloc[recommend_index]
|
| 35 |
+
rec_score = [round(i[1], 4) for i in sim_scores]
|
| 36 |
+
|
| 37 |
+
# Create a pandas DataFrame to display the recommendations
|
| 38 |
+
rec_table = pd.DataFrame(list(zip(rec_movie, rec_score)), columns=['Recommendation', 'Similarity_score(0-1)'])
|
| 39 |
+
# recommended_content.append(rec_table['Recommendation'].values)
|
| 40 |
+
|
| 41 |
+
return rec_table['Recommendation'].values
|
| 42 |
+
|
| 43 |
+
#######################################################
|
| 44 |
+
# # Loading the pickle file
|
| 45 |
+
# content_dict= pickle.load(open('content_dict.pkl','rb'))
|
| 46 |
+
|
| 47 |
+
# # Converting dictionary into pandas DataFrame
|
| 48 |
+
# content= pd.DataFrame(content_dict)
|
| 49 |
+
|
| 50 |
+
# # Loding the pickle file
|
| 51 |
+
# similarity= pickle.load(open('cosine_similarity.pkl','rb'))
|
| 52 |
+
|
| 53 |
+
########################################################
|
| 54 |
+
# Displaying title
|
| 55 |
+
st.title("Netflix Recommender System")
|
| 56 |
+
|
| 57 |
+
# Display dialogue box that contains content
|
| 58 |
+
selected_content_name = st.selectbox(
|
| 59 |
+
'Which Movie/TV Show are you watching?',
|
| 60 |
+
content['title'].values)
|
| 61 |
+
st.write('**Note**: We have the data till 2019 only.')
|
| 62 |
+
#########################################################
|
| 63 |
+
|
| 64 |
+
# Setting a button
|
| 65 |
+
if st.button('Recommend'):
|
| 66 |
+
recommendations= recommend(title=selected_content_name)
|
| 67 |
+
st.write('**_You are watching:_**', selected_content_name)
|
| 68 |
+
st.write('**_Your top 10 recommendations:_**')
|
| 69 |
+
for num,i in enumerate(recommendations):
|
| 70 |
+
st.write(num+1,':', i)
|
| 71 |
+
|
| 72 |
+
# Last note
|
| 73 |
+
st.write('_Lights out, popcorn in hand, and let the movies begin! We hope our recommendations hit the spot._:smile:')
|
content.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1e366a1e58d083ba23635855fb173d811a8ec30a1c54cd0a581cd52ee0b55cac
|
| 3 |
+
size 10107932
|
content_dict.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:02c7c712ba520b713b35581143b0fe070710cf39ec225c71adbbce35b1a0dd66
|
| 3 |
+
size 10312847
|
cosine_similarity.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4d7016172d6a2f870b8cbcdcabd7e75bc58535dc3e3e6cbe24fcca83a835eadb
|
| 3 |
+
size 482983363
|
recommend.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1212366ceb56df7555e013fd1a567c4dfadd1a8c65059d9ca62438d7cec9f298
|
| 3 |
+
size 45
|
requirements.txt
ADDED
|
Binary file (1.69 kB). View file
|
|
|
teamcolab_netflixmoviesandtvshowsclustering_shahrukh.py
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
tfidf.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0397536ca0d45239f9622c039f91e443670e524085c405dfcc535b8764d292b3
|
| 3 |
+
size 1324438
|
tfidf_matrix.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c99d328016ea1889fc88f3502e7ef9534f673842ad2270efd432057d0ebd26f3
|
| 3 |
+
size 3424782
|