Code2pdf 66714d844f78a
Code2pdf 66714d844f78a
import streamlit as st
import pickle
import numpy as np
import pandas as pd
st.set_page_config(layout="wide")
# Get the similarity scores for the given book and sort them in descending order
# We use enumerate to get the index and similarity score
# We skip the first item ([1:5]) since it's the book itself (highest similarity score)
similar_items = sorted(list(enumerate(similarity_score[index])), key=lambda x: x[1], reverse=True)[1:6]
# Uncomment the following line to add the book image URL to the item list, if needed
item.extend(list(temp_df.drop_duplicates('Book-Title')['Image-URL-M'].values))
# Append the item (containing book title and author) to the data list
data.append(item)
# Return the list of similar books with their titles and authors
return data