code: def map(
      rating_true,
      rating_pred,
      col_user=DEFAULT_USER_COL,
      col_item=DEFAULT_ITEM_COL,
      col_prediction=DEFAULT_PREDICTION_COL,
      relevancy_method="top_k",
      k=DEFAULT_K,
      threshold=DEFAULT_THRESHOLD,
      **_,
  ):
      """Mean Average Precision for top k prediction items
  
      The implementation of MAP is referenced from Spark MLlib evaluation metrics.
      https://spark.apache.org/docs/2.3.0/mllib-evaluation-metrics.html#ranking-systems
  
      A good reference can be found at:
      http://web.stanford.edu/class/cs276/handouts/EvaluationNew-handout-6-per.pdf
  
      Note:
          The MAP is meant to calculate Avg. Precision for the relevant items, so it is normalized by the number of
          relevant items in the ground truth data, instead of k.
  
      Args:
          rating_true (pandas.DataFrame): True DataFrame
          rating_pred (pandas.DataFrame): Predicted DataFrame
          col_user (str): column name for user
          col_item (str): column name for item
          col_prediction (str): column name for prediction
          relevancy_method (str): method for determining relevancy ['top_k', 'by_threshold', None]. None means that the
              top k items are directly provided, so there is no need to compute the relevancy operation.
          k (int): number of top k items per user
          threshold (float): threshold of top items per user (optional)
  
      Returns:
          float: MAP (min=0, max=1)
      """
      df_merge, n_users = _get_reciprocal_rank(
          rating_true=rating_true,
          rating_pred=rating_pred,
          col_user=col_user,
          col_item=col_item,
          col_prediction=col_prediction,
          relevancy_method=relevancy_method,
          k=k,
          threshold=threshold,
      )
  
      if df_merge is None:
          return 0.0
      else:
          return (df_merge["rr"] / df_merge["actual"]).sum() / n_users
  
imports: import numpy
  import pandas
  from functools import wraps
  from sklearn.metrics import mean_squared_error, mean_absolute_error, r2_score, explained_variance_score, roc_auc_score, log_loss
  from recommenders.utils.constants import DEFAULT_USER_COL, DEFAULT_ITEM_COL, DEFAULT_RATING_COL, DEFAULT_PREDICTION_COL, DEFAULT_RELEVANCE_COL, DEFAULT_SIMILARITY_COL, DEFAULT_ITEM_FEATURES_COL, DEFAULT_ITEM_SIM_MEASURE, DEFAULT_K, DEFAULT_THRESHOLD
  from recommenders.datasets.pandas_df_utils import has_columns, has_same_base_dtype, lru_cache_df
label_desc: Use image node_id 14 for calling a global function with example usage: map(rating_true, rating_pred, col_user, col_item, col_prediction, relevancy_method, k, threshold) and returns: int, unknown