dgld.models.DONE.models

class dgld.models.DONE.models.DONE(feat_size: int, num_nodes: int, embedding_dim=32, num_layers=2, activation=LeakyReLU(negative_slope=0.2), dropout=0.0)[source]

Bases: object

fit(graph: DGLHeteroGraph, lr=0.001, weight_decay=0.0, num_epoch=1, num_neighbors=-1, alphas=[0.2, 0.2, 0.2, 0.2, 0.2], batch_size=0, max_len=0, restart=0.5, device='cpu')[source]

Fitting model

Parameters
  • graph (dgl.DGLGraph) – graph data

  • lr (float, optional) – learning rate, by default 1e-3

  • weight_decay (float, optional) – weight decay (L2 penalty), by default 0.

  • num_epoch (int, optional) – number of training epochs, by default 1

  • num_neighbors (int, optional) – number of sampling neighbors, by default -1

  • alphas (list, optional) – balance parameters, by default [0.2]*5

  • batch_size (int, optional) – the size of training batch, by default 0

  • max_len (int, optional) – the maximum length of the truncated random walk, if the value is zero, the adjacency matrix of the original graph is used, by default 0

  • restart (float, optional) – probability of restart, by default 0.5

  • device (str, optional) – device of computation, by default ‘cpu’

predict(graph: DGLHeteroGraph, batch_size=0, max_len=0, restart=0.5, device='cpu', alphas=[0.2, 0.2, 0.2, 0.2, 0.2])[source]

predict and return anomaly score of each node

Parameters
  • graph (dgl.DGLGraph) – graph data

  • batch_size (int, optional) – the size of training batch, by default 0

  • max_len (int, optional) – the maximum length of the truncated random walk, if the value is zero, the adjacency matrix of the original graph is used, by default 0

  • restart (float, optional) – probability of restart, by default 0.5

  • device (str, optional) – device of computation, by default ‘cpu’

  • alphas (list, optional) – balance parameters, by default [0.2]*5

Returns

predict_score – predicted outlier score

Return type

numpy.ndarray

class dgld.models.DONE.models.DONE_Base(feat_size, num_nodes, hid_feats, num_layers, activation, dropout)[source]

Bases: Module

This is a basic structure model of DONE.

Parameters
  • feat_size (int) – the feature dimension of the input data

  • num_nodes (int) – number of nodes

  • hid_feats (int) – the feature dimension of the hidden layers

  • num_layers (int) – number of layers of the auto-encoder, where the number of layers of the encoder and decoder is the same number

  • activation (torch.nn.quantized.functional) – activation function

  • dropout (float) – probability of restart

forward(g, x, c)[source]

Forward Propagation

Parameters
  • g (dgl.DGLGraph) – graph data

  • x (torch.Tensor) – structure matrix

  • c (torch.Tensor) – attribute matrix

training: bool