pygod.utils¶
Data Loading¶
- class pygod.utils.load_data(name, cache_dir=None)[source]¶
Data loading function. See data repository for supported datasets. For injected/generated datasets, the labels meanings are as follows.
0: inlier
1: contextual outlier only
2: structural outlier only
3: both contextual outlier and structural outlier
- Parameters:
- Returns:
data – The outlier dataset.
- Return type:
Examples
>>> from pygod.utils import load_data >>> data = load_data(name='weibo') # in PyG format >>> y = data.y.bool() # binary labels (inlier/outlier) >>> yc = data.y >> 0 & 1 # contextual outliers >>> ys = data.y >> 1 & 1 # structural outliers
Score Conversion¶
- pygod.utils.to_edge_score(score, edge_index)[source]¶
Convert outlier node score to outlier edge score by averaging the scores of two nodes connected by an edge.
- Parameters:
score (torch.Tensor) – The node score.
edge_index (torch.Tensor) – The edge index.
- Returns:
score – The edge score.
- Return type:
torch.Tensor