ML4ITS / mtad-gat-pytorch

PyTorch implementation of MTAD-GAT (Multivariate Time-Series Anomaly Detection via Graph Attention Networks) by Zhao et. al (2020, https://arxiv.org/abs/2009.02040).
MIT License
328 stars 76 forks source link

The parameter of `adjust_predicts()` #6

Closed vvvu closed 3 years ago

vvvu commented 3 years ago

Thank you for your excellent work! I don't understand the adjust_predicts() function when I was reading the source code.

In the adjust_predicts() function, the comment indicates that

threshold (float): The threshold of anomaly score. A point is labeled as "anomaly" if its score is [[lower than]] the threshold.

But when you preprocess the data, in the preprocess.py file

for anomaly in anomalies:
      label[anomaly[0] : anomaly[1] + 1] = True

My question is, why do you consider a point is labeled as "anomaly" if its score lower than the threshold in the adjust_predicts() function when you set the Label of the anomaly to True during data preprocessing? In my opinion the anomaly point which score is higher than the threshold.

Thanks for your time. Hope you can answer my question.

axeloh commented 3 years ago

Thanks for your input. This is actually a typo from our side. The method adjust_predicts() is an evaluation method taken from OmniAnomaly (as stated in line 19). We simply forgot to change the comment in the method.

In OmniAnomaly, the model outputs reconstruction probabilities that represent the likelihood of the input data. Therefore, they mark instances with a score (probability) below a certain threshold as anomalies. So your intuition is correct, and we do mark instances as anomalous if their anomaly score is above the threshold.

vvvu commented 3 years ago

Thanks for the explanation. It helps me a lot!