<jupyter_start><jupyter_text>Recommendations based on Jaccard indexIn this Notebook you will write the function that can be implemented in the Streamlit app. The actual code is already implemented in the streamlit app if you want to be inspired.  1. Loading the dataLoad a subset from the ratings dataset.<jupyter_code>import pandas as pd
df = pd.read_csv('./data/BX-Book-Ratings-Subset.csv', sep=';', encoding='latin-1')<jupyter_output><empty_output><jupyter_text>2. Generating the recommendations<jupyter_code>import itertools

# user we want to check
id = 98783

def get_jaccard_recommendations(id):
  # create lists per user
  users = df.groupby('User-ID')['ISBN'].apply(list)
  
  new_content = []
  similar_users = []
  
  for user, value in users.items():
    # calculate Jaccard distance
    
    # tweak this parameter. Closer to 0.0 is more the same. 0.0 is the user.
    if distance < 0.8 and distance != 0.0:
      
      # get the differences in sets (ISBN) from the the selected user and user in the for-loop
      # add these differences to new_content 
      # code goes here

      # add the user to similiar_users
      # code goes here

  # flatten the list with the sets
  new_content = list(itertools.chain(*new_content))

  # select the books
  # code goes here

  return df_recommendations

get_jaccard_recommendations(id)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08, 'fraction_numerical': 0.011636363636363636, 'mean_word_length': 3.7612456747404845, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '150241', 'license': 'MIT', 'n_tokens_mistral': 446, 'n_tokens_neox': 424, 'n_words': 151, 'path': 'Week 02/jaccard-distance/01-jaccard-recommendations.ipynb', 'repo_name': 'thomasmosterd/INFOMPPM', 'size': '1375'}