docstr: In this implementation, for each unknown item,
  which will be predicted, we first look for users that seen that item and calculate the similarity between them
  and the user. Then we sort these similarities and get the most similar k's. 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","users","that","seen","that","item","and","calculate","the","similarity","between","them","and","the","user",".","Then","we","sort","these","similarities","and","get","the","most","similar","k","'s",".","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_scores(self, user, unpredicted_items):
      """
      In this implementation, for each unknown item,
      which will be predicted, we first look for users that seen that item and calculate the similarity between them
      and the user. Then we sort these similarities and get the most similar k's. 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 = []
  
      for item in unpredicted_items:
          neighbors = []
          rui = 0
          sim_sum = 0
          for user_v_id in self.users_id_viewed_item.get(item, []):
              user_v = self.user_id_to_user[user_v_id]
              neighbors.append(
                  (
                      user_v,
                      self.su_matrix[u_id, user_v_id],
                      self.train_set["feedback"][user_v][item],
                  )
              )
          neighbors = sorted(neighbors, key=lambda x: -x[1])
  
          if neighbors:
              for triple in neighbors[: self.k_neighbors]:
                  rui += (
                      (triple[2] - self.bui[triple[0]][item])
                      * triple[1]
                      if triple[1] != 0
                      else 0.001
                  )
                  sim_sum += triple[1] if triple[1] != 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 4 for calling the UserKNN obj's underlying member method code with example usage: obj.predict_scores(user, unpredicted_items) and returns: sorted