MCPcopy Index your code
hub / github.com/alibaba/bigcomputing / process

Method process

DIEN/data_utils.py:424–630  ·  view source on GitHub ↗
(self, data_files, file_name)

Source from the content-addressed store, hash-verified

422
423 # Process the data by read in the user information from raw_path file
424 def process(self, data_files, file_name):
425 #try:
426 # ss = self.source_buffer.pop()
427 #except IndexError:
428
429
430 source = []
431 target = []
432 hist_item_list = []
433 hist_cate_list = []
434 hist_shop_list = []
435 hist_node_list = []
436 hist_product_list = []
437 hist_brand_list = []
438
439 neg_hist_item_list = []
440 neg_hist_cate_list = []
441 neg_hist_shop_list = []
442 neg_hist_node_list = []
443 neg_hist_product_list = []
444 neg_hist_brand_list = []
445
446 st = time.time()
447 data_size = 500000 #around 9GB data for maxlength=100
448 #data_size = 250000 #around 9GB data for maxlength=1500
449 line_count = 0
450 file_count = 0
451 for file_read in data_files:
452 data_file = self.data_path + file_read
453 print('Open file ', data_file)
454 f = open(data_file, 'r')
455 tmp_s = f.readline()
456 while(tmp_s):
457 line_count = line_count + 1
458
459 ss = tmp_s.strip().split("^H")
460 uid = self.map_user(ss[0])
461 hist_item = map(self.map_item, ss[1].split('\003'))
462 hist_cate = map(self.map_cate, ss[2].split('\003'))
463 hist_shop = map(self.map_shop, ss[3].split('\003'))
464 hist_node = map(self.map_node, ss[4].split('\003'))
465 hist_product = map(self.map_product, ss[5].split('\003'))
466 hist_brand = map(self.map_brand, ss[6].split('\003'))
467
468 pos_item = hist_item[-1]
469 pos_cate = hist_cate[-1]
470 pos_shop = hist_shop[-1]
471 pos_node = hist_node[-1]
472 pos_product = hist_product[-1]
473 pos_brand = hist_brand[-1]
474 if self.neg_sample == 'LastInstance':
475 #set item of last instance as neg sample
476 neg_item, neg_cate, neg_shop, neg_node, neg_product, neg_brand \
477 = self.last_item, self.last_cate, self.last_shop, self.last_node, \
478 self.last_product, self.last_brand
479 elif self.neg_sample == 'Random':
480 #generate random neg_item information for neg sample
481 item_idx = int(random.random()*self.num_items)

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected