Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 90de771

Browse files
style: format code with autopep8
Format code with autopep8 This commit fixes the style issues introduced in e0ebea9 according to the output from Autopep8. Details: None
1 parent e0ebea9 commit 90de771

File tree

1 file changed

+10
-9
lines changed
  • Movie recommendation system

1 file changed

+10
-9
lines changed

‎Movie recommendation system/app.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,20 @@
44
import pandas as pd
55

66

7-
87
def fetch_poster(movie_id):
9-
url = "https://api.themoviedb.org/3/movie/{}?api_key=8265bd1679663a7ea12ac168da84d2e8&language=en-US".format(movie_id)
8+
url = "https://api.themoviedb.org/3/movie/{}?api_key=8265bd1679663a7ea12ac168da84d2e8&language=en-US".format(
9+
movie_id)
1010
data = requests.get(url)
1111
data = data.json()
1212
poster_path = data['poster_path']
1313
full_path = "https://image.tmdb.org/t/p/w500/" + poster_path
1414
return full_path
1515

16+
1617
def recommend(movie):
1718
index = movies[movies['title'] == movie].index[0]
18-
distances = sorted(list(enumerate(similarity[index])), reverse=True, key=lambda x: x[1])
19+
distances = sorted(
20+
list(enumerate(similarity[index])), reverse=True, key=lambda x: x[1])
1921
recommended_movie_names = []
2022
recommended_movie_posters = []
2123
for i in distances[1:6]:
@@ -24,13 +26,13 @@ def recommend(movie):
2426
recommended_movie_posters.append(fetch_poster(movie_id))
2527
recommended_movie_names.append(movies.iloc[i[0]].title)
2628

27-
return recommended_movie_names,recommended_movie_posters
29+
return recommended_movie_names,recommended_movie_posters
2830

2931

3032
st.header('TMDB Movie Recommender System')
31-
movies = pickle.load(open('movie_list.pkl','rb'))
33+
movies = pickle.load(open('movie_list.pkl','rb'))
3234
movies = pd.DataFrame(movies)
33-
similarity = pickle.load(open('similarity.pkl','rb'))
35+
similarity = pickle.load(open('similarity.pkl','rb'))
3436

3537
movie_list = movies['title'].values
3638
selected_movie = st.selectbox(
@@ -39,7 +41,8 @@ def recommend(movie):
3941
)
4042

4143
if st.button('Show Recommendation'):
42-
recommended_movie_names,recommended_movie_posters = recommend(selected_movie)
44+
recommended_movie_names, recommended_movie_posters = recommend(
45+
selected_movie)
4346
# for i in recommended_movie_names,recommended_movie_posters:
4447
# st.write(i)
4548
col1, col2, col3, col4, col5 = st.columns(5)
@@ -59,5 +62,3 @@ def recommend(movie):
5962
with col5:
6063
st.text(recommended_movie_names[4])
6164
st.image(recommended_movie_posters[4])
62-
63-

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /