[ANOMALOUS]PYGOD

Author

SEOYEON CHOI

Published

October 27, 2023

Abbr Year Backbone Sampling Class
SCAN 2007 Clustering No pygod.detector.SCAN
GAE 2016 GNN+AE Yes pygod.detector.GAE
Radar 2017 MF No pygod.detector.Radar
ANOMALOUS 2018 MF No pygod.detector.ANOMALOUS
ONE 2019 MF No pygod.detector.ONE
DOMINANT 2019 GNN+AE Yes pygod.detector.DOMINANT
DONE 2020 MLP+AE Yes pygod.detector.DONE
AdONE 2020 MLP+AE Yes pygod.detector.AdONE
AnomalyDAE 2020 GNN+AE Yes pygod.detector.AnomalyDAE
GAAN 2020 GAN Yes pygod.detector.GAAN
OCGNN 2021 GNN Yes pygod.detector.OCGNN
CoLA 2021 GNN+AE+SSL Yes pygod.detector.CoLA
GUIDE 2021 GNN+AE Yes pygod.detector.GUIDE
CONAD 2022 GNN+AE+SSL Yes pygod.detector.CONAD

Import

import pygod
import numpy as np
import torch_geometric.transforms as T
from torch_geometric.datasets import Planetoid

import torch
from pygod.generator import gen_contextual_outlier, gen_structural_outlier

from pygod.utils import load_data

from pygod.metric import eval_roc_auc

from pygod.detector import SCAN, GAE, Radar, ANOMALOUS, ONE, DOMINANT, DONE, AdONE, AnomalyDAE, GAAN, OCGNN, CoLA, GUIDE, CONAD

Data

data = Planetoid('./data/Cora', 'Cora', transform=T.NormalizeFeatures())[0]
data, ya = gen_contextual_outlier(data, n=100, k=50)
data, ys = gen_structural_outlier(data, m=10, n=10)
data.y = torch.logical_or(ys, ya).long()
data = load_data('inj_cora')
data.y = data.y.bool()

SCAN

detector = SCAN(contamination=0.05)
detector.fit(data)
SCAN(contamination=0.05, eps=0.5, mu=2, verbose=0)
pred, score, prob, conf = detector.predict(data,
                                           return_pred=True,
                                           return_score=True,
                                           return_prob=True,
                                           return_conf=True)
print('Labels:')
print(pred)

print('Raw scores:')
print(score)

print('Probability:')
print(prob)

