class_docstr: SAR implementation for PySpark.
docstr: Initialize model parameters
  Args:
      spark (pyspark.sql.SparkSession): Spark session
      col_user (str): user column name
      col_item (str): item column name
      col_rating (str): rating column name
      col_timestamp (str): timestamp column name
      table_prefix (str): name prefix of the generated tables
      similarity_type (str): ['cooccurrence', 'jaccard', 'lift']
          option for computing item-item similarity
      time_decay_coefficient (float): number of days till
          ratings are decayed by 1/2.  denominator in time
          decay.  Zero makes time decay irrelevant
      time_now (int | None): current time for time decay
          calculation
      timedecay_formula (bool): flag to apply time decay
      threshold (int): item-item co-occurrences below this
          threshold will be removed
      cache_path (str): user specified local cache directory for
          recommend_k_items().  If specified,
          recommend_k_items() will do C++ based fast
          predictions.
docstr_tok: ["Initialize","model","parameters","Args",":","spark","(","pyspark.sql.SparkSession",")",":","Spark","session","col_user","(","str",")",":","user","column","name","col_item","(","str",")",":","item","column","name","col_rating","(","str",")",":","rating","column","name","col_timestamp","(","str",")",":","timestamp","column","name","table_prefix","(","str",")",":","name","prefix","of","the","generated","tables","similarity_type","(","str",")",":","[","'cooccurrence","'",",","'jaccard","'",",","'lift","'","]","option","for","computing","item-item","similarity","time_decay_coefficient","(","float",")",":","number","of","days","till","ratings","are","decayed","by","1\/2",".","denominator","in","time","decay",".","Zero","makes","time","decay","irrelevant","time_now","(","int","|","None",")",":","current","time","for","time","decay","calculation","timedecay_formula","(","bool",")",":","flag","to","apply","time","decay","threshold","(","int",")",":","item-item","co-occurrences","below","this","threshold","will","be","removed","cache_path","(","str",")",":","user","specified","local","cache","directory","for","recommend_k_items","(",")",".","If","specified",",","recommend_k_items","(",")","will","do","C++","based","fast","predictions","."]
code: def __init__(
      self,
      spark,
      col_user="userID",
      col_item="itemID",
      col_rating="rating",
      col_timestamp="timestamp",
      table_prefix="",
      similarity_type="jaccard",
      time_decay_coefficient=30,
      time_now=None,
      timedecay_formula=False,
      threshold=1,
      cache_path=None,
  ):
      """Initialize model parameters
      Args:
          spark (pyspark.sql.SparkSession): Spark session
          col_user (str): user column name
          col_item (str): item column name
          col_rating (str): rating column name
          col_timestamp (str): timestamp column name
          table_prefix (str): name prefix of the generated tables
          similarity_type (str): ['cooccurrence', 'jaccard', 'lift']
              option for computing item-item similarity
          time_decay_coefficient (float): number of days till
              ratings are decayed by 1/2.  denominator in time
              decay.  Zero makes time decay irrelevant
          time_now (int | None): current time for time decay
              calculation
          timedecay_formula (bool): flag to apply time decay
          threshold (int): item-item co-occurrences below this
              threshold will be removed
          cache_path (str): user specified local cache directory for
              recommend_k_items().  If specified,
              recommend_k_items() will do C++ based fast
              predictions.
      """
      assert threshold > 0
  
      self.spark = spark
      self.header = {
          "col_user": col_user,
          "col_item": col_item,
          "col_rating": col_rating,
          "col_timestamp": col_timestamp,
          "prefix": table_prefix,
          "time_now": time_now,
          "time_decay_half_life": time_decay_coefficient * 24 * 60 * 60,
          "threshold": threshold,
      }
      if similarity_type not in [SIM_COOCCUR, SIM_JACCARD, SIM_LIFT]:
          raise ValueError(
              'Similarity type must be one of ["cooccurrence" | "jaccard" | "lift"]'
          )
      self.similarity_type = similarity_type
      self.timedecay_formula = timedecay_formula
      self.item_similarity = None
      self.item_frequencies = None
      self.cache_path = cache_path
  
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 1 to create a new SARPlus object  with example: obj = SARPlus(spark, col_user, col_item, col_rating, col_timestamp, table_prefix, similarity_type, time_decay_coefficient, time_now, timedecay_formula, threshold, cache_path)