docstr: (E)CoRec for rating prediction
  
  This algorithm is based on a co-training approach, named (E)CoRec, that drives two or more recommenders to
  agree with each others’ predictions to generate their own. The output of this algorithm is n (where n is the
  number of used recommenders) new enriched user x item matrix, which can be used as new training sets.
  
  Usage::
  
      >> ECoRec(tr, te, number_sample=10, confidence_measure='su').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 recommenders: Recommenders in which should be used as regressors to predict unlabeled sets. At least 2
  should be selected. Options:
      - 1: Item KNN
      - 2: User KNN
      - 3: Matrix Factorization
      - 4: SVD++
  :type recommenders: tuple, default (1,2)
  
  :param confidence_measure: Confidence Measure to calculate the precision of the predicted sample. Options:
         - 'pc': proposed metric in the articles
         - 'vi': Variability for item
         - 'su': supported for users
         - 'si': supported for items
  :type confidence_measure: str, default 'vi'
  
  :param number_sample: Number of new samples (unlabeled samples) per user, which should be labeled
  :type number_sample: int, default 10
  
  :param m: Number of most confident examples to select in each interaction
  :type m: int, default None
  
  :param sep: Delimiter for input files
  :type sep: str, default '       '
  
  :param ensemble_method: Active ensemble method (ECoRec), combining the n other recommenders outputs
  :type ensemble_method: bool, default False
docstr_tok: ["(","E",")","CoRec","for","rating","prediction","This","algorithm","is","based","on","a","co-training","approach",",","named","(","E",")","CoRec",",","that","drives","two","or","more","recommenders","to","agree","with","each","others","\u2019","predictions","to","generate","their","own",".","The","output","of","this","algorithm","is","n","(","where","n","is","the","number","of","used","recommenders",")","new","enriched","user","x","item","matrix",",","which","can","be","used","as","new","training","sets",".","Usage",":",":",">",">","ECoRec","(","tr",",","te",",","number_sample=10",",","confidence_measure='su","'",")",".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","recommenders",":","Recommenders","in","which","should","be","used","as","regressors","to","predict","unlabeled","sets",".","At","least","2","should","be","selected",".","Options",":","-","1",":","Item","KNN","-","2",":","User","KNN","-","3",":","Matrix","Factorization","-","4",":","SVD++",":","type","recommenders",":","tuple",",","default","(","1,2",")",":","param","confidence_measure",":","Confidence","Measure","to","calculate","the","precision","of","the","predicted","sample",".","Options",":","-","'pc","'",":","proposed","metric","in","the","articles","-","'vi","'",":","Variability","for","item","-","'su","'",":","supported","for","users","-","'si","'",":","supported","for","items",":","type","confidence_measure",":","str",",","default","'vi'",":","param","number_sample",":","Number","of","new","samples","(","unlabeled","samples",")","per","user",",","which","should","be","labeled",":","type","number_sample",":","int",",","default","10",":","param","m",":","Number","of","most","confident","examples","to","select","in","each","interaction",":","type","m",":","int",",","default","None",":","param","sep",":","Delimiter","for","input","files",":","type","sep",":","str",",","default","'","'",":","param","ensemble_method",":","Active","ensemble","method","(","ECoRec",")",",","combining","the","n","other","recommenders","outputs",":","type","ensemble_method",":","bool",",","default","False"]
code: def __init__(
      self,
      train_file,
      test_file,
      recommenders=(1, 2),
      confidence_measure="vi",
      number_sample=10,
      m=None,
      sep="\t",
      ensemble_method=False,
  ):
      """
  
      (E)CoRec for rating prediction
  
      This algorithm is based on a co-training approach, named (E)CoRec, that drives two or more recommenders to
      agree with each others’ predictions to generate their own. The output of this algorithm is n (where n is the
      number of used recommenders) new enriched user x item matrix, which can be used as new training sets.
  
      Usage::
  
          >> ECoRec(tr, te, number_sample=10, confidence_measure='su').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 recommenders: Recommenders in which should be used as regressors to predict unlabeled sets. At least 2
      should be selected. Options:
          - 1: Item KNN
          - 2: User KNN
          - 3: Matrix Factorization
          - 4: SVD++
      :type recommenders: tuple, default (1,2)
  
      :param confidence_measure: Confidence Measure to calculate the precision of the predicted sample. Options:
             - 'pc': proposed metric in the articles
             - 'vi': Variability for item
             - 'su': supported for users
             - 'si': supported for items
      :type confidence_measure: str, default 'vi'
  
      :param number_sample: Number of new samples (unlabeled samples) per user, which should be labeled
      :type number_sample: int, default 10
  
      :param m: Number of most confident examples to select in each interaction
      :type m: int, default None
  
      :param sep: Delimiter for input files
      :type sep: str, default '\t'
  
      :param ensemble_method: Active ensemble method (ECoRec), combining the n other recommenders outputs
      :type ensemble_method: bool, default False
  
      """
  
      self.train_file = train_file
      self.test_file = test_file
      self.train_set = ReadFile(train_file, sep=sep).read()
      self.test_set = ReadFile(test_file, sep=sep).read()
      self.recommenders = recommenders
      self.confidence_measure = confidence_measure
      self.number_sample = number_sample
      self.m = m
      self.sep = sep
      self.ensemble_method = ensemble_method
  
      # internal vars
      self.number_of_recommenders = len(recommenders)
      self.unlabeled_set = None
      self.unlabeled_data = dict()
      self.labeled_files = dict()
      self.unlabeled_files = dict()
      self.ensemble_file = None
  
      self.empty = False
      self.recommenders_predictions = None
      self.recommenders_confident = None
  
      self.rec_conf = dict()
      self.l_test = list()
  
      np.random.seed(123)
  
imports: from multiprocessing.pool import Pool
  from random import shuffle
  import numpy
  import os
  from caserec.recommenders.rating_prediction.itemknn import ItemKNN
  from caserec.recommenders.rating_prediction.matrixfactorization import MatrixFactorization
  from caserec.recommenders.rating_prediction.svdplusplus import SVDPlusPlus
  from caserec.recommenders.rating_prediction.userknn import UserKNN
  from caserec.utils.process_data import ReadFile
  from caserec.utils.extra_functions import ComputeBui
label_desc: Use image node_id 1 to create a new ECoRec object from inherited base classes: object with example: obj = ECoRec(train_file, test_file, recommenders, confidence_measure, number_sample, m, sep, ensemble_method)