class_docstr: Spark Evaluator for diversity, coverage, novelty, serendipity
class_docstr_tok: ["Spark","Evaluator","for","diversity",",","coverage",",","novelty",",","serendipity"]
docstr: Calculate average serendipity for recommendations across all users.
  
  Returns:
      float: serendipity.
docstr_tok: ["Calculate","average","serendipity","for","recommendations","across","all","users",".","Returns",":","float",":","serendipity","."]
code: def serendipity(self):
      """Calculate average serendipity for recommendations across all users.
  
      Returns:
          float: serendipity.
      """
      if self.avg_serendipity is None:
          self.df_user_serendipity = self.user_serendipity()
          self.avg_serendipity = self.df_user_serendipity.agg(
              {"user_serendipity": "mean"}
          ).first()[0]
      return self.avg_serendipity
  
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 14 for calling the SparkDiversityEvaluation obj's underlying member method code with example usage: obj.serendipity() and returns: self