liznerski / fcdd

Repository for the Explainable Deep One-Class Classification paper
MIT License
225 stars 62 forks source link

Training with 0 as the anomalous label #71

Closed layadas closed 8 months ago

layadas commented 8 months ago

I am trying to understand how I can edit the code so that I can safely use an anomalous label of 0 as is done in the HSC paper. I went into the loss function definitions in the FCDD trainer and it looks like the loss is hard-coded to consider 0 as nominal and 1 as anomalous. I want to rewrite the loss function so that 0 is anomalous and 1 is nominal. How can I achieve this?

liznerski commented 8 months ago

Hi.

You're right. Apparently this got hard-coded at some point. After a quick check, it seems that the datasets still support a custom nominal label, but the trainer and losses don't. We need to pass the nominal label to the trainer here, here, here, and here. Then, the trainer needs to pass the nominal label definition to the loss invocations at all relevant places. For example, the losses are called here, here, here, here, and here. Then, we need to redefine the loss function to process the nominal label and invert the scores for the AuROC computation. In conclusion, it's perhaps easier to just swap the labels of your dataset. ;)

Btw, there is an updated version of the HSC paper published in TMLR: https://arxiv.org/pdf/2205.11474.pdf.

Hope it helps!

layadas commented 8 months ago

Thank you for your suggestion. It does appear easier to switch the labels. Thank you for the link to the paper.