This repo contains the code used in the paper "Anomaly Detection with Machine Learning Algorithms in Large-Scale Power Grids", arXiv preprint 2602.10888.
The code base has grown over several years, with different authors involved. It is therefore not optimized in any way, nor thoroughly documented. Nevertheless, this repo enables anybody to reproduce the results presented in the paper, in accordance with modern publication principles.
The first step is to install the virtual environment. This is most easily done with conda, using the command
conda env create -f environment.yml
conda activate AttackDetectionML"AttackDetectionML" is the name of the environment by default.
The dataset used in this project is publicly available on Zenodo:
- Visit https://doi.org/10.5281/zenodo.13378476.
- Click Download next to the file(s) you need.
- Place the downloaded files in the
raw_data/directory of this repo.
The multiples Python scripts in the codes directory must be run sequentially.
These scripts generate the list of on/off anomalies as well as several figures
under figures for manual dataset exploration and validation.
Training loops can take a significant time to run. To run in the background, e.g. on a compute server, use
nohup python -u codes/supervised/01GSCV.py > supervised.out &LSTM models have been run separately on Google Colab using Jupyter notebooks: