All Projects → hiram64 → ocsvm-anomaly-detection

hiram64 / ocsvm-anomaly-detection

Licence: MIT license
anomaly detection by one-class SVM

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to ocsvm-anomaly-detection

MVTec-Anomaly-Detection
This project proposes an end-to-end framework for semi-supervised Anomaly Detection and Segmentation in images based on Deep Learning.
Stars: ✭ 161 (+143.94%)
Mutual labels:  convolutional-autoencoder, anomaly-detection
deepAD
Detection of Accounting Anomalies in the Latent Space using Adversarial Autoencoder Neural Networks - A lab we prepared for the KDD'19 Workshop on Anomaly Detection in Finance that will walk you through the detection of interpretable accounting anomalies using adversarial autoencoder neural networks. The majority of the lab content is based on J…
Stars: ✭ 65 (-1.52%)
Mutual labels:  anomaly-detection
GMRPD
A Ground Mobile Robot Perception Dataset, IEEE RA-L & IEEE T-CYB
Stars: ✭ 30 (-54.55%)
Mutual labels:  anomaly-detection
FSSD OoD Detection
Feature Space Singularity for Out-of-Distribution Detection. (SafeAI 2021)
Stars: ✭ 66 (+0%)
Mutual labels:  anomaly-detection
drama
Main component extraction for outlier detection
Stars: ✭ 17 (-74.24%)
Mutual labels:  anomaly-detection
pytod
TOD: GPU-accelerated Outlier Detection via Tensor Operations
Stars: ✭ 131 (+98.48%)
Mutual labels:  anomaly-detection
deepcassi
[SIGGRAPH Asia 2017] High-Quality Hyperspectral Reconstruction Using a Spectral Prior
Stars: ✭ 50 (-24.24%)
Mutual labels:  convolutional-autoencoder
ind knn ad
Industrial knn-based anomaly detection for images. Visit streamlit link to check out the demo.
Stars: ✭ 102 (+54.55%)
Mutual labels:  anomaly-detection
DGFraud-TF2
A Deep Graph-based Toolbox for Fraud Detection in TensorFlow 2.X
Stars: ✭ 84 (+27.27%)
Mutual labels:  anomaly-detection
kubervisor
The Kubervisor allow you to control which pods should receive traffic or not based on anomaly detection.It is a new kind of health check system.
Stars: ✭ 35 (-46.97%)
Mutual labels:  anomaly-detection
Hyperspectral-Anomaly-Detection-LSUNRSORAD-and-LSAD-CR-IDW-
This is the code for the paper nemed 'Anomaly Detection for Hyperspectral Imagery Based on the Regularized Subspace Method and Collaborative Representation'
Stars: ✭ 22 (-66.67%)
Mutual labels:  anomaly-detection
pytorch-cifar-model-zoo
Implementation of Conv-based and Vit-based networks designed for CIFAR.
Stars: ✭ 62 (-6.06%)
Mutual labels:  cifar10
ResidualAttentionNetwork
A Gluon implement of Residual Attention Network. Best acc on cifar10-97.78%.
Stars: ✭ 104 (+57.58%)
Mutual labels:  cifar10
transfertools
Python toolbox for transfer learning.
Stars: ✭ 22 (-66.67%)
Mutual labels:  anomaly-detection
COVID-away
Repo of paper title 'Avoid touching your face: A hand-to-face 3d motion dataset (covid-away) and trained models for smartwatches'
Stars: ✭ 18 (-72.73%)
Mutual labels:  one-class-svm
anompy
A Python library for anomaly detection
Stars: ✭ 13 (-80.3%)
Mutual labels:  anomaly-detection
anomaly-detection-models
some anomaly detection models and experiments.
Stars: ✭ 19 (-71.21%)
Mutual labels:  anomaly-detection
f anogan pytorch
Code for reproducing f-AnoGAN in Pytorch
Stars: ✭ 28 (-57.58%)
Mutual labels:  anomaly-detection
gans-2.0
Generative Adversarial Networks in TensorFlow 2.0
Stars: ✭ 76 (+15.15%)
Mutual labels:  cifar10
coursera-ml-py-sj
No description or website provided.
Stars: ✭ 41 (-37.88%)
Mutual labels:  anomaly-detection

Unsupervised Anomaly Detection with One-Class Support Vector Machine

This repository includes codes for unsupervised anomaly detection by means of One-Class SVM(Support Vector Machine). In the codes, CIFAR10 is expected to be used. Firstly, the image data are compressed by convolutional autoencoder(CAE) to vector features. Secondly, training a model only with the features of the data which you define as normal will be done. At the last, you can run anomaly detection with One-Class SVM and you can evaluate the models by AUCs of ROC and PR.

Dependencies

scikit-learn, Keras, Numpy, OpenCV

My test environment: Python3.6, scikit-learn==.21.2, Keras==2.2.4 , numpy==1.16.4, opencv-python==4.1.0.25

How to use

1. Prepare data

Prepare data and labels to use. For instance, CIFAR10 is composed of 10 classes and each label should express unique class and be integer. These prepared data should be placed in the data directory.

You can download CIFAR10 data via :
https://www.kaggle.com/janzenliu/cifar-10-batches-py

Put them in "data" directory and run the following code to compress them into NPZ file.

python make_cifar10_npz.py

After running this code, you can get cifar10.npz under "data" directory.

(Optional)

When you use your own dataset, please prepare npz file as the same format as CIFAR-10.

data = np.load('your_data.npz')
data.files
-> ['images', 'labels'] # "images" and "labels" keys'

data['labels']
-> array([6, 9, 9, ..., 5, 1, 7]) # labels is the vector composed of integers which correspond to each class identifier.

Note : Please be careful fo input image size of model.py.
You might need to change network architecture's parameter so that it can deal with your images.

2. Train CAE

Run the following command. Settable parameters like epoch, batchsize or output directory are described in the script.

python cae.py

The encoded features by CAE will be saved in the "data" directory as cifar10_cae.npz.

3. Run Anomaly Detection

First, normal class needs to be defined by "normal_label". It means the other classes EXCEPT the normal class will be automatically defined as abnormal. By running the script below, OC-SVM is trained with the normal data. As evaluation metrics, AUCs of ROC(Receiver Operating Characteristic) and PR(Precision and Recall) are calculated.

By default, training models and test procedure are repeated over different nu parameters(see scikit-learn document. gamma and kernel are fixed in the script). For each nu and its trained model, the AUCs are averaged over 10 different test data set.

python anomaly_detection_ocsvm.py

Please look into the script for the settable parameters.

scikit-learn(sklearn.svm.OneClassSVM)
http://scikit-learn.org/stable/modules/generated/sklearn.svm.OneClassSVM.html

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].