0
from IPython.display import display, Image, SVG, Math, YouTubeVideo
from sklearn.metrics import pairwise_distances
def tfIdf_model(data_id, numOfResults):
    pairwise_dist = pairwise_distances(tfidf_feature_title,tfidf_feature_title[data_id])
    indices = np.argsort(pairwise_dist.flatten())[0:numOfResults]
    pdists  = np.sort(pairwise_dist.flatten())[0:numOfResults]
    df_indices = list(data.index[indices])
    for i in range(0,len(indices)):
        print('ASIN :',data['asin'].loc[df_indices[i]])
        print ('Brand:', data['brand'].loc[df_indices[i]])
        print ('Title:', data['title'].loc[df_indices[i]])
        print('Image: ')
        #This below command is not working .
        Image(url=data['medium_image_url'].loc[df_indices[i]])
        print('Euclidean similarity with the query image :', pdists[i])
        print('*'*100)
tfIdf_model(3456, 20)


This is the code I am using to print the image whose url is stored in 'medium_image_url' column of the dataframe by the name of data. Please tell me what to do to print the image also .

enter image description here

dm2
  • 4,053
  • 3
  • 17
  • 28

0 Answers0