docstr: In this implementation, for each unknown item, which will be
  predicted, we first look for its k most similar items and then take the intersection with the seen items of
  the user. Finally, the score of the unknown item will be the sum of the  similarities of k's most similar
  to it, taking into account only the items that each user seen.
docstr_tok: ["In","this","implementation",",","for","each","unknown","item",",","which","will","be","predicted",",","we","first","look","for","its","k","most","similar","items","and","then","take","the","intersection","with","the","seen","items","of","the","user",".","Finally",",","the","score","of","the","unknown","item","will","be","the","sum","of","the","similarities","of","k","'s","most","similar","to","it",",","taking","into","account","only","the","items","that","each","user","seen","."]
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 items and then take the intersection with the seen items of
      the user. Finally, the score of the unknown item will be the sum of the  similarities of k's most similar
      to it, taking into account only the items that each user seen.
  
      """
  
      predictions = []
      user_id = self.user_to_user_id[user]
      seen_items_id = np.flatnonzero(self.matrix[user_id])
  
      # predict score for item_i
      for item_j in unpredicted_items:
          item_j_id = self.item_to_item_id[item_j]
          rui = 0
          sim_sum = 0
  
          neighbors_list_id = list(
              set(self.similar_items[item_j_id]).intersection(
                  seen_items_id
              )
          )
  
          if neighbors_list_id:
              for item_id in neighbors_list_id:
                  item = self.item_id_to_item[item_id]
                  similarity = self.si_matrix[item_j_id, item_id]
                  rui += (
                      (
                          self.train_set["feedback"][user][item]
                          - self.bui[user][item]
                      )
                      * similarity
                      if similarity != 0
                      else 0.001
                  )
  
                  sim_sum += similarity if similarity != 0 else 0.001
  
              rui = self.bui[user][item_j] + (rui / sim_sum)
  
          else:
              rui = self.bui[user][item_j]
  
          # 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_j, rui))
  
      return sorted(predictions, key=lambda x: x[1])
  
file_path: CaseRecommender/caserec/recommenders/rating_prediction/itemknn.py
imports: from collections import defaultdict
  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 ItemKNN obj's underlying member method code with example usage: obj.predict_similar_first_scores(user, unpredicted_items) and returns: sorted