class_docstr: SAR implementation for PySpark.
docstr: Recommend top K items for all users which are in the test set.
  
  Args:
      test: test Spark dataframe
      top_k: top n items to return
      remove_seen: remove items test users have already seen in
          the past from the recommended set.
docstr_tok: ["Recommend","top","K","items","for","all","users","which","are","in","the","test","set",".","Args",":","test",":","test","Spark","dataframe","top_k",":","top","n","items","to","return","remove_seen",":","remove","items","test","users","have","already","seen","in","the","past","from","the","recommended","set","."]
code: def _recommend_k_items_slow(self, test, top_k=10, remove_seen=True):
      """Recommend top K items for all users which are in the test set.
  
      Args:
          test: test Spark dataframe
          top_k: top n items to return
          remove_seen: remove items test users have already seen in
              the past from the recommended set.
      """
  
      # TODO: remove seen
      if remove_seen:
          raise ValueError("Not implemented")
  
      self.get_user_affinity(test).write.mode("overwrite").saveAsTable(
          self._format("{prefix}user_affinity")
      )
  
      # user_affinity * item_similarity
      # filter top-k
      query = self._format(
          """
              SELECT `{col_user}`, `{col_item}`, score
              FROM (
                    SELECT df.`{col_user}`,
                           s.i2 AS `{col_item}`,
                           SUM(df.`{col_rating}` * s.value) AS score,
                           ROW_NUMBER() OVER w AS rank
                    FROM `{prefix}user_affinity` AS df,
                         `{prefix}item_similarity` AS s
                    WHERE df.`{col_item}` = s.i1
                    GROUP BY df.`{col_user}`, s.i2
                    WINDOW w AS (
                        PARTITION BY `{col_user}`
                        ORDER BY SUM(df.`{col_rating}` * s.value) DESC)
                   )
              WHERE rank <= {top_k}
          """,
          top_k=top_k,
      )
  
      return self.spark.sql(query)
  
file_path: recommenders/contrib/sarplus/python/pysarplus/SARPlus.py
imports: import logging
  import pandas
  from pyspark.sql.types import StructType, StructField, IntegerType, FloatType
  from pyspark.sql.functions import pandas_udf, PandasUDFType
  from pysarplus import SARModel
  import pyspark.sql.functions
label_desc: Use image node_id 6 for calling the SARPlus obj's underlying member method code with example usage: obj._recommend_k_items_slow(test, top_k, remove_seen) and returns: self