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