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: Get top K most frequently occurring items across all users.
  
  Args:
      top_k (int): number of top items to recommend.
      sort_top_k (bool): flag to sort top k results.
      items (bool): if false, return most frequent users instead
  
  Returns:
      pandas.DataFrame: top k most popular items.
docstr_tok: ["Get","top","K","most","frequently","occurring","items","across","all","users",".","Args",":","top_k","(","int",")",":","number","of","top","items","to","recommend",".","sort_top_k","(","bool",")",":","flag","to","sort","top","k","results",".","items","(","bool",")",":","if","false",",","return","most","frequent","users","instead","Returns",":","pandas.DataFrame",":","top","k","most","popular","items","."]
code: def get_popularity_based_topk(
      self, top_k=10, sort_top_k=True, items=True
  ):
      """Get top K most frequently occurring items across all users.
  
      Args:
          top_k (int): number of top items to recommend.
          sort_top_k (bool): flag to sort top k results.
          items (bool): if false, return most frequent users instead
  
      Returns:
          pandas.DataFrame: top k most popular items.
      """
      if items:
          frequencies = self.item_frequencies
          col = self.col_item
          idx = self.index2item
      else:
          if self.user_frequencies is None:
              self.user_frequencies = self.user_affinity.getnnz(
                  axis=1
              ).astype("int64")
          frequencies = self.user_frequencies
          col = self.col_user
          idx = self.index2user
  
      test_scores = np.array([frequencies])
  
      logger.info("Getting top K")
      top_components, top_scores = get_top_k_scored_items(
          scores=test_scores, top_k=top_k, sort_top_k=sort_top_k
      )
  
      return pd.DataFrame(
          {
              col: [idx[item] for item in top_components.flatten()],
              self.col_prediction: top_scores.flatten(),
          }
      )
  
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 8 for calling the SARSingleNode obj's underlying member method code with example usage: obj.get_popularity_based_topk(top_k, sort_top_k, items) and returns: pd