class_docstr: Temporal-Item-Frequency-based User-KNN (TIFUKNN)
  
  Parameters
  ----------
  name: string, default: 'TIFUKNN'
      The name of the recommender model.
  
  n_neighbors: int, optional, default: 300
      The number of neighbors for KNN
  
  within_decay_rate: float, optional, default: 0.9
      Within-basket time-decayed ratio in range [0, 1]
  
  group_decay_rate: float, optional, default: 0.7
      Group time-decayed ratio in range [0, 1]
  
  alpha: float, optional, default: 0.7
      The trade-off between current user vector and neighbors vectors
      to compute final item scores
  
  n_groups: int, optional, default: 7
      The historal baskets will be partition into `n_groups` equally.
  
  verbose: boolean, optional, default: False
      When True, running logs are displayed.
  
  References
  ----------
  Haoji Hu, Xiangnan He, Jinyang Gao, and Zhi-Li Zhang. 2020.
  Modeling Personalized Item Frequency Information for Next-basket Recommendation.
  In Proceedings of the 43rd International ACM SIGIR Conference on Research and Development in Information Retrieval (SIGIR '20). Association for Computing Machinery, New York, NY, USA, 1071–1080. https://doi.org/10.1145/3397271.3401066
class_docstr_tok: ["Temporal-Item-Frequency-based","User-KNN","(","TIFUKNN",")","Parameters","--","--","--","--","--","name",":","string",",","default",":","'TIFUKNN'","The","name","of","the","recommender","model",".","n_neighbors",":","int",",","optional",",","default",":","300","The","number","of","neighbors","for","KNN","within_decay_rate",":","float",",","optional",",","default",":","0.9","Within-basket","time-decayed","ratio","in","range","[","0",",","1","]","group_decay_rate",":","float",",","optional",",","default",":","0.7","Group","time-decayed","ratio","in","range","[","0",",","1","]","alpha",":","float",",","optional",",","default",":","0.7","The","trade-off","between","current","user","vector","and","neighbors","vectors","to","compute","final","item","scores","n_groups",":","int",",","optional",",","default",":","7","The","historal","baskets","will","be","partition","into","`","n_groups","`","equally",".","verbose",":","boolean",",","optional",",","default",":","False","When","True",",","running","logs","are","displayed",".","References","--","--","--","--","--","Haoji","Hu",",","Xiangnan","He",",","Jinyang","Gao",",","and","Zhi-Li","Zhang",".","2020",".","Modeling","Personalized","Item","Frequency","Information","for","Next-basket","Recommendation",".","In","Proceedings","of","the","43rd","International","ACM","SIGIR","Conference","on","Research","and","Development","in","Information","Retrieval","(","SIGIR","'20",")",".","Association","for","Computing","Machinery",",","New","York",",","NY",",","USA",",","1071\u20131080",".","https",":","\/\/doi.org\/10.1145\/3397271.3401066"]
code: def _group_history_list(self, his_list, n_groups):
      grouped_vec_list = []
      if len(his_list) < n_groups:
          for j in range(len(his_list)):
              grouped_vec_list.append(his_list[j])
          return grouped_vec_list, len(his_list)
      else:
          est_num_vec_each_block = len(his_list) / n_groups
          base_num_vec_each_block = int(
              np.floor(len(his_list) / n_groups)
          )
          residual = est_num_vec_each_block - base_num_vec_each_block
  
          num_vec_has_extra_vec = int(np.round(residual * n_groups))
  
          if residual == 0:
              for i in range(n_groups):
                  sum = np.zeros(len(his_list[0]))
                  for j in range(base_num_vec_each_block):
                      sum += his_list[i * base_num_vec_each_block + j]
                  grouped_vec_list.append(sum / base_num_vec_each_block)
          else:
              for i in range(n_groups - num_vec_has_extra_vec):
                  sum = np.zeros(len(his_list[0]))
                  for j in range(base_num_vec_each_block):
                      sum += his_list[i * base_num_vec_each_block + j]
                      last_idx = i * base_num_vec_each_block + j
                  grouped_vec_list.append(sum / base_num_vec_each_block)
  
              est_num = int(np.ceil(est_num_vec_each_block))
              start_group_idx = n_groups - num_vec_has_extra_vec
              if (
                  len(his_list)
                  - start_group_idx * base_num_vec_each_block
                  >= est_num_vec_each_block
              ):
                  for i in range(start_group_idx, n_groups):
                      sum = np.zeros(len(his_list[0]))
                      for j in range(est_num):
                          iidxx = (
                              last_idx
                              + 1
                              + (i - start_group_idx) * est_num
                              + j
                          )
                          sum += his_list[iidxx]
                      grouped_vec_list.append(sum / est_num)
  
          return grouped_vec_list, n_groups
  
file_path: cornac/cornac/models/tifuknn/recom_tifuknn.py
imports: import warnings
  from time import time
  import numpy
  from tqdm import tqdm
  from ..recommender import NextBasketRecommender
label_desc: Use image node_id 5 for calling the TIFUKNN obj's underlying member method code with example usage: obj._group_history_list(his_list, n_groups) and returns: grouped_vec_list,  len, grouped_vec_list,  n_groups