code: def compute_ranking_predictions(
      algo,
      data,
      usercol=DEFAULT_USER_COL,
      itemcol=DEFAULT_ITEM_COL,
      predcol=DEFAULT_PREDICTION_COL,
      remove_seen=False,
  ):
      """Computes predictions of an algorithm from Surprise on all users and items in data. It can be used for computing
      ranking metrics like NDCG.
  
      Args:
          algo (surprise.prediction_algorithms.algo_base.AlgoBase): an algorithm from Surprise
          data (pandas.DataFrame): the data from which to get the users and items
          usercol (str): name of the user column
          itemcol (str): name of the item column
          remove_seen (bool): flag to remove (user, item) pairs seen in the training data
  
      Returns:
          pandas.DataFrame: Dataframe with usercol, itemcol, predcol
      """
      preds_lst = []
      users = data[usercol].unique()
      items = data[itemcol].unique()
  
      for user in users:
          for item in items:
              preds_lst.append(
                  [user, item, algo.predict(user, item).est]
              )
  
      all_predictions = pd.DataFrame(
          data=preds_lst, columns=[usercol, itemcol, predcol]
      )
  
      if remove_seen:
          tempdf = pd.concat(
              [
                  data[[usercol, itemcol]],
                  pd.DataFrame(
                      data=np.ones(data.shape[0]),
                      columns=["dummycol"],
                      index=data.index,
                  ),
              ],
              axis=1,
          )
          merged = pd.merge(
              tempdf,
              all_predictions,
              on=[usercol, itemcol],
              how="outer",
          )
          return merged[merged["dummycol"].isnull()].drop(
              "dummycol", axis=1
          )
      else:
          return all_predictions
  
imports: import pandas
  import numpy
  from recommenders.utils.constants import DEFAULT_USER_COL, DEFAULT_ITEM_COL, DEFAULT_PREDICTION_COL
  from recommenders.utils.general_utils import invert_dictionary
label_desc: Use image node_id 3 for calling a global function with example usage: compute_ranking_predictions(algo, data, usercol, itemcol, predcol, remove_seen) and returns: merged, all_predictions