code: def predict(
      algo,
      data,
      usercol=DEFAULT_USER_COL,
      itemcol=DEFAULT_ITEM_COL,
      predcol=DEFAULT_PREDICTION_COL,
  ):
      """Computes predictions of an algorithm from Surprise on the data. Can be used for computing rating metrics like RMSE.
  
      Args:
          algo (surprise.prediction_algorithms.algo_base.AlgoBase): an algorithm from Surprise
          data (pandas.DataFrame): the data on which to predict
          usercol (str): name of the user column
          itemcol (str): name of the item column
  
      Returns:
          pandas.DataFrame: Dataframe with usercol, itemcol, predcol
      """
      predictions = [
          algo.predict(getattr(row, usercol), getattr(row, itemcol))
          for row in data.itertuples()
      ]
      predictions = pd.DataFrame(predictions)
      predictions = predictions.rename(
          index=str,
          columns={"uid": usercol, "iid": itemcol, "est": predcol},
      )
      return predictions.drop(["details", "r_ui"], axis="columns")
  
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 2 for calling a global function with example usage: predict(algo, data, usercol, itemcol, predcol) and returns: predictions