Last active
January 21, 2017 14:33
-
-
Save Wann-Jiun/2ec32c544e68813dad0cc54b8f8a856b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
from IPython.display import Image | |
from IPython.display import display | |
from IPython.display import HTML | |
idx_to_movie = {} | |
for row in df_id.itertuples(): | |
idx_to_movie[row[1]-1] = row[2] | |
idx_to_movie | |
k = 6 | |
idx = 0 | |
movies = [ idx_to_movie[x] for x in np.argsort(similarity_movie[idx,:])[:-k-1:-1] ] | |
movies = filter(lambda imdb: len(str(imdb)) == 6, movies) | |
n_display = 5 | |
URL = [0]*n_display | |
IMDB = [0]*n_display | |
i = 0 | |
for movie in movies: | |
(URL[i], IMDB[i]) = get_poster(movie, base_url) | |
i += 1 | |
images = '' | |
for i in range(n_display): | |
images += "<img style='width: 100px; margin: 0px; \ | |
float: left; border: 1px solid black;' src='%s' />" \ | |
% URL[i] | |
display(HTML(images)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment