class_docstr: Spark Evaluator for diversity, coverage, novelty, serendipity
class_docstr_tok: ["Spark","Evaluator","for","diversity",",","coverage",",","novelty",",","serendipity"]
docstr: Calculate catalog coverage for recommendations across all users.
  The metric definition is based on the "catalog coverage" definition in the following reference:
  
  :Citation:
  
      G. Shani and A. Gunawardana, Evaluating Recommendation Systems,
      Recommender Systems Handbook pp. 257-297, 2010.
  
  Returns:
      float: catalog coverage
docstr_tok: ["Calculate","catalog","coverage","for","recommendations","across","all","users",".","The","metric","definition","is","based","on","the","``","catalog","coverage","''","definition","in","the","following","reference",":",":","Citation",":","G.","Shani","and","A.","Gunawardana",",","Evaluating","Recommendation","Systems",",","Recommender","Systems","Handbook","pp",".","257-297",",","2010",".","Returns",":","float",":","catalog","coverage"]
code: def catalog_coverage(self):
      """Calculate catalog coverage for recommendations across all users.
      The metric definition is based on the "catalog coverage" definition in the following reference:
  
      :Citation:
  
          G. Shani and A. Gunawardana, Evaluating Recommendation Systems,
          Recommender Systems Handbook pp. 257-297, 2010.
  
      Returns:
          float: catalog coverage
      """
      # distinct item count in reco_df
      count_distinct_item_reco = (
          self.reco_df.select(self.col_item).distinct().count()
      )
      # distinct item count in train_df
      count_distinct_item_train = (
          self.train_df.select(self.col_item).distinct().count()
      )
  
      # catalog coverage
      c_coverage = count_distinct_item_reco / count_distinct_item_train
      return c_coverage
  
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 15 for calling the SparkDiversityEvaluation obj's underlying member method code with example usage: obj.catalog_coverage() and returns: c_coverage