code: def _get_relevant_items_by_threshold(
      dataframe,
      col_user=DEFAULT_USER_COL,
      col_item=DEFAULT_ITEM_COL,
      col_rating=DEFAULT_RATING_COL,
      col_prediction=DEFAULT_PREDICTION_COL,
      threshold=DEFAULT_THRESHOLD,
  ):
      """Get relevant items for each customer in the input rating data.
  
      Relevant items are defined as those having ratings above certain threshold.
      The threshold is defined as a statistical measure of the ratings for a
      user, e.g., median.
  
      Args:
          dataframe: Spark DataFrame of customerID-itemID-rating tuples.
          col_user (str): column name for user.
          col_item (str): column name for item.
          col_rating (str): column name for rating.
          col_prediction (str): column name for prediction.
          threshold (float): threshold for determining the relevant recommended items.
              This is used for the case that predicted ratings follow a known
              distribution.
  
      Return:
          pyspark.sql.DataFrame: DataFrame of customerID-itemID-rating tuples with only relevant
          items.
      """
      items_for_user = (
          dataframe.orderBy(col_rating, ascending=False)
          .where(col_rating + " >= " + str(threshold))
          .select(col_user, col_item, col_rating)
          .withColumn(
              col_prediction,
              F.collect_list(col_item).over(
                  Window.partitionBy(col_user)
              ),
          )
          .select(col_user, col_prediction)
          .dropDuplicates()
      )
  
      return items_for_user
  
imports: import numpy
  from recommenders.utils.constants import DEFAULT_PREDICTION_COL, DEFAULT_USER_COL, DEFAULT_ITEM_COL, DEFAULT_RATING_COL, DEFAULT_RELEVANCE_COL, DEFAULT_SIMILARITY_COL, DEFAULT_ITEM_FEATURES_COL, DEFAULT_ITEM_SIM_MEASURE, DEFAULT_TIMESTAMP_COL, DEFAULT_K, DEFAULT_THRESHOLD
label_desc: Use image node_id 2 for calling a global function with example usage: _get_relevant_items_by_threshold(dataframe, col_user, col_item, col_rating, col_prediction, threshold) and returns: items_for_user