docstr: Group-Based for Item Recommendation
  
  This algorithm predicts a rank for each user using a co-clustering algorithm
  
  Usage::
  
      >> GroupBasedRecommender([train_history], test).compute()
      >> GroupBasedRecommender([train_history, train_rating], test, as_binary=True).compute()
  
  :param train_files: List of train files
  :type train_files: list
  
  :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 similarity_metric: Pairwise metric to compute the similarity between the users. Reference about
  distances: http://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.spatial.distance.pdist.html
  :type similarity_metric: str, default cosine
  
  :param as_binary: If True, the explicit feedback will be transform to binary
  :type as_binary: bool, default False
  
  :param sep: Delimiter for input files
  :type sep: str, default '       '
  
  :param output_sep: Delimiter for output file
  :type output_sep: str, default '        '
docstr_tok: ["Group-Based","for","Item","Recommendation","This","algorithm","predicts","a","rank","for","each","user","using","a","co-clustering","algorithm","Usage",":",":",">",">","GroupBasedRecommender","(","[","train_history","]",",","test",")",".compute","(",")",">",">","GroupBasedRecommender","(","[","train_history",",","train_rating","]",",","test",",","as_binary=True",")",".compute","(",")",":","param","train_files",":","List","of","train","files",":","type","train_files",":","list",":","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","similarity_metric",":","Pairwise","metric","to","compute","the","similarity","between","the","users",".","Reference","about","distances",":","http",":","\/\/docs.scipy.org\/doc\/scipy-0.14.0\/reference\/generated\/scipy.spatial.distance.pdist.html",":","type","similarity_metric",":","str",",","default","cosine",":","param","as_binary",":","If","True",",","the","explicit","feedback","will","be","transform","to","binary",":","type","as_binary",":","bool",",","default","False",":","param","sep",":","Delimiter","for","input","files",":","type","sep",":","str",",","default","'","'",":","param","output_sep",":","Delimiter","for","output","file",":","type","output_sep",":","str",",","default","'","'"]
code: def __init__(
      self,
      train_files=None,
      test_file=None,
      output_file=None,
      similarity_metric="cosine",
      rank_length=10,
      k_groups=3,
      recommender="UserKNN",
      as_binary=False,
      sep="\t",
      output_sep="\t",
      max_int_kmedoids=1000,
      parser="",
      user_weights=False,
  ):
      """
      Group-Based for Item Recommendation
  
      This algorithm predicts a rank for each user using a co-clustering algorithm
  
      Usage::
  
          >> GroupBasedRecommender([train_history], test).compute()
          >> GroupBasedRecommender([train_history, train_rating], test, as_binary=True).compute()
  
      :param train_files: List of train files
      :type train_files: list
  
      :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 similarity_metric: Pairwise metric to compute the similarity between the users. Reference about
      distances: http://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.spatial.distance.pdist.html
      :type similarity_metric: str, default cosine
  
      :param as_binary: If True, the explicit feedback will be transform to binary
      :type as_binary: bool, default False
  
      :param sep: Delimiter for input files
      :type sep: str, default '\t'
  
      :param output_sep: Delimiter for output file
      :type output_sep: str, default '\t'
  
      """
  
      super(GroupBasedRecommender, self).__init__(
          train_file="",
          test_file=test_file,
          output_file=output_file,
          as_binary=as_binary,
          rank_length=rank_length,
          similarity_metric=similarity_metric,
          sep=sep,
          output_sep=output_sep,
      )
  
      self.recommender_name = "Group Based Recommender Algorithm"
      self.train_files = train_files
      self.k_groups = k_groups
      self.recommender = recommender
      self.max_int_kmedoids = max_int_kmedoids
      self.parser = parser
      self.user_weights = user_weights
  
      # internal vars
      self.n_files = 0
      self.train_set_list = []
      self.distance_matrix = None
      self.dir_name = None
      self.gb_train_files = []
      self.weighted_matrices = []
      self.k_users_in_cluster = []
  
imports: from scipy.spatial.distance import squareform, pdist
  import numpy
  import os
  from caserec.clustering.kmedoids import kmedoids
  from caserec.recommenders.item_recommendation.base_item_recommendation import BaseItemRecommendation
  from caserec.recommenders.item_recommendation.itemknn import ItemKNN
  from caserec.recommenders.item_recommendation.most_popular import MostPopular
  from caserec.recommenders.item_recommendation.userknn import UserKNN
  from caserec.utils.process_data import ReadFile, WriteFile
  from caserec.recommenders.item_recommendation.bprmf import BprMF
label_desc: Use image node_id 1 to create a new GroupBasedRecommender object from inherited base classes: BaseItemRecommendation with example: obj = GroupBasedRecommender(train_files, test_file, output_file, similarity_metric, rank_length, k_groups, recommender, as_binary, sep, output_sep, max_int_kmedoids, parser, user_weights)