pygod-team / pygod

A Python Library for Graph Outlier Detection (Anomaly Detection)
https://pygod.org
BSD 2-Clause "Simplified" License
1.31k stars 127 forks source link

Running issues with GAAN (Prediction probabilities are all NANs) #93

Closed ZhongLIFR closed 9 months ago

ZhongLIFR commented 10 months ago

Describe the bug I just run a simple example provided by your documentation for the GAAN algorithm on Cora dataset, but I received some result errors that I couldn’t find the reasons. Please kindly help me if possible.

To Reproduce the code is as follows:

import torch from pygod.utils import load_data data = load_data('inj_cora') data.y = data.y.bool()

from pygod.detector import GAAN detector = GAAN(hid_dim=64, num_layers=4, epoch=100, weight=0.6) detector.fit(data)

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)

from pygod.metric import eval_roc_auc

auc_score = eval_roc_auc(data.y, score) print('AUC Score:', auc_score)

Expected behavior The prediction probabilities are all Nans. I thought this may be caused by the dataset Cora itself, but I checked you BOND paper and I found that you have successfully applied GAAN on Cora dataset.

Screenshots A screenshot of my problem.

截屏2023-12-03 17 12 08
kayzliu commented 10 months ago

Thanks for pointing it out. I wonder which version of PyGOD you are using. I actually cannot reproduce the error in my environment. The problem seems to be the overflow of the outlier score. A quick solution can be masking out the nan for evaluation.

mask = ~torch.isnan(score)
eval_roc_auc(data.y[mask], score[mask])
ZhongLIFR commented 9 months ago

Thank you for the reply. It has been solved by updating PyGOD to the latest version.