(self, data_files, file_name)
| 204 | |
| 205 | # 2nd method by using previous user's behavior to replace the current user's negative behavior data |
| 206 | def process2(self, data_files, file_name): |
| 207 | #try: |
| 208 | # ss = self.source_buffer.pop() |
| 209 | #except IndexError: |
| 210 | |
| 211 | |
| 212 | source = [] |
| 213 | target = [] |
| 214 | hist_item_list = [] |
| 215 | hist_cate_list = [] |
| 216 | hist_shop_list = [] |
| 217 | hist_node_list = [] |
| 218 | hist_product_list = [] |
| 219 | hist_brand_list = [] |
| 220 | |
| 221 | neg_hist_item_list = [] |
| 222 | neg_hist_cate_list = [] |
| 223 | neg_hist_shop_list = [] |
| 224 | neg_hist_node_list = [] |
| 225 | neg_hist_product_list = [] |
| 226 | neg_hist_brand_list = [] |
| 227 | |
| 228 | last_neg_hist = self.gen_neg_hist3(self.maxlen) |
| 229 | |
| 230 | st = time.time() |
| 231 | #data_size = 20000 |
| 232 | #data_size = 500000 #around 9GB data for maxlength=100 |
| 233 | data_size = 50000 #around 9GB data for maxlength=1000 |
| 234 | line_count = 0 |
| 235 | file_count = 0 |
| 236 | for file_read in data_files: |
| 237 | data_file = self.data_path + file_read |
| 238 | print('Open file ', data_file) |
| 239 | f = open(data_file, 'r') |
| 240 | tmp_s = f.readline() |
| 241 | while(tmp_s): |
| 242 | line_count = line_count + 1 |
| 243 | |
| 244 | ss = tmp_s.strip().split("^H") |
| 245 | uid = self.map_user(ss[0]) |
| 246 | hist_item = map(self.map_item, ss[1].split('\003')) |
| 247 | hist_cate = map(self.map_cate, ss[2].split('\003')) |
| 248 | hist_shop = map(self.map_shop, ss[3].split('\003')) |
| 249 | hist_node = map(self.map_node, ss[4].split('\003')) |
| 250 | hist_product = map(self.map_product, ss[5].split('\003')) |
| 251 | hist_brand = map(self.map_brand, ss[6].split('\003')) |
| 252 | |
| 253 | pos_item = hist_item[-1] |
| 254 | pos_cate = hist_cate[-1] |
| 255 | pos_shop = hist_shop[-1] |
| 256 | pos_node = hist_node[-1] |
| 257 | pos_product = hist_product[-1] |
| 258 | pos_brand = hist_brand[-1] |
| 259 | if self.neg_sample == 'LastInstance': |
| 260 | #set item of last instance as neg sample |
| 261 | neg_item, neg_cate, neg_shop, neg_node, neg_product, neg_brand \ |
| 262 | = self.last_item, self.last_cate, self.last_shop, self.last_node, \ |
| 263 | self.last_product, self.last_brand |
no test coverage detected