coder003 commited on
Commit
10ade8d
·
1 Parent(s): a8fd644

Upload 5 files

Browse files
Files changed (5) hide show
  1. README.md +20 -0
  2. app.py +63 -0
  3. movie_dict.pkl +3 -0
  4. movie_recommendation_system.ipynb +0 -0
  5. movies.pkl +3 -0
README.md ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ # Movie Recommendation System🚀
3
+
4
+ A movie recommender that recommends five movies based on the movie input.
5
+ It uses a KNN model that works on the concept text vectorization.
6
+
7
+
8
+ ## Screenshots
9
+
10
+ ![](https://github.com/VividhPandey003/movie_recommendation_system/blob/main/images/1.png)
11
+ ---
12
+ ![](https://github.com/VividhPandey003/movie_recommendation_system/blob/main/images/2.png)
13
+ ---
14
+ ![](https://github.com/VividhPandey003/movie_recommendation_system/blob/main/images/3.png)
15
+ ---
16
+ ![](https://github.com/VividhPandey003/movie_recommendation_system/blob/main/images/4.png)
17
+
18
+
19
+ ### Try it on your own 💻
20
+ [Movie Recommendation System Deployment](https://huggingface.co/spaces/coder003/movie-recommender)
app.py ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pickle
3
+ import pandas as pd
4
+ import requests
5
+
6
+
7
+ def fetch_poster(movie_id):
8
+ url = "https://api.themoviedb.org/3/movie/{}?api_key=fe34a557846e9a676a98fd362f059b28&language=en-US".format(
9
+ movie_id)
10
+ response = requests.get(url)
11
+ data = response.json()
12
+ poster_path = data['poster_path']
13
+ full_path = "https://image.tmdb.org/t/p/w500/" + poster_path
14
+ return full_path
15
+
16
+
17
+ def recommend(movie):
18
+ movie_index = movies[movies['title'] == movie].index[0]
19
+ distances = similarity[movie_index]
20
+ movies_list = sorted(list(enumerate(distances)), reverse=True, key=lambda x: x[1])[1:6]
21
+
22
+ recommended_movies = []
23
+ recommended_movies_posters = []
24
+ for i in movies_list:
25
+ movie_id = movies.iloc[i[0]].movie_id
26
+
27
+ recommended_movies.append(movies.iloc[i[0]].title)
28
+ # using movie_id fetch poster from API
29
+ recommended_movies_posters.append(fetch_poster(movie_id))
30
+ return recommended_movies,recommended_movies_posters
31
+
32
+
33
+ st.title('Movie Recommender System')
34
+ st.text('👨🏻‍💻 by Vividh Pandey')
35
+ movies_dict = pickle.load(open('movie_dict.pkl', 'rb'))
36
+ movies = pd.DataFrame(movies_dict)
37
+
38
+ similarity = pickle.load(open('similarity.pkl', 'rb'))
39
+
40
+ movie_list = movies['title'].values
41
+ selected_movie_name = st.selectbox(
42
+ "Type or select a movie from the dropdown",
43
+ movies['title'].values
44
+ )
45
+
46
+ if st.button('Show Recommendation'):
47
+ names,posters = recommend(selected_movie_name)
48
+ col1, col2, col3, col4, col5 = st.columns(5)
49
+ with col1:
50
+ st.text(names[0])
51
+ st.image(posters[0])
52
+ with col2:
53
+ st.text(names[1])
54
+ st.image(posters[1])
55
+ with col3:
56
+ st.text(names[2])
57
+ st.image(posters[2])
58
+ with col4:
59
+ st.text(names[3])
60
+ st.image(posters[3])
61
+ with col5:
62
+ st.text(names[4])
63
+ st.image(posters[4])
movie_dict.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e9a65940b6abc3091a4a6b8891226aa9d18c98e536138b6f79ceaef8ac8e95ec
3
+ size 2216684
movie_recommendation_system.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
movies.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1aed44f66872a07f849a2472c6aeb2294cfb0e01562ed41db3925cd2e6d22c48
3
+ size 2235322