class_docstr: SAR implementation for PySpark.
docstr: Prepare test set for C++ SAR prediction code.
  Find all items the test users have seen in the past.
  
  Arguments:
      test (pySpark.DataFrame): input dataframe which contains test users.
docstr_tok: ["Prepare","test","set","for","C++","SAR","prediction","code",".","Find","all","items","the","test","users","have","seen","in","the","past",".","Arguments",":","test","(","pySpark.DataFrame",")",":","input","dataframe","which","contains","test","users","."]
code: def get_user_affinity(self, test):
      """Prepare test set for C++ SAR prediction code.
      Find all items the test users have seen in the past.
  
      Arguments:
          test (pySpark.DataFrame): input dataframe which contains test users.
      """
      test.createOrReplaceTempView(self._format("{prefix}df_test"))
  
      query = self._format(
          """
              SELECT DISTINCT `{col_user}`
              FROM `{prefix}df_test`
              CLUSTER BY `{col_user}`
          """
      )
  
      df_test_users = self.spark.sql(query)
      df_test_users.write.mode("overwrite").saveAsTable(
          self._format("{prefix}df_test_users")
      )
  
      query = self._format(
          """
              SELECT a.`{col_user}`,
                     a.`{col_item}`,
                     CAST(a.`{col_rating}` AS double) AS `{col_rating}`
              FROM `{prefix}df_train` AS a
              INNER JOIN `{prefix}df_test_users` AS b
              ON a.`{col_user}` = b.`{col_user}`
              DISTRIBUTE BY `{col_user}`
              SORT BY `{col_user}`, `{col_item}`
          """
      )
  
      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 4 for calling the SARPlus obj's underlying member method code with example usage: obj.get_user_affinity(test) and returns: self