- pygod.generator.gen_contextual_outlier(data, n, k, seed=None)#
Generating contextual outliers according to paper [DLBL19]. We randomly select
nnodes as the attribute perturbation candidates. For each selected node \(i\), we randomly pick another
knodes from the data and select the node \(j\) whose attributes \(x_j\) deviate the most from node \(i\)’s attribute \(x_i\) among
knodes by maximizing the Euclidean distance \(\| x_i − x_j \|\). Afterwards, we then substitute the attributes \(x_i\) of node \(i\) to \(x_j\).
data (torch_geometric.data.Data) – The contextual outlier graph with modified node attributes.
y_outlier (torch.Tensor) – The outlier label tensor where 1 represents outliers and 0 represents normal nodes.
- pygod.generator.gen_structural_outlier(data, m, n, p=0, directed=False, seed=None)#
Generating structural outliers according to paper : cite:ding2019deep. We randomly select
mnodes from the network and then make those nodes fully connected, and then all the
mnodes in the clique are regarded as outliers. We iteratively repeat this process until a number of
ncliques are generated and the total number of structural outliers is
m * n.
data (torch_geometric.data.Data) – The input data.
m (int) – Number nodes in the outlier cliques.
n (int) – Number of outlier cliques.
p (int, optional) – Probability of edge drop in cliques. Default:
directed (bool, optional) – Whether the edges added are directed. Default:
seed (int, optional) – The seed to control the randomness, Default:
data (torch_geometric.data.Data) – The structural outlier graph with injected edges.