docstr: Evaluation Metrics for information retrieval tasks such as document retrieval, image retrieval, etc.
  Reference: https://www.cs.cornell.edu/courses/cs4300/2013fa/lectures/metrics-2-4pp.pdf
  
  Parameters
  ----------
  pred:
      the prediction of the ranking model. It has the following form.
      pred = {
          'q1': {
              'd1': 1,
              'd3': 0,
          },
          'q2': {
              'd2': 1,
              'd3': 1,
          },
      }
      where q refers to queries, and d refers to documents, each query has a few relevant documents.
      0s and 1s are model predicted scores (does not need to be binary).
  target:
      the ground truth query and response relevance which has the same form as pred.
  is_higher_better:
      if higher relevance score means higher ranking.
      if the relevance score is cosine similarity / dot product, it should be set to True;
      if it is Eulidean distance, it should be False.
docstr_tok: ["Evaluation","Metrics","for","information","retrieval","tasks","such","as","document","retrieval",",","image","retrieval",",","etc",".","Reference",":","https",":","\/\/www.cs.cornell.edu\/courses\/cs4300\/2013fa\/lectures\/metrics-2-4pp.pdf","Parameters","--","--","--","--","--","pred",":","the","prediction","of","the","ranking","model",".","It","has","the","following","form",".","pred","=","{","'q1","'",":","{","'d1","'",":","1",",","'d3","'",":","0",",","}",",","'q2","'",":","{","'d2","'",":","1",",","'d3","'",":","1",",","}",",","}","where","q","refers","to","queries",",","and","d","refers","to","documents",",","each","query","has","a","few","relevant","documents",".","0s","and","1s","are","model","predicted","scores","(","does","not","need","to","be","binary",")",".","target",":","the","ground","truth","query","and","response","relevance","which","has","the","same","form","as","pred",".","is_higher_better",":","if","higher","relevance","score","means","higher","ranking",".","if","the","relevance","score","is","cosine","similarity","\/","dot","product",",","it","should","be","set","to","True",";","if","it","is","Eulidean","distance",",","it","should","be","False","."]
code: def __init__(
      self,
      pred: Dict[str, Dict],
      target: Dict[str, Dict],
      is_higher_better=True,
  ):
      """
      Evaluation Metrics for information retrieval tasks such as document retrieval, image retrieval, etc.
      Reference: https://www.cs.cornell.edu/courses/cs4300/2013fa/lectures/metrics-2-4pp.pdf
  
      Parameters
      ----------
      pred:
          the prediction of the ranking model. It has the following form.
          pred = {
              'q1': {
                  'd1': 1,
                  'd3': 0,
              },
              'q2': {
                  'd2': 1,
                  'd3': 1,
              },
          }
          where q refers to queries, and d refers to documents, each query has a few relevant documents.
          0s and 1s are model predicted scores (does not need to be binary).
      target:
          the ground truth query and response relevance which has the same form as pred.
      is_higher_better:
          if higher relevance score means higher ranking.
          if the relevance score is cosine similarity / dot product, it should be set to True;
          if it is Eulidean distance, it should be False.
      """
      self.pred = pred
      self.target = target
      self.is_higher_better = is_higher_better
      # the supported metrics in this script
      self.supported_metrics = {
          "precision": 0,
          "recall": 1,
          "mrr": 2,
          "map": 3,
          "ndcg": 4,
      }
  
      assert len(pred) == len(
          target
      ), f"The prediction and groudtruth target should have the same number of queries, \
          while there are {len(pred)} queries in prediction and {len(target)} in the target."
  
      self.results = {}
      for key in target.keys():
          self.results.update({key: [target[key], pred[key]]})
  
imports: import logging
  import math
  import operator
  import warnings
  from typing import Dict, List, Optional, Tuple, Union
  import evaluate
  import numpy
  from sklearn.metrics import f1_score
  from autogluon.core.metrics import Scorer, get_metric
  from ..constants import ACCURACY, AVERAGE_PRECISION, BINARY, DIRECT_LOSS, F1, FEW_SHOT_CLASSIFICATION, IOU, MAP, MATCHING_METRICS, MATCHING_METRICS_WITHOUT_PROBLEM_TYPE, MAX, METRIC_MODE_MAP, MIN, MULTICLASS, NDCG, NER, NER_TOKEN_F1, NUMERICAL, OBJECT_DETECTION, OPEN_VOCABULARY_OBJECT_DETECTION, OVERALL_ACCURACY, OVERALL_F1, PRECISION, RECALL, REGRESSION, RETRIEVAL_METRICS, RMSE, ROC_AUC, SEMANTIC_SEGMENTATION, SPEARMANR, Y_PRED, Y_PRED_PROB, Y_TRUE
  from ..problem_types import PROBLEM_TYPES_REG
label_desc: Use image node_id 1 to create a new RankingMetrics object  with example: obj = RankingMetrics(pred, target, is_higher_better)