docstr: PaCo for Item Recommendation
  
  This algorithm predicts a rank for each user using a co-clustering algorithm
  
  Usage::
  
      >> PaCoRecommender(train, test).compute()
      >> PaCoRecommender(train, test, as_binary=True).compute()
  
  :param train_file: File which contains the train set. This file needs to have at least 3 columns
  (user item feedback_value).
  :type train_file: str
  
  :param test_file: File which contains the test set. This file needs to have at least 3 columns
  (user item feedback_value).
  :type test_file: str, default None
  
  :param output_file: File with dir to write the final predictions
  :type output_file: str, default None
  
  :param k_row: Number of clusters generated by k-means in rows
  :type k_row: int, default None
  
  :param l_col: (int) Number of clusters generated by k-means in rows
  :type l_col: int, default None
  
  :param density_low: Threshold to change the density matrix values
  :type density_low: float, default 0.008
  
  :param as_binary: If True, the explicit feedback will be transform to binary
  :type as_binary: bool, default True
  
  :param min_density: Considers bi-clusters until min-density
  :type min_density: float, default 0.3
docstr_tok: ["PaCo","for","Item","Recommendation","This","algorithm","predicts","a","rank","for","each","user","using","a","co-clustering","algorithm","Usage",":",":",">",">","PaCoRecommender","(","train",",","test",")",".compute","(",")",">",">","PaCoRecommender","(","train",",","test",",","as_binary=True",")",".compute","(",")",":","param","train_file",":","File","which","contains","the","train","set",".","This","file","needs","to","have","at","least","3","columns","(","user","item","feedback_value",")",".",":","type","train_file",":","str",":","param","test_file",":","File","which","contains","the","test","set",".","This","file","needs","to","have","at","least","3","columns","(","user","item","feedback_value",")",".",":","type","test_file",":","str",",","default","None",":","param","output_file",":","File","with","dir","to","write","the","final","predictions",":","type","output_file",":","str",",","default","None",":","param","k_row",":","Number","of","clusters","generated","by","k-means","in","rows",":","type","k_row",":","int",",","default","None",":","param","l_col",":","(","int",")","Number","of","clusters","generated","by","k-means","in","rows",":","type","l_col",":","int",",","default","None",":","param","density_low",":","Threshold","to","change","the","density","matrix","values",":","type","density_low",":","float",",","default","0.008",":","param","as_binary",":","If","True",",","the","explicit","feedback","will","be","transform","to","binary",":","type","as_binary",":","bool",",","default","True",":","param","min_density",":","Considers","bi-clusters","until","min-density",":","type","min_density",":","float",",","default","0.3"]
code: def __init__(
      self,
      train_file,
      test_file=None,
      output_file=None,
      k_row=None,
      l_col=None,
      density_low=0.01,
      as_binary=True,
      min_density=0.3,
  ):
      """
      PaCo for Item Recommendation
  
      This algorithm predicts a rank for each user using a co-clustering algorithm
  
      Usage::
  
          >> PaCoRecommender(train, test).compute()
          >> PaCoRecommender(train, test, as_binary=True).compute()
  
      :param train_file: File which contains the train set. This file needs to have at least 3 columns
      (user item feedback_value).
      :type train_file: str
  
      :param test_file: File which contains the test set. This file needs to have at least 3 columns
      (user item feedback_value).
      :type test_file: str, default None
  
      :param output_file: File with dir to write the final predictions
      :type output_file: str, default None
  
      :param k_row: Number of clusters generated by k-means in rows
      :type k_row: int, default None
  
      :param l_col: (int) Number of clusters generated by k-means in rows
      :type l_col: int, default None
  
      :param density_low: Threshold to change the density matrix values
      :type density_low: float, default 0.008
  
      :param as_binary: If True, the explicit feedback will be transform to binary
      :type as_binary: bool, default True
  
      :param min_density: Considers bi-clusters until min-density
      :type min_density: float, default 0.3
  
      """
      self.recommender_name = "PaCo Recommender Algorithm"
  
      self.train_file = train_file
      self.test_file = test_file
      if test_file is not None:
          self.test_set = ReadFile(test_file).read()
      self.train_set = ReadFile(train_file, as_binary=as_binary).read()
      self.output_file = output_file
      self.k_row = k_row
      self.l_col = l_col
      self.density_low = density_low
      self.min_density = min_density
  
      self.users = self.train_set["users"]
      self.items = self.train_set["items"]
  
      self.item_to_item_id = {}
      self.item_id_to_item = {}
      self.user_to_user_id = {}
      self.user_id_to_user = {}
  
      for i, item in enumerate(self.items):
          self.item_to_item_id.update({item: i})
          self.item_id_to_item.update({i: item})
      for u, user in enumerate(self.users):
          self.user_to_user_id.update({user: u})
          self.user_id_to_user.update({u: user})
  
      self.predictions = []
      self.uns_items = defaultdict()
      self.co_clustering = None
  
file_path: CaseRecommender/caserec/recommenders/item_recommendation/paco_recommender.py
imports: from collections import defaultdict
  import numpy
  from caserec.clustering.paco import PaCo
  from caserec.evaluation.item_recommendation import ItemRecommendationEvaluation
  from caserec.utils.process_data import ReadFile
label_desc: Use image node_id 1 to create a new PaCoRecommender object from inherited base classes: object with example: obj = PaCoRecommender(train_file, test_file, output_file, k_row, l_col, density_low, as_binary, min_density)