Results of anomaly detection using GSL-GNN#

from ice.anomaly_detection.datasets import AnomalyDetectionRiethTEP
from ice.anomaly_detection.models import GSL_GNN
from sklearn.preprocessing import StandardScaler
import numpy as np
import pandas as pd

Download the dataset.

dataset = AnomalyDetectionRiethTEP()

Normalize the data.

scaler = StandardScaler()
dataset.df[dataset.train_mask] = scaler.fit_transform(dataset.df[dataset.train_mask])
dataset.df[dataset.test_mask] = scaler.transform(dataset.df[dataset.test_mask])

Create the GNN model.

model = GSL_GNN(
    window_size=32, 
    num_epochs=30, 
    device='cuda',
    verbose=True,
    val_ratio=0.1,
    save_checkpoints=True,
    threshold_level=0.98
    )

Load the checkpoint.

model.load_checkpoint('gnn_anomaly_detection_epoch_30.tar')

Evaluate the model on the test data.

metrics = model.evaluate(dataset.df[dataset.test_mask], dataset.target[dataset.test_mask])
metrics
{'accuracy': 0.8517518472906404,
 'true_positive_rate': [0.82365725],
 'false_positive_rate': [0.019373853211009175]}