print('Confidence:')
print(conf)
/home/csy/anaconda3/envs/temp_csy/lib/python3.8/site-packages/pygod/detector/scan.py:162: UserWarning: This detector is transductive only. Training from scratch with the input data.
  warnings.warn("This detector is transductive only. "
Labels:
tensor([0, 0, 0,  ..., 0, 0, 0])
Raw scores:
tensor([0., 0., 0.,  ..., 0., 1., 1.])
Probability:
tensor([0., 0., 0.,  ..., 0., 1., 1.])
Confidence:
tensor([1., 1., 1.,  ..., 1., 0., 0.])
auc_score = eval_roc_auc(data.y, score)
print('AUC Score:', auc_score)
AUC Score: 0.6602577116111205
detector.predict(data)
/home/csy/anaconda3/envs/temp_csy/lib/python3.8/site-packages/pygod/detector/scan.py:162: UserWarning: This detector is transductive only. Training from scratch with the input data.
  warnings.warn("This detector is transductive only. "
tensor([0, 0, 0,  ..., 0, 0, 0])

GAE

detector = GAE(contamination=0.05)
detector.fit(data)
/home/csy/anaconda3/envs/temp_csy/lib/python3.8/site-packages/torch_geometric/sampler/neighbor_sampler.py:50: UserWarning: Using '{self.__class__.__name__}' without a 'pyg-lib' installation is deprecated and will be removed soon. Please install 'pyg-lib' for accelerated neighborhood sampling
  warnings.warn("Using '{self.__class__.__name__}' without a "
GAE(act=<function relu at 0x7fc0a6db61f0>,
    backbone=<class 'torch_geometric.nn.models.basic_gnn.GCN'>,
    batch_size=2708, compile_model=False, contamination=0.05, dropout=0.0,
    epoch=100, gpu=None, hid_dim=64, lr=0.004, num_layers=4,
    num_neigh=[-1, -1, -1, -1], recon_s=False, save_emb=False,
    sigmoid_s=False, verbose=False, weight_decay=0.0)
pred, score, prob, conf = detector.predict(data,
                                           return_pred=True,
                                           return_score=True,
                                           return_prob=True,
                                           return_conf=True)
print('Labels:')
print(pred)

print('Raw scores:')
print(score)

print('Probability:')
print(prob)

print('Confidence:')
print(conf)
Labels:
tensor([0, 0, 0,  ..., 0, 0, 0])
Raw scores:
tensor([7.4681e-05, 2.7619e-05, 3.1114e-05,  ..., 3.5192e-05, 4.7995e-05,
        5.1914e-05])
Probability:
tensor([0.1605, 0.0172, 0.0279,  ..., 0.0403, 0.0793, 0.0912])
Confidence:
tensor([1., 1., 1.,  ..., 1., 1., 1.])
auc_score = eval_roc_auc(data.y, score)
print('AUC Score:', auc_score)
AUC Score: 0.7109583826763661
detector.predict(data)
tensor([0, 0, 0,  ..., 0, 0, 0])

Radar

detector = Radar(contamination=0.05)
detector.fit(data)
Radar(contamination=0.05, epoch=100, gamma=1.0, gpu=None, lr=0.004, verbose=0,
      weight_decay=0.0)
pred, score, prob, conf = detector.predict(data,
                                           return_pred=True,
                                           return_score=True,
                                           return_prob=True,
                                           return_conf=True)
print('Labels:')
print(pred)

print('Raw scores:')
print(score)

print('Probability:')
print(prob)

print('Confidence:')
print(conf)
/home/csy/anaconda3/envs/temp_csy/lib/python3.8/site-packages/pygod/detector/radar.py:106: UserWarning: This detector is transductive only. Training from scratch with the input data.
  warnings.warn("This detector is transductive only. "
Labels:
tensor([0, 0, 0,  ..., 0, 0, 0])
Raw scores:
tensor([0.0648, 0.0645, 0.0642,  ..., 0.0652, 0.0641, 0.0653])
Probability:
tensor([0.1813, 0.1800, 0.1786,  ..., 0.1830, 0.1779, 0.1837])
Confidence:
tensor([1.0000, 1.0000, 1.0000,  ..., 0.9991, 1.0000, 0.7069])
auc_score = eval_roc_auc(data.y, score)
print('AUC Score:', auc_score)
AUC Score: 0.5290630462978627
detector.predict(data)
/home/csy/anaconda3/envs/temp_csy/lib/python3.8/site-packages/pygod/detector/radar.py:106: UserWarning: This detector is transductive only. Training from scratch with the input data.
  warnings.warn("This detector is transductive only. "
tensor([0, 0, 0,  ..., 0, 0, 0])

ANOMALOUS

detector = ANOMALOUS(contamination=0.05)
detector.fit(data)
ANOMALOUS(contamination=0.05, epoch=100, gamma=1.0, gpu=None, lr=0.004,
          verbose=0, weight_decay=0.0)
pred, score, prob, conf = detector.predict(data,
                                           return_pred=True,
                                           return_score=True,
                                           return_prob=True,
                                           return_conf=True)
print('Labels:')
print(pred)

print('Raw scores:')
print(score)

print('Probability:')
print(prob)

print('Confidence:')
print(conf)
/home/csy/anaconda3/envs/temp_csy/lib/python3.8/site-packages/pygod/detector/anomalous.py:111: UserWarning: This detector is transductive only. Training from scratch with the input data.
  warnings.warn("This detector is transductive only. "
Labels:
tensor([0, 0, 0,  ..., 0, 0, 0])
Raw scores:
tensor([0.0328, 0.0329, 0.0327,  ..., 0.0326, 0.0324, 0.0324])
Probability:
tensor([6.0319e-05, 7.6742e-05, 5.4724e-05,  ..., 4.5833e-05, 2.9440e-05,
        3.0046e-05])
Confidence:
tensor([1., 1., 1.,  ..., 1., 1., 1.])
auc_score = eval_roc_auc(data.y, score)
print('AUC Score:', auc_score)
AUC Score: 0.34356989793041226
detector.predict(data)
/home/csy/anaconda3/envs/temp_csy/lib/python3.8/site-packages/pygod/detector/anomalous.py:111: UserWarning: This detector is transductive only. Training from scratch with the input data.
  warnings.warn("This detector is transductive only. "
tensor([0, 0, 0,  ..., 0, 0, 0])

ONE

detector = ONE(contamination=0.05)
detector.fit(data)
ONE(alpha=1.0, beta=1.0, contamination=0.05, epoch=5, gamma=1.0, gpu=None,
    hid_a=36, hid_s=36, lr=0.004, verbose=0, weight_decay=0.0)
pred, score, prob, conf = detector.predict(data,
                                           return_pred=True,
                                           return_score=True,
                                           return_prob=True,
                                           return_conf=True)
print('Labels:')
print(pred)

print('Raw scores:')
print(score)

print('Probability:')
print(prob)

print('Confidence:')
print(conf)
Labels:
tensor([1, 0, 0,  ..., 0, 0, 0])
Raw scores:
tensor([0.0005, 0.0003, 0.0003,  ..., 0.0004, 0.0004, 0.0003])
Probability:
tensor([0.6612, 0.2325, 0.2584,  ..., 0.4854, 0.5029, 0.3107])
Confidence:
tensor([0.6309, 1.0000, 1.0000,  ..., 1.0000, 1.0000, 1.0000])
/home/csy/anaconda3/envs/temp_csy/lib/python3.8/site-packages/pygod/detector/one.py:140: UserWarning: This detector is transductive only. Training from scratch with the input data.
  warnings.warn("This detector is transductive only. "
auc_score = eval_roc_auc(data.y, score)
print('AUC Score:', auc_score)
AUC Score: 0.47641121073704384
detector.predict(data)
/home/csy/anaconda3/envs/temp_csy/lib/python3.8/site-packages/pygod/detector/one.py:140: UserWarning: This detector is transductive only. Training from scratch with the input data.
  warnings.warn("This detector is transductive only. "
tensor([0, 1, 0,  ..., 0, 0, 0])

DOMINANT

detector = DOMINANT(contamination=0.05)
detector.fit(data)
/home/csy/anaconda3/envs/temp_csy/lib/python3.8/site-packages/torch_geometric/sampler/neighbor_sampler.py:50: UserWarning: Using '{self.__class__.__name__}' without a 'pyg-lib' installation is deprecated and will be removed soon. Please install 'pyg-lib' for accelerated neighborhood sampling
  warnings.warn("Using '{self.__class__.__name__}' without a "
DOMINANT(act=<function relu at 0x7fc0a6db61f0>,
         backbone=<class 'torch_geometric.nn.models.basic_gnn.GCN'>,
         batch_size=2708, compile_model=False, contamination=0.05,
         dropout=0.0, epoch=100, gpu=None, hid_dim=64, lr=0.004,
         num_layers=4, num_neigh=[-1, -1, -1, -1], save_emb=False,
         sigmoid_s=False, verbose=0, weight=0.5, weight_decay=0.0)
pred, score, prob, conf = detector.predict(data,
                                           return_pred=True,
                                           return_score=True,
                                           return_prob=True,
                                           return_conf=True)
print('Labels:')
print(pred)

print('Raw scores:')
print(score)

print('Probability:')
print(prob)

print('Confidence:')
print(conf)
Labels:
tensor([0, 0, 0,  ..., 0, 0, 0])
Raw scores:
tensor([1.0299, 0.9671, 1.2206,  ..., 0.6122, 1.1306, 1.1348])
Probability:
tensor([0.0779, 0.0668, 0.1116,  ..., 0.0040, 0.0957, 0.0964])
Confidence:
tensor([1., 1., 1.,  ..., 1., 1., 1.])
auc_score = eval_roc_auc(data.y, score)
print('AUC Score:', auc_score)
AUC Score: 0.7674138611628039
detector.predict(data)
/home/csy/anaconda3/envs/temp_csy/lib/python3.8/site-packages/torch_geometric/sampler/neighbor_sampler.py:50: UserWarning: Using '{self.__class__.__name__}' without a 'pyg-lib' installation is deprecated and will be removed soon. Please install 'pyg-lib' for accelerated neighborhood sampling
  warnings.warn("Using '{self.__class__.__name__}' without a "
tensor([0, 0, 0,  ..., 0, 0, 0])

DONE

detector = DONE(contamination=0.05)
detector.fit(data)
DONE(act=<function relu at 0x7fc0a6db61f0>,
     backbone=<class 'torch_geometric.nn.models.basic_gnn.GIN'>,
     batch_size=2708, compile_model=False, contamination=0.05, dropout=0.0,
     epoch=100, gpu=None, hid_dim=64, lr=0.004, num_layers=4,
     num_neigh=[-1], save_emb=False, verbose=0, w1=0.2, w2=0.2, w3=0.2,
     w4=0.2, w5=0.2, weight_decay=0.0)
pred, score, prob, conf = detector.predict(data,
                                           return_pred=True,
                                           return_score=True,
                                           return_prob=True,
                                           return_conf=True)
print('Labels:')
print(pred)

print('Raw scores:')
print(score)

print('Probability:')
print(prob)

print('Confidence:')
print(conf)
/home/csy/anaconda3/envs/temp_csy/lib/python3.8/site-packages/pygod/detector/done.py:217: UserWarning: This detector is transductive only. Training from scratch with the input data.
  warnings.warn("This detector is transductive only. "
Labels:
tensor([0, 0, 0,  ..., 0, 0, 0])
Raw scores:
tensor([0.0004, 0.0003, 0.0004,  ..., 0.0003, 0.0002, 0.0002])
Probability:
tensor([0.0144, 0.0114, 0.0143,  ..., 0.0090, 0.0057, 0.0075])
Confidence:
tensor([1., 1., 1.,  ..., 1., 1., 1.])
auc_score = eval_roc_auc(data.y, score)
print('AUC Score:', auc_score)
AUC Score: 0.8193565668527604
detector.predict(data)
/home/csy/anaconda3/envs/temp_csy/lib/python3.8/site-packages/pygod/detector/done.py:217: UserWarning: This detector is transductive only. Training from scratch with the input data.
  warnings.warn("This detector is transductive only. "
/home/csy/anaconda3/envs/temp_csy/lib/python3.8/site-packages/torch_geometric/sampler/neighbor_sampler.py:50: UserWarning: Using '{self.__class__.__name__}' without a 'pyg-lib' installation is deprecated and will be removed soon. Please install 'pyg-lib' for accelerated neighborhood sampling
  warnings.warn("Using '{self.__class__.__name__}' without a "
tensor([0, 0, 0,  ..., 0, 0, 0])

AdONE

detector = AdONE(contamination=0.05)
detector.fit(data)
AdONE(act=<function relu at 0x7fc0a6db61f0>,
      backbone=<class 'torch_geometric.nn.models.basic_gnn.GIN'>,
      batch_size=2708, compile_model=False, contamination=0.05,
      dropout=0.0, epoch=100, gpu=None, hid_dim=64, lr=0.004, num_layers=4,
      num_neigh=[-1], save_emb=False, verbose=0, w1=0.2, w2=0.2, w3=0.2,
      w4=0.2, w5=0.2, weight_decay=0.0)
pred, score, prob, conf = detector.predict(data,
                                           return_pred=True,
                                           return_score=True,
                                           return_prob=True,
                                           return_conf=True)
print('Labels:')
print(pred)

print('Raw scores:')
print(score)

print('Probability:')
print(prob)

print('Confidence:')
print(conf)
/home/csy/anaconda3/envs/temp_csy/lib/python3.8/site-packages/pygod/detector/adone.py:220: UserWarning: This detector is transductive only. Training from scratch with the input data.
  warnings.warn("This detector is transductive only. "
Labels:
tensor([0, 0, 0,  ..., 1, 0, 0])
Raw scores:
tensor([0.0004, 0.0004, 0.0004,  ..., 0.0007, 0.0003, 0.0003])
Probability:
tensor([0.0061, 0.0059, 0.0063,  ..., 0.0160, 0.0045, 0.0045])
Confidence:
tensor([1.0000, 1.0000, 1.0000,  ..., 0.6644, 1.0000, 1.0000])
auc_score = eval_roc_auc(data.y, score)
print('AUC Score:', auc_score)
AUC Score: 0.8176958213500254
detector.predict(data)
/home/csy/anaconda3/envs/temp_csy/lib/python3.8/site-packages/pygod/detector/adone.py:220: UserWarning: This detector is transductive only. Training from scratch with the input data.
  warnings.warn("This detector is transductive only. "
/home/csy/anaconda3/envs/temp_csy/lib/python3.8/site-packages/torch_geometric/sampler/neighbor_sampler.py:50: UserWarning: Using '{self.__class__.__name__}' without a 'pyg-lib' installation is deprecated and will be removed soon. Please install 'pyg-lib' for accelerated neighborhood sampling
  warnings.warn("Using '{self.__class__.__name__}' without a "
tensor([0, 0, 0,  ..., 0, 0, 0])

AnomalyDAE

detector = AnomalyDAE(contamination=0.05)
detector.fit(data)
AnomalyDAE(act=<function relu at 0x7fc0a6db61f0>, alpha=0.5, backbone=None,
           batch_size=2708, compile_model=False, contamination=0.05,
           dropout=0.0, emb_dim=64, epoch=5, eta=1.0, gpu=None, hid_dim=64,
           lr=0.004, num_layers=4, num_neigh=[-1, -1, -1, -1],
           save_emb=False, theta=1.0, verbose=0, weight_decay=0.0)
pred, score, prob, conf = detector.predict(data,
                                           return_pred=True,
                                           return_score=True,
                                           return_prob=True,
                                           return_conf=True)
print('Labels:')
print(pred)

print('Raw scores:')
print(score)

print('Probability:')
print(prob)

print('Confidence:')
print(conf)
Labels:
tensor([0, 0, 0,  ..., 1, 0, 0])
Raw scores:
tensor([13.3267, 13.3064, 13.3163,  ..., 13.3551, 13.3328, 13.3346])
Probability:
tensor([0.4702, 0.3900, 0.4291,  ..., 0.5820, 0.4940, 0.5013])
Confidence:
tensor([0.9993, 1.0000, 1.0000,  ..., 1.0000, 0.9288, 0.6767])
auc_score = eval_roc_auc(data.y, score)
print('AUC Score:', auc_score)
AUC Score: 0.7103648564822648
detector.predict(data)
/home/csy/anaconda3/envs/temp_csy/lib/python3.8/site-packages/torch_geometric/sampler/neighbor_sampler.py:50: UserWarning: Using '{self.__class__.__name__}' without a 'pyg-lib' installation is deprecated and will be removed soon. Please install 'pyg-lib' for accelerated neighborhood sampling
  warnings.warn("Using '{self.__class__.__name__}' without a "
tensor([0, 0, 0,  ..., 1, 0, 0])

GAAN

detector = GAAN(contamination=0.05)
detector.fit(data)
GAAN(act=<function relu at 0x7fc0a6db61f0>,
     backbone=<class 'torch_geometric.nn.models.basic_gnn.GIN'>,
     batch_size=2708, compile_model=False, contamination=0.05, dropout=0.0,
     epoch=100, gpu=None, hid_dim=64, lr=0.004, noise_dim=16, num_layers=4,
     num_neigh=[0, 0, 0, 0], save_emb=False, verbose=0, weight=0.5,
     weight_decay=0.0)
pred, score, prob, conf = detector.predict(data,
                                           return_pred=True,
                                           return_score=True,
                                           return_prob=True,
                                           return_conf=True)
print('Labels:')
print(pred)

print('Raw scores:')
print(score)

print('Probability:')
print(prob)

print('Confidence:')
print(conf)
Labels:
tensor([0, 0, 0,  ..., 0, 0, 0])
Raw scores:
tensor([ 5.7676,  9.2353, 10.9062,  ...,  7.3059,  8.5299, 10.1563])
Probability:
tensor([nan, nan, nan,  ..., nan, nan, nan])
Confidence:
tensor([1.0000, 1.0000, 0.3032,  ..., 1.0000, 1.0000, 1.0000])
indices = [index for index, value in enumerate(score) if np.isnan(value)]
print(indices)
[459, 915, 1035, 1783]
values_except_indices = [value for index, value in enumerate(data.y) if index not in indices]
print(values_except_indices)
values_except_indices_score = [value for index, value in enumerate(score) if index not in indices]
print(values_except_indices_score)
auc_score = eval_roc_auc(values_except_indices, values_except_indices_score)
print('AUC Score:', auc_score)
AUC Score: 0.5648063186015447
detector.predict(data)
/home/csy/anaconda3/envs/temp_csy/lib/python3.8/site-packages/torch_geometric/sampler/neighbor_sampler.py:50: UserWarning: Using '{self.__class__.__name__}' without a 'pyg-lib' installation is deprecated and will be removed soon. Please install 'pyg-lib' for accelerated neighborhood sampling
  warnings.warn("Using '{self.__class__.__name__}' without a "
tensor([0, 0, 0,  ..., 0, 0, 0])

OCGNN

detector = OCGNN(contamination=0.05)
detector.fit(data)
OCGNN(act=<function relu at 0x7fc0a6db61f0>,
      backbone=<class 'torch_geometric.nn.models.basic_gnn.GCN'>,
      batch_size=2708, beta=0.5, compile_model=False, contamination=0.05,
      dropout=0.0, epoch=100, eps=0.001, gpu=None, hid_dim=64, lr=0.004,
      num_layers=2, num_neigh=[-1, -1], save_emb=False, verbose=0,
      warmup=2, weight_decay=0.0)
pred, score, prob, conf = detector.predict(data,
                                           return_pred=True,
                                           return_score=True,
                                           return_prob=True,
                                           return_conf=True)
print('Labels:')
print(pred)

print('Raw scores:')
print(score)

print('Probability:')
print(prob)

print('Confidence:')
print(conf)
Labels:
tensor([1, 1, 1,  ..., 1, 1, 1])
Raw scores:
tensor([-0.0027, -0.0027, -0.0027,  ..., -0.0027, -0.0027, -0.0027])
Probability:
tensor([0.4665, 0.4665, 0.4665,  ..., 0.4665, 0.4665, 0.4665])
Confidence:
tensor([1., 1., 1.,  ..., 1., 1., 1.])
auc_score = eval_roc_auc(data.y, score)
print('AUC Score:', auc_score)
AUC Score: 0.49961089494163424
detector.predict(data)
/home/csy/anaconda3/envs/temp_csy/lib/python3.8/site-packages/torch_geometric/sampler/neighbor_sampler.py:50: UserWarning: Using '{self.__class__.__name__}' without a 'pyg-lib' installation is deprecated and will be removed soon. Please install 'pyg-lib' for accelerated neighborhood sampling
  warnings.warn("Using '{self.__class__.__name__}' without a "
tensor([1, 1, 1,  ..., 1, 1, 1])

CoLA

detector = CoLA(contamination=0.05)
detector.fit(data)
CoLA(act=<function relu at 0x7fc0a6db61f0>,
     backbone=<class 'torch_geometric.nn.models.basic_gnn.GCN'>,
     batch_size=2708, compile_model=False, contamination=0.05, dropout=0.0,
     epoch=100, gpu=None, hid_dim=64, lr=0.004, num_layers=4,
     num_neigh=[-1, -1, -1, -1], save_emb=False, verbose=0,
     weight_decay=0.0)
pred, score, prob, conf = detector.predict(data,
                                           return_pred=True,
                                           return_score=True,
                                           return_prob=True,
                                           return_conf=True)
print('Labels:')
print(pred)

print('Raw scores:')
print(score)

print('Probability:')
print(prob)

print('Confidence:')
print(conf)
Labels:
tensor([0, 0, 0,  ..., 0, 0, 0])
Raw scores:
tensor([ -4.8481,  -1.8666,  -8.1737,  ...,  -1.4098, -23.5582,  -2.9994])
Probability:
tensor([0.8340, 0.8850, 0.7772,  ..., 0.8928, 0.5143, 0.8656])
Confidence:
tensor([1., 1., 1.,  ..., 1., 1., 1.])
auc_score = eval_roc_auc(data.y, score)
print('AUC Score:', auc_score)
AUC Score: 0.5846472678057859
detector.predict(data)
/home/csy/anaconda3/envs/temp_csy/lib/python3.8/site-packages/torch_geometric/sampler/neighbor_sampler.py:50: UserWarning: Using '{self.__class__.__name__}' without a 'pyg-lib' installation is deprecated and will be removed soon. Please install 'pyg-lib' for accelerated neighborhood sampling
  warnings.warn("Using '{self.__class__.__name__}' without a "
tensor([0, 0, 0,  ..., 0, 0, 1])

GUIDE

detector = GUIDE(contamination=0.05)
detector.fit(data)
GUIDE(act=<function relu at 0x7fc0a6db61f0>, alpha=0.5, backbone=None,
      batch_size=2708, cache_dir=None, compile_model=False,
      contamination=0.05, dropout=0.0, epoch=100, gpu=None,
      graphlet_size=4, hid_a=None, hid_s=None, lr=0.004, num_layers=4,
      num_neigh=[-1, -1, -1, -1], save_emb=False, selected_motif=True,
      verbose=0, weight_decay=0.0)
pred, score, prob, conf = detector.predict(data,
                                           return_pred=True,
                                           return_score=True,
                                           return_prob=True,
                                           return_conf=True)
print('Labels:')
print(pred)

print('Raw scores:')
print(score)

print('Probability:')
print(prob)

print('Confidence:')
print(conf)
Labels:
tensor([0, 0, 0,  ..., 0, 0, 0])
Raw scores:
tensor([2.0098, 1.6367, 7.5997,  ..., 1.5903, 3.3043, 4.8700])
Probability:
tensor([0.0002, 0.0001, 0.0010,  ..., 0.0001, 0.0004, 0.0006])
Confidence:
tensor([1., 1., 1.,  ..., 1., 1., 1.])
auc_score = eval_roc_auc(data.y, score)
print('AUC Score:', auc_score)
AUC Score: 0.7460300005639204
detector.predict(data)
/home/csy/anaconda3/envs/temp_csy/lib/python3.8/site-packages/torch_geometric/sampler/neighbor_sampler.py:50: UserWarning: Using '{self.__class__.__name__}' without a 'pyg-lib' installation is deprecated and will be removed soon. Please install 'pyg-lib' for accelerated neighborhood sampling
  warnings.warn("Using '{self.__class__.__name__}' without a "
tensor([0, 0, 0,  ..., 0, 0, 0])

CONAD

detector = CONAD(contamination=0.05)
detector.fit(data)
CONAD(act=<function relu at 0x7fc0a6db61f0>,
      backbone=<class 'torch_geometric.nn.models.basic_gnn.GCN'>,
      batch_size=2708, compile_model=False, contamination=0.05,
      dropout=0.0, epoch=100, eta=0.5, f=10, gpu=None, hid_dim=64, k=50,
      lr=0.004, m=50, margin=None, num_layers=4,
      num_neigh=[-1, -1, -1, -1], r=0.2, save_emb=False, sigmoid_s=False,
      verbose=0, weight=0.5, weight_decay=0.0)
pred, score, prob, conf = detector.predict(data,
                                           return_pred=True,
                                           return_score=True,
                                           return_prob=True,
                                           return_conf=True)
print('Labels:')
print(pred)

print('Raw scores:')
print(score)

print('Probability:')
print(prob)

print('Confidence:')
print(conf)
Labels:
tensor([0, 0, 0,  ..., 0, 0, 0])
Raw scores:
tensor([1.0205, 0.9653, 1.2166,  ..., 0.6145, 1.1203, 1.1154])
Probability:
tensor([0.0960, 0.0847, 0.1363,  ..., 0.0126, 0.1165, 0.1155])
Confidence:
tensor([1., 1., 1.,  ..., 1., 1., 1.])
auc_score = eval_roc_auc(data.y, score)
print('AUC Score:', auc_score)
AUC Score: 0.7700304517002199
detector.predict(data)
/home/csy/anaconda3/envs/temp_csy/lib/python3.8/site-packages/torch_geometric/sampler/neighbor_sampler.py:50: UserWarning: Using '{self.__class__.__name__}' without a 'pyg-lib' installation is deprecated and will be removed soon. Please install 'pyg-lib' for accelerated neighborhood sampling
  warnings.warn("Using '{self.__class__.__name__}' without a "
tensor([0, 0, 0,  ..., 0, 0, 0])