docstr: Calculate retrieval metrics
docstr_tok: ["Calculate","retrieval","metrics"]
code: def calculate_retrieval_metrics(
      self,
      df: pd.DataFrame,
      context_embeddings,
      retrieved_context_embeddings,
      prefix="retrieval_",
  ):
      """Calculate retrieval metrics"""
  
      for metric in self.retrieval_metrics:
          col_name = f"{prefix}{metric}"
          if metric == "cosine_similarity":
              df[col_name] = self.metric_map[metric](
                  context_embeddings, retrieved_context_embeddings
              )
          elif metric == "accuracy":
              col_name = f"{prefix}match"
              df[col_name] = self.get_matches(
                  gt_embeddings=context_embeddings,
                  test_embeddings=retrieved_context_embeddings,
                  threshold=self.args.retriever_match_threshold,
              )
          else:
              raise ValueError(f"metric {metric} not supported")
  
          self.store_mean_metric(
              col_name=col_name, mean_metric=df[col_name].mean()
          )
  
      return df
  
imports: import ast
  from collections import defaultdict
  from typing import List
  import nltk
  import pandas
  from nltk import word_tokenize
  from nltk.translate.bleu_score import sentence_bleu
  from nltk.translate.meteor_score import meteor_score
  from rouge_score import rouge_scorer
  from scipy.spatial import distance
  from mindsdb.integrations.handlers.writer_handler.settings import WriterHandlerParameters
  from mindsdb.utilities import log
label_desc: Use image node_id 2 for calling the WriterEvaluator obj's underlying member method code with example usage: obj.calculate_retrieval_metrics(df, context_embeddings, retrieved_context_embeddings, prefix) and returns: df