MCPcopy Create free account
hub / github.com/WangXFng/RDRec / sample_seq

Method sample_seq

utils/utils.py:172–179  ·  view source on GitHub ↗
(self, u)

Source from the content-addressed store, hash-verified

170 random.shuffle(self.index_list)
171
172 def sample_seq(self, u):
173 item_history = self.user2items_pos[u] # should have at least 4 items
174 start_item = random.randint(0, len(item_history) - 4) # cannot be the last 3
175 end_item = random.randint(start_item + 1, len(item_history) - 3) # cannot be the last 2
176 item_seg = item_history[start_item:(end_item + 1)] # sample a segment from the sequence without the last two
177 if len(item_seg) > self.max_seq_len:
178 item_seg = item_seg[-self.max_seq_len:]
179 return item_seg
180
181 def sample(self, num):
182 task = [self.task_id] * num

Callers 1

sampleMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected