class_docstr: Generate the user/item affinity matrix from a pandas dataframe and vice versa
class_docstr_tok: ["Generate","the","user\/item","affinity","matrix","from","a","pandas","dataframe","and","vice","versa"]
docstr: Initialize class parameters
  
  Args:
      df (pandas.DataFrame): a dataframe containing the data
      items_list (numpy.ndarray): a list of unique items to use (if provided)
      col_user (str): default name for user column
      col_item (str): default name for item column
      col_rating (str): default name for rating columns
      save_path (str): default path to save item/user maps
docstr_tok: ["Initialize","class","parameters","Args",":","df","(","pandas.DataFrame",")",":","a","dataframe","containing","the","data","items_list","(","numpy.ndarray",")",":","a","list","of","unique","items","to","use","(","if","provided",")","col_user","(","str",")",":","default","name","for","user","column","col_item","(","str",")",":","default","name","for","item","column","col_rating","(","str",")",":","default","name","for","rating","columns","save_path","(","str",")",":","default","path","to","save","item\/user","maps"]
code: def __init__(
      self,
      df,
      items_list=None,
      col_user=DEFAULT_USER_COL,
      col_item=DEFAULT_ITEM_COL,
      col_rating=DEFAULT_RATING_COL,
      col_pred=DEFAULT_PREDICTION_COL,
      save_path=None,
  ):
      """Initialize class parameters
  
      Args:
          df (pandas.DataFrame): a dataframe containing the data
          items_list (numpy.ndarray): a list of unique items to use (if provided)
          col_user (str): default name for user column
          col_item (str): default name for item column
          col_rating (str): default name for rating columns
          save_path (str): default path to save item/user maps
      """
      self.df = df  # dataframe
      self.items_list = items_list  # list of unique items
  
      # pandas DF parameters
      self.col_item = col_item
      self.col_user = col_user
      self.col_rating = col_rating
      self.col_pred = col_pred
  
      # Options to save the model for future use
      self.save_path = save_path
  
file_path: recommenders/recommenders/datasets/sparse.py
imports: import pandas
  import numpy
  import itertools
  from scipy.sparse import coo_matrix
  import logging
  from recommenders.utils.constants import DEFAULT_USER_COL, DEFAULT_ITEM_COL, DEFAULT_RATING_COL, DEFAULT_PREDICTION_COL
label_desc: Use image node_id 1 to create a new AffinityMatrix object  with example: obj = AffinityMatrix(df, items_list, col_user, col_item, col_rating, col_pred, save_path)