docstr: In this implementation, for each unknown item, which will be
  predicted, we first look for its k most similar users and then take the intersection with the users that
  seen that item. Finally, the score of the unknown item will be the sum of the  similarities.
  
  rui = bui + (sum((rvi - bvi) * sim(u,v)) / sum(sim(u,v)))
  
  :param user: User
  :type user: int
  
  :param unpredicted_items: A list of unknown items for each user
  :type unpredicted_items: list
  
  :return: Sorted list with triples user item rating
  :rtype: list
docstr_tok: ["In","this","implementation",",","for","each","unknown","item",",","which","will","be","predicted",",","we","first","look","for","its","k","most","similar","users","and","then","take","the","intersection","with","the","users","that","seen","that","item",".","Finally",",","the","score","of","the","unknown","item","will","be","the","sum","of","the","similarities",".","rui","=","bui","+","(","sum","(","(","rvi","-","bvi",")","*","sim","(","u",",","v",")",")","\/","sum","(","sim","(","u",",","v",")",")",")",":","param","user",":","User",":","type","user",":","int",":","param","unpredicted_items",":","A","list","of","unknown","items","for","each","user",":","type","unpredicted_items",":","list",":","return",":","Sorted","list","with","triples","user","item","rating",":","rtype",":","list"]
code: def predict_similar_first_scores(self, user, unpredicted_items):
      """
      In this implementation, for each unknown item, which will be
      predicted, we first look for its k most similar users and then take the intersection with the users that
      seen that item. Finally, the score of the unknown item will be the sum of the  similarities.
  
      rui = bui + (sum((rvi - bvi) * sim(u,v)) / sum(sim(u,v)))
  
      :param user: User
      :type user: int
  
      :param unpredicted_items: A list of unknown items for each user
      :type unpredicted_items: list
  
      :return: Sorted list with triples user item rating
      :rtype: list
  
      """
      u_id = self.user_to_user_id[user]
      predictions = []
  
      # Select user neighbors, sorting user similarity vector. Returns a list with index of sorting values
      neighbors = sorted(
          range(len(self.su_matrix[u_id])),
          key=lambda m: -self.su_matrix[u_id][m],
      )
  
      for item in unpredicted_items:
          rui = 0
          sim_sum = 0
  
          # Intersection bt. the neighbors closest to the user and the users who accessed the unknown item.
          common_users = list(
              set(self.users_id_viewed_item.get(item, [])).intersection(
                  neighbors[1 : self.k_neighbors]
              )
          )
  
          if common_users:
              for user_v_id in common_users:
                  user_v = self.user_id_to_user[user_v_id]
                  sim_uv = self.su_matrix[u_id, user_v_id]
                  rui += (
                      (
                          self.train_set["feedback"][user_v][item]
                          - self.bui[user_v][item]
                      )
                      * sim_uv
                      if sim_sum != 0
                      else 0.001
                  )
                  sim_sum += sim_uv if sim_sum != 0 else 0.001
  
              rui = self.bui[user][item] + (rui / sim_sum)
  
          else:
              rui = self.bui[user][item]
  
          # normalize the ratings based on the highest and lowest value.
          if rui > self.train_set["max_value"]:
              rui = self.train_set["max_value"]
          if rui < self.train_set["min_value"]:
              rui = self.train_set["min_value"]
  
          predictions.append((user, item, rui))
  
      return sorted(predictions, key=lambda x: x[1])
  
file_path: CaseRecommender/caserec/recommenders/rating_prediction/userknn.py
imports: import numpy
  from caserec.utils.extra_functions import timed
  from caserec.recommenders.rating_prediction.base_knn import BaseKNN
label_desc: Use image node_id 5 for calling the UserKNN obj's underlying member method code with example usage: obj.predict_similar_first_scores(user, unpredicted_items) and returns: sorted