class_docstr: Spark Evaluator for diversity, coverage, novelty, serendipity
class_docstr_tok: ["Spark","Evaluator","for","diversity",",","coverage",",","novelty",",","serendipity"]
docstr: Cosine similarity metric based on item feature vectors
  
  The item indexes in the result are such that i1 <= i2.
docstr_tok: ["Cosine","similarity","metric","based","on","item","feature","vectors","The","item","indexes","in","the","result","are","such","that","i1","<","=","i2","."]
code: def _get_item_feature_similarity(self, n_partitions):
      """Cosine similarity metric based on item feature vectors
  
      The item indexes in the result are such that i1 <= i2.
      """
      if self.df_cosine_similarity is None:
          self.df_cosine_similarity = (
              self.item_feature_df.select(
                  F.col(self.col_item).alias("i1"),
                  F.col(self.col_item_features).alias("f1"),
              )
              .join(
                  self.item_feature_df.select(
                      F.col(self.col_item).alias("i2"),
                      F.col(self.col_item_features).alias("f2"),
                  ),
                  (F.col("i1") <= F.col("i2")),
              )
              .select("i1", "i2", self.sim_cos("f1", "f2").alias("sim"))
              .sort("i1", "i2")
              .repartition(n_partitions, "i1", "i2")
          )
      return self.df_cosine_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 6 for calling the SparkDiversityEvaluation obj's underlying member method code with example usage: obj._get_item_feature_similarity(n_partitions) and returns: self