text stringlengths 1 93.6k |
|---|
for i in range(len(s_his_nodes)):
|
s_node_his = self.node2hist[s_his_nodes[i]]
|
if s_node_his == []:
|
s_his_tidx_list.append(0)
|
elif np.array([list(i) for i in s_node_his])[:, 1][0] > s_his_times[i]:
|
s_his_tidx_list.append(0)
|
else:
|
his_tidx = np.argwhere(np.array([list(i) for i in s_node_his])[:, 1] <= s_his_times[i])[-1].item()
|
s_his_tidx_list.append(his_tidx)
|
s_his_his_nodes_list = []
|
s_his_his_times_list = []
|
for i in range(len(s_his_nodes)):
|
if len(self.node2hist[s_his_nodes[i]][:s_his_tidx_list[i]]) == 0:
|
s_his_his_nodes = np.array(s_his_nodes[i]).repeat(self.hist_len)
|
s_his_his_times = np.array(s_his_times[i]).repeat(self.hist_len)
|
else:
|
if s_his_tidx_list[i] < self.hist_len:
|
s_his_nei_idx = np.random.choice(np.arange(
|
len(self.node2hist[s_his_nodes[i]][:s_his_tidx_list[i]])), self.hist_len, replace=True)
|
else:
|
s_his_nei_idx = np.random.choice(np.arange(len(self.node2hist[s_his_nodes[i]][:s_his_tidx_list[i]])), self.hist_len, replace=False)
|
s_his_his = [(self.node2hist[s_his_nodes[i]][:s_his_tidx_list[i]])[a] for a in s_his_nei_idx]
|
s_his_his_nodes = [h[0] for h in s_his_his]
|
s_his_his_times = [h[1] for h in s_his_his]
|
s_his_his_times_list.append(s_his_his_times)
|
s_his_his_nodes_list.append(s_his_his_nodes)
|
s_his_his_times_list = np.array(s_his_his_times_list)
|
s_his_his_nodes_list = np.array(s_his_his_nodes_list).astype(int)
|
t_his_tidx_list = []
|
for i in range(len(t_his_nodes)):
|
t_node_his = self.node2hist[t_his_nodes[i]]
|
if t_node_his == []:
|
t_his_tidx_list.append(0)
|
elif np.array([list(i) for i in t_node_his])[:, 1][0] > t_his_times[i]:
|
t_his_tidx_list.append(0)
|
else:
|
his_tidx = np.argwhere(np.array([list(i) for i in t_node_his])[:, 1] <= t_his_times[i])[-1].item()
|
t_his_tidx_list.append(his_tidx+1)
|
t_his_his_nodes_list = []
|
t_his_his_times_list = []
|
for i in range(len(t_his_nodes)):
|
if len(self.node2hist[t_his_nodes[i]][:t_his_tidx_list[i]]) == 0:
|
t_his_his_nodes = np.array(t_his_nodes[i]).repeat(self.hist_len)
|
t_his_his_times = np.array(t_his_times[i]).repeat(self.hist_len)
|
else:
|
if t_his_tidx_list[i] < self.hist_len:
|
t_his_nei_idx = np.random.choice(np.arange(
|
len(self.node2hist[t_his_nodes[i]][:t_his_tidx_list[i]])), self.hist_len, replace=True)
|
else:
|
t_his_nei_idx = np.random.choice(np.arange(
|
len(self.node2hist[t_his_nodes[i]][:t_his_tidx_list[i]])), self.hist_len, replace=False)
|
t_his_his = [(self.node2hist[t_his_nodes[i]][:t_his_tidx_list[i]])[a] for a in t_his_nei_idx]
|
t_his_his_nodes = [h[0] for h in t_his_his]
|
t_his_his_times = [h[1] for h in t_his_his]
|
t_his_his_times_list.append(t_his_his_times)
|
t_his_his_nodes_list.append(t_his_his_nodes)
|
t_his_his_times_list = np.array(t_his_his_times_list)
|
t_his_his_nodes_list = np.array(t_his_his_nodes_list).astype(int)
|
# negtive_sampling part
|
neg_s_nodes = self.negative_sampling().astype(int)
|
neg_tidx_list = []
|
for i in range(self.neg_size):
|
neg_node = self.node2hist[neg_s_nodes[i]]
|
if neg_node == []:
|
neg_tidx_list.append(0)
|
elif np.array([list(i) for i in neg_node])[:, 1][0] > e_time:
|
neg_tidx_list.append(0)
|
else:
|
his_tidx = np.argwhere(np.array([list(i) for i in neg_node])[:, 1] <= e_time)[-1].item()
|
neg_tidx_list.append(his_tidx+1)
|
neg_his_nodes_list = []
|
neg_his_times_list = []
|
# neg_his_len = []
|
for i in range(self.neg_size):
|
if len(self.node2hist[neg_s_nodes[i]][:neg_tidx_list[i]]) == 0:
|
neg_his_nodes = np.array(neg_s_nodes[i]).repeat(self.hist_len)
|
neg_his_times = np.array(e_time).repeat(self.hist_len)
|
else:
|
if neg_tidx_list[i] < self.hist_len:
|
neg_nei_idx = np.random.choice(len(self.node2hist[neg_s_nodes[i]][:neg_tidx_list[i]]), self.hist_len, replace=True)
|
else:
|
neg_nei_idx = np.random.choice(len(self.node2hist[neg_s_nodes[i]][:neg_tidx_list[i]]), self.hist_len, replace=False)
|
neg_his = [(self.node2hist[neg_s_nodes[i]][:neg_tidx_list[i]])[a] for a in neg_nei_idx]
|
neg_his_nodes = [h[0] for h in neg_his]
|
neg_his_times = [h[1] for h in neg_his]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.