Spaces:
Build error
Build error
Upload 6 files
Browse files- Movie_Recommendation_System-.ipynb +0 -0
- Procfile +1 -0
- apps.py +66 -0
- movies_list.pkl +3 -0
- requirements.txt +52 -0
- setup.sh +13 -0
Movie_Recommendation_System-.ipynb
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
Procfile
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
web: sh setup.sh && streamlit run app.py
|
apps.py
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pickle
|
| 3 |
+
import requests
|
| 4 |
+
import pandas as pd
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
st.set_page_config(page_title=None, page_icon=None, layout="wide", initial_sidebar_state="auto", menu_items=None)
|
| 9 |
+
|
| 10 |
+
movies = pickle.load(open("model/movies_list.pkl",'rb'))
|
| 11 |
+
similarity = pickle.load(open("model/similarity.pkl",'rb'))
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
def fetch_poster(movie_id):
|
| 15 |
+
url = "https://api.themoviedb.org/3/movie/{}?api_key=8735d1698444eb906584226ecb77307b&language=en-US".format(movie_id)
|
| 16 |
+
data = requests.get(url)
|
| 17 |
+
data = data.json()
|
| 18 |
+
poster_path = data['poster_path']
|
| 19 |
+
full_path = "https://image.tmdb.org/t/p/w500/" + poster_path
|
| 20 |
+
return full_path
|
| 21 |
+
|
| 22 |
+
def recommend(movie):
|
| 23 |
+
index = movies[movies['title'] == movie].index[0]
|
| 24 |
+
distances = sorted(list(enumerate(similarity[index])), reverse=True, key=lambda x: x[1])
|
| 25 |
+
recommended_movie_names = []
|
| 26 |
+
recommended_movie_posters = []
|
| 27 |
+
for i in distances[1:6]:
|
| 28 |
+
# fetch the movie poster
|
| 29 |
+
movie_id = movies.iloc[i[0]].movie_id
|
| 30 |
+
recommended_movie_posters.append(fetch_poster(movie_id))
|
| 31 |
+
recommended_movie_names.append(movies.iloc[i[0]].title)
|
| 32 |
+
|
| 33 |
+
return recommended_movie_names,recommended_movie_posters
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
st.header('Movie Recommendation System (Content Based)')
|
| 37 |
+
|
| 38 |
+
st.text("A movie recommendation system, or a movie recommender system, is an ML-based approach to filtering or predicting the users' film preferences ")
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
movie_list = movies['title'].values
|
| 43 |
+
selected_movie = st.selectbox(
|
| 44 |
+
"Type or select a movie from the dropdown",
|
| 45 |
+
movie_list
|
| 46 |
+
)
|
| 47 |
+
|
| 48 |
+
if st.button('Show Recommendation'):
|
| 49 |
+
recommended_movie_names,recommended_movie_posters = recommend(selected_movie)
|
| 50 |
+
col1, col2, col3, col4, col5 = st.columns(5)
|
| 51 |
+
with col1:
|
| 52 |
+
st.text(recommended_movie_names[0])
|
| 53 |
+
st.image(recommended_movie_posters[0])
|
| 54 |
+
with col2:
|
| 55 |
+
st.text(recommended_movie_names[1])
|
| 56 |
+
st.image(recommended_movie_posters[1])
|
| 57 |
+
|
| 58 |
+
with col3:
|
| 59 |
+
st.text(recommended_movie_names[2])
|
| 60 |
+
st.image(recommended_movie_posters[2])
|
| 61 |
+
with col4:
|
| 62 |
+
st.text(recommended_movie_names[3])
|
| 63 |
+
st.image(recommended_movie_posters[3])
|
| 64 |
+
with col5:
|
| 65 |
+
st.text(recommended_movie_names[4])
|
| 66 |
+
st.image(recommended_movie_posters[4])
|
movies_list.pkl
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bf95869ff7334761fcd41790aa16cd06e5f8de07c33aeedaec0b14e46fc78a9b
|
| 3 |
+
size 2614026
|
requirements.txt
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
altair==4.2.0
|
| 2 |
+
attrs==22.1.0
|
| 3 |
+
blinker==1.5
|
| 4 |
+
cachetools==5.2.0
|
| 5 |
+
certifi==2022.9.24
|
| 6 |
+
charset-normalizer==2.1.1
|
| 7 |
+
click==8.1.3
|
| 8 |
+
colorama==0.4.6
|
| 9 |
+
commonmark==0.9.1
|
| 10 |
+
decorator==5.1.1
|
| 11 |
+
entrypoints==0.4
|
| 12 |
+
flask==2.2.2
|
| 13 |
+
gitdb==4.0.10
|
| 14 |
+
GitPython==3.1.29
|
| 15 |
+
idna==3.4
|
| 16 |
+
importlib-metadata==5.1.0
|
| 17 |
+
itsdangerous==2.1.2
|
| 18 |
+
Jinja2==3.1.2
|
| 19 |
+
jsonschema==4.17.3
|
| 20 |
+
MarkupSafe==2.1.1
|
| 21 |
+
numpy==1.23.5
|
| 22 |
+
packaging==21.3
|
| 23 |
+
pandas==1.5.2
|
| 24 |
+
Pillow==9.3.0
|
| 25 |
+
protobuf==3.20.3
|
| 26 |
+
pyarrow==10.0.1
|
| 27 |
+
pydeck==0.8.0
|
| 28 |
+
Pygments==2.13.0
|
| 29 |
+
Pympler==1.0.1
|
| 30 |
+
pyparsing==3.0.9
|
| 31 |
+
pyrsistent==0.19.2
|
| 32 |
+
python-dateutil==2.8.2
|
| 33 |
+
pytz==2022.6
|
| 34 |
+
pytz-deprecation-shim==0.1.0.post0
|
| 35 |
+
requests==2.28.1
|
| 36 |
+
rich==12.6.0
|
| 37 |
+
semver==2.13.0
|
| 38 |
+
six==1.16.0
|
| 39 |
+
sklearn==0.0.post1
|
| 40 |
+
smmap==5.0.0
|
| 41 |
+
streamlit==1.15.2
|
| 42 |
+
toml==0.10.2
|
| 43 |
+
toolz==0.12.0
|
| 44 |
+
tornado==6.2
|
| 45 |
+
typing_extensions==4.4.0
|
| 46 |
+
tzdata==2022.7
|
| 47 |
+
tzlocal==4.2
|
| 48 |
+
urllib3==1.26.13
|
| 49 |
+
validators==0.20.0
|
| 50 |
+
watchdog==2.1.9
|
| 51 |
+
Werkzeug==2.2.2
|
| 52 |
+
zipp==3.11.0
|
setup.sh
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
mkdir -p ~/.streamlit/
|
| 2 |
+
|
| 3 |
+
echo \
|
| 4 |
+
|
| 5 |
+
[server]\n\
|
| 6 |
+
|
| 7 |
+
port = $PORT\n\
|
| 8 |
+
|
| 9 |
+
enableCORS = false\n\
|
| 10 |
+
headless = true\n\
|
| 11 |
+
\n\
|
| 12 |
+
|
| 13 |
+
" > ~/.streamlit/config.toml
|