MCPcopy Create free account
hub / github.com/alibaba/bigcomputing / gen_neg_hist3

Method gen_neg_hist3

DIEN/data_utils.py:140–166  ·  view source on GitHub ↗
(self, length)

Source from the content-addressed store, hash-verified

138 return [neg_item_hist, neg_cate_hist, neg_shop_hist, neg_node_hist, neg_product_hist, neg_brand_hist]
139
140 def gen_neg_hist3(self, length):
141 if len(self.neg_hist_catch.get(length, [1])) == self.max_catch_num:
142 index = int(random.random()*self.max_catch_num)
143 return self.neg_hist_catch[length][index]
144 else:
145 #generate a new neg hist
146 neg_item_hist = []
147 neg_cate_hist = []
148 neg_shop_hist = []
149 neg_node_hist = []
150 neg_product_hist = []
151 neg_brand_hist = []
152 for i in range(length):
153 item_idx = int(random.random()*self.num_items)
154 neg_item = self.all_items[item_idx]
155
156 tmp = self.item_info[neg_item]
157 neg_cate_hist.append(self.map_cate(tmp[0]))
158 neg_shop_hist.append(self.map_shop(tmp[1]))
159 neg_node_hist.append(self.map_node(tmp[2]))
160 neg_product_hist.append(self.map_product(tmp[3]))
161 neg_brand_hist.append(self.map_brand(tmp[4]))
162 neg_item_hist.append(self.map_item(neg_item))#map origin item to item_id
163 self.neg_hist_catch[length] = self.neg_hist_catch.get(length, []) # do not understand TODO
164 self.neg_hist_catch[length].append([neg_item_hist, neg_cate_hist, neg_shop_hist,\
165 neg_node_hist, neg_product_hist, neg_brand_hist])
166 return [neg_item_hist, neg_cate_hist, neg_shop_hist, neg_node_hist, neg_product_hist, neg_brand_hist]
167
168 def gen_neg_hist2(self, length):
169 if len(self.neg_hist_catch.get(length, [1])) == self.max_catch_num:

Callers 2

process2Method · 0.95
processMethod · 0.95

Calls 6

map_cateMethod · 0.95
map_shopMethod · 0.95
map_nodeMethod · 0.95
map_productMethod · 0.95
map_brandMethod · 0.95
map_itemMethod · 0.95

Tested by

no test coverage detected