VAESIMCA — one class classifier based on Variational Autoencoders and data driven SIMCA approach
The package vaesimca implements a method for creating one-class classification (OCC) models (also known as anomaly detectors or novelty detectors) using Variational Autoencoders (VAE). The overall idea is based on another OCC method, DD-SIMCA, and hence can be considered as a adaptation of the DD-SIMCA approach using VAE for data decomposition. The theoretical background and practical examples for the vaesimca methods are described in this paper, please use it for citation. The paper is freely available to everyone via open access option, it is recommended to read it first and then come back and try the examples from the demo notebook.
Pay attention that version 1.1.0 introduces several breaking changes, mostly related to plots, please check the release notes below!
Although the method we proposed is versatile, the package implements VAESIMCA method for analysis of images. It can be installed from PyPI using pip or any other package manager compatible with PyPI, e.g.:
pip install vaesimca
It requires numpy, scipy, torch, torchvision, pandas, torch_lr_finder and matplotlib, which will be automatically installed as dependencies.
Getting started
Use Jupyter notebook demo.ipynb in order to get started. To run the examples from this notebook you need to download zip file with simulated dataset (it is also used for illustration of the method in the paper). Here is direct link to the archive with the dataset.
Simply download the dataset and unzip it to your working directory, where you have the notebook, and follow the guides. CSV files can be downloaded from GitHub as well.
Releases
1.1.0 (05/01/2026)
- please pay attention that this version contains breaking changes, so you either have to amend your previously written code or use an older version. Check the short description below and the demo notebook for code examples.
- further improvements to loss computation, it was decided to drop the
log_normparameter, introduced in previous version, as the new loss works much better. However it will require smaller beta values for some of the cases, pay attention to that. - method
predict()got additional argument,method. By default it is set to"moments", in this case the critical limit for classification is computed based on chi-square distribution (as in conventional DD-SIMCA). If you set it to"quantiles", then the critical limit will be computed based on quantiles (e.g. foralpha = 0.05it will use 95th quantile computed for the training set distances). This can be useful when training set is large (> 1000). This option though works only with selectedalphavalues: 0.10, 0.05, 0.01 and 0.001. - the
gridsearch()has been simplified and improved. First of all now it returns only data frame with average figures of merits for each tested combination of hyperparameters. Second, the best set of hyperparameters is based on average (over iterations) FoM values. - all plotting methods now require matplotlib's
Axesobject as method's argument (instead ofpyplot) . The demo notebook has been amended correspondingly. - optional parameter
show_boundaryfor methodplotDistance()is renamed toshow_critto make it more clear (as it shows critical value for corresponding distance). - optional parameter
colorsfor methodsplotDistance()andplotAcceptance()now should be provided as a dictionary (instead of a list), so every class has a specific color. - several smaller improvements and bug fixes.
- see updated demo.ipynb for all details.
1.0.0 (18/12/2025)
- fixed a bug leading to lack of reproducibility when
predict()is called several times. - when fitting a model, the loss value by default is now normalized to image size and batch size which makes it more stable and reproducible. If you want to use the previous way of computing loss, provide
loss_norm = Falseto the methodfit(). - method
gridsearch()can now be used with CSV based data. - method
plotDistance()shows objects in the same order as they were loaded without regrouping them. - method
plotError()now also works with object index (e.g. show error for object12). - method
stat()returns two outcomes instead of one: the number of accepted/rejected objects for each class (like in previous version) and the figures of merits (TN, FN, TP, FP, sensitivity, specificity and efficiency). - method
gridsearch()also returns two data frames, one with all class based details like in previous version and second one with figures of merits. - method
summary()now also shows figures of merits (sensitivity, specificity and efficiency). - added memory and CUDA device cache cleaning after each grid search iteration to avoid memory leaks.
- several smaller improvements and bug fixes.
0.4.2 (2/6/2025)
- added possibility to load data from CSV files.
- added learning rate finder option.
0.3.7
- fixed a bug in saving state dictionary of the best model during training loop.
Reference
A. Petersen, S. Kucheryavskiy, VAE-SIMCA — Data-driven method for building one class classifiers with variational autoencoders, Chemometrics and Intelligent Laboratory Systems, 256, 2025, 105276, DOI: 10.1016/j.chemolab.2024.105276.
Metadata
Release files for vaesimca 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| vaesimca-1.1.0.tar.gz | 53.1 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| vaesimca-1.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 53.1 MB
Release files / vaesimca-1.1.0.tar.gz
| Download URL | vaesimca-1.1.0.tar.gz |
|---|---|
| Size | 53.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
146f4ab8631c706854642d78684de9511200eb3ec1c78ddeedede2fd4544a52a
|
|
BLAKE2b-256 checksum How to use checksums |
85d3ca9e45ee6d6369fe266f0919f13c2be9cc726cd76819c9da72c214e1f6aa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / vaesimca-1.1.0-py3-none-any.whl
| Download URL | vaesimca-1.1.0-py3-none-any.whl |
|---|---|
| Size | 18.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0a7615439602eee590cacc5e83171aed9ab0a05daff4315f880b5b87b389ea1e
|
|
BLAKE2b-256 checksum How to use checksums |
eeebe4c39c33e6952d905b1ace5588c48b32101b2083f82fd1971b4108296aa8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|