code: def rank_items(self, userid, user_items, selected_items, recalculate_user=False):
          if max(selected_items) >= user_items.shape[1] or min(selected_items) < 0:
              raise IndexError("Some of selected itemids are not in the model")
          liked_vector = user_items[userid]
          recommendations = liked_vector.dot(self.similarity)
          best = sorted(zip(recommendations.indices, recommendations.data), key=lambda x: -x[1])
          ret = [rec for rec in best if rec[0] in selected_items]
          for itemid in selected_items:
              if itemid not in recommendations.indices:
                  ret.append((itemid, -1.0))
          return ret