- class pygod.detector.SCAN(eps=0.5, mu=2, contamination=0.1, verbose=0)#
Structural Clustering Algorithm for Networks
SCAN is a clustering algorithm, which only takes the graph structure without the node features as the input. Note: This model will output detected clusters instead of “outliers” descibed in the original paper.
This detector is transductive only. Using
predictwith unseen data will train the detector from scratch.
See [XYFS07] for details.
eps (float, optional) – Neighborhood threshold. Default:
mu (int, optional) – Minimal size of clusters. Default:
contamination (float, optional) – Valid in (0., 0.5). The proportion of outliers in the data set. Used when fitting to define the threshold on the decision function. Default:
verbose (int, optional) – Verbosity mode. Range in [0, 3]. Larger value for printing out more log information. Default:
The outlier scores of the training data. The higher, the more abnormal. Outliers tend to have higher scores. This value is available once the detector is fitted.
The threshold is based on
contamination. It is the \(N`*``contamination`\) most abnormal samples in
decision_score_. The threshold is calculated for generating binary outlier labels.
The binary labels of the training data. 0 stands for inliers and 1 for outliers. It is generated by applying
The binary scatter scores of each node, i.e., the “outlier” scores in the original paper.
- fit(data, label=None)#
Fit detector with training data.
self – Fitted detector.
- Return type:
- predict(data=None, label=None, return_pred=True, return_score=False, return_prob=False, prob_method='linear', return_conf=False)#
Prediction for testing data using the fitted detector. Return predicted labels by default.
data (torch_geometric.data.Data, optional) – The testing graph. If
None, the training data is used. Default:
label (torch.Tensor, optional) – The optional outlier ground truth labels used for testing. Default:
return_pred (bool, optional) – Whether to return the predicted binary labels. The labels are determined by the outlier contamination on the raw outlier scores. Default:
return_score (bool, optional) – Whether to return the raw outlier scores. Default:
return_prob (bool, optional) – Whether to return the outlier probabilities. Default:
prob_method (str, optional) –
The method to convert the outlier scores to probabilities. Two approaches are possible:
'linear': simply use min-max conversion to linearly transform the outlier scores into the range of [0,1]. The model must be fitted first.
'unify': use unifying scores, see [KKSZ11].
return_conf (boolean, optional) – Whether to return the model’s confidence in making the same prediction under slightly different training sets. See [PVD20]. Default:
pred (torch.Tensor) – The predicted binary outlier labels of shape \(N\). 0 stands for inliers and 1 for outliers. Only available when
score (torch.Tensor) – The raw outlier scores of shape \(N\). Only available when
prob (torch.Tensor) – The outlier probabilities of shape \(N\). Only available when
conf (torch.Tensor) – The prediction confidence of shape \(N\). Only available when