class_docstr: Simple Algorithm for Recommendations (SAR) implementation
  
  SAR is a fast scalable adaptive algorithm for personalized recommendations based on user transaction history
  and items description. The core idea behind SAR is to recommend items like those that a user already has
  demonstrated an affinity to. It does this by 1) estimating the affinity of users for items, 2) estimating
  similarity across items, and then 3) combining the estimates to generate a set of recommendations for a given user.
class_docstr_tok: ["Simple","Algorithm","for","Recommendations","(","SAR",")","implementation","SAR","is","a","fast","scalable","adaptive","algorithm","for","personalized","recommendations","based","on","user","transaction","history","and","items","description",".","The","core","idea","behind","SAR","is","to","recommend","items","like","those","that","a","user","already","has","demonstrated","an","affinity","to",".","It","does","this","by","1",")","estimating","the","affinity","of","users","for","items",",","2",")","estimating","similarity","across","items",",","and","then","3",")","combining","the","estimates","to","generate","a","set","of","recommendations","for","a","given","user","."]
docstr: Based on user affinity towards items, calculate the most similar users to the given user.
  
  Args:
      user (int): user to retrieve most similar users for
      top_k (int): number of top items to recommend
      sort_top_k (bool): flag to sort top k results
  
  Returns:
      pandas.DataFrame: top k most similar users and their scores
docstr_tok: ["Based","on","user","affinity","towards","items",",","calculate","the","most","similar","users","to","the","given","user",".","Args",":","user","(","int",")",":","user","to","retrieve","most","similar","users","for","top_k","(","int",")",":","number","of","top","items","to","recommend","sort_top_k","(","bool",")",":","flag","to","sort","top","k","results","Returns",":","pandas.DataFrame",":","top","k","most","similar","users","and","their","scores"]
code: def get_topk_most_similar_users(self, user, top_k, sort_top_k=True):
      """Based on user affinity towards items, calculate the most similar users to the given user.
  
      Args:
          user (int): user to retrieve most similar users for
          top_k (int): number of top items to recommend
          sort_top_k (bool): flag to sort top k results
  
      Returns:
          pandas.DataFrame: top k most similar users and their scores
      """
      user_idx = self.user2index[user]
      similarities = (
          self.user_affinity[user_idx]
          .dot(self.user_affinity.T)
          .toarray()
      )
      similarities[0, user_idx] = -np.inf
  
      top_items, top_scores = get_top_k_scored_items(
          scores=similarities, top_k=top_k, sort_top_k=sort_top_k
      )
  
      df = pd.DataFrame(
          {
              self.col_user: [
                  self.index2user[user] for user in top_items.flatten()
              ],
              self.col_prediction: top_scores.flatten(),
          }
      )
  
      # drop invalid items
      return df.replace(-np.inf, np.nan).dropna()
  
file_path: recommenders/recommenders/models/sar/sar_singlenode.py
imports: import numpy
  import pandas
  import logging
  from scipy import sparse
  from recommenders.utils.python_utils import cosine_similarity, inclusion_index, jaccard, lexicographers_mutual_information, lift, mutual_information, exponential_decay, get_top_k_scored_items, rescale
  from recommenders.utils import constants
label_desc: Use image node_id 10 for calling the SARSingleNode obj's underlying member method code with example usage: obj.get_topk_most_similar_users(user, top_k, sort_top_k) and returns: df