Git Product home page Git Product logo

pv-system-anomaly-detection's Introduction

SCVAE

This is the codebase for SCVAE.

Usage

This section of the README walks through how to train and evaluate the SCVAE model.

Preparing Data

The training code reads time series from a directory of .csv files. In the data folder, we have provided synthesized data including normal data and 6 types of anoamly data.

For creating your own data, simply prepare the time series data in the same format. The .csv files should at least contain colums of "instantaneous_output_power","instantaneous_global_radiation","clearsky_Tamb" for power yeild, irradiation intensity and environment temperature data. You should also scale the data at the time dimension using Z-Score standardization.

Training

To train your model, you should first decide some hyperparameters.Here are some reasonable defaults for a baseline:

"--h_dim 512 --z_dim 128 --mode 2 --learning_rate 1e-5 --batch_size 256 --seq_shape (-1, 12, 6)"

Once you have setup your hyper-parameters, you can run an experiment like so:

python scripts/SCVAE_train.py --h_dim 512 --z_dim 128

Evaluating

The above training script saves checkpoints to .pth files in the "saved_model" directory.

Once you have a path to your model, you can evaluate your model's reconstruction results using synthesized data like so:

python scripts/SCVAE_eval.py --model_path ./saved_model/SCVAE_savedmodel.pth --anomaly_type all

Getting latent variables & Clustering and classfication

Once you have a path to your model, you can also get the latent variable s of synthesized data as its representations like so. The latent variables are saved as a set of .npy files in the "re_z" folder.

python scripts/get_latent_var.py --model_path ./saved_model/SCVAE_savedmodel.pth --is_trainsites True

Once you have a set of latent variables files, you can do some clustering and classification experiments to analysis these latent variables like so:

python scripts/cluster_and_classify.py --latent_var_path ./re_z --task clustering --latent_mode diff --anomaly_type whole_anomaly
python scripts/cluster_and_classify.py --latent_var_path ./re_z --task classification --latent_mode diff --anomaly_type whole_anomaly --classifier XGB

pv-system-anomaly-detection's People

Contributors

dinglee17 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

urbanmobility

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.