class_docstr: Spark Evaluator for diversity, coverage, novelty, serendipity
class_docstr_tok: ["Spark","Evaluator","for","diversity",",","coverage",",","novelty",",","serendipity"]
docstr: Intra-list similarity from
  
  :Citation:
  
      "Improving Recommendation Lists Through Topic Diversification",
      Ziegler, McNee, Konstan and Lausen, 2005.
docstr_tok: ["Intra-list","similarity","from",":","Citation",":","``","Improving","Recommendation","Lists","Through","Topic","Diversification","''",",","Ziegler",",","McNee",",","Konstan","and","Lausen",",","2005","."]
code: def _get_intralist_similarity(self, df):
      """Intra-list similarity from
  
      :Citation:
  
          "Improving Recommendation Lists Through Topic Diversification",
          Ziegler, McNee, Konstan and Lausen, 2005.
      """
      if self.df_intralist_similarity is None:
          pairs = self._get_pairwise_items(df=df)
          similarity_df = self._get_cosine_similarity()
          # Fillna(0) is needed in the cases where similarity_df does not have an entry for a pair of items.
          # e.g. i1 and i2 have never occurred together.
          self.df_intralist_similarity = (
              pairs.join(similarity_df, on=["i1", "i2"], how="left")
              .fillna(0)
              .filter(F.col("i1") != F.col("i2"))
              .groupBy(self.col_user)
              .agg(F.mean(self.sim_col).alias("avg_il_sim"))
              .select(self.col_user, "avg_il_sim")
          )
      return self.df_intralist_similarity
  
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 7 for calling the SparkDiversityEvaluation obj's underlying member method code with example usage: obj._get_intralist_similarity(df) and returns: self