Skip to main content

Implementation of VAESIMCA one class classification method

Project description

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_norm parameter, 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. for alpha = 0.05 it 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 selected alpha values: 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 Axes object as method's argument (instead of pyplot) . The demo notebook has been amended correspondingly.
  • optional parameter show_boundary for method plotDistance() is renamed to show_crit to make it more clear (as it shows critical value for corresponding distance).
  • optional parameter colors for methods plotDistance() and plotAcceptance() 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 = False to the method fit().
  • 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 object 12).
  • 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vaesimca-1.1.0.tar.gz (53.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vaesimca-1.1.0-py3-none-any.whl (18.0 kB view details)

Uploaded Python 3

File details

Details for the file vaesimca-1.1.0.tar.gz.

File metadata

  • Download URL: vaesimca-1.1.0.tar.gz
  • Upload date:
  • Size: 53.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for vaesimca-1.1.0.tar.gz
Algorithm Hash digest
SHA256 146f4ab8631c706854642d78684de9511200eb3ec1c78ddeedede2fd4544a52a
MD5 94456159f23338958f40fddaffd8742a
BLAKE2b-256 85d3ca9e45ee6d6369fe266f0919f13c2be9cc726cd76819c9da72c214e1f6aa

See more details on using hashes here.

File details

Details for the file vaesimca-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: vaesimca-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 18.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for vaesimca-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0a7615439602eee590cacc5e83171aed9ab0a05daff4315f880b5b87b389ea1e
MD5 70287ec1070b462304c4c20ea442d5dc
BLAKE2b-256 eeebe4c39c33e6952d905b1ace5588c48b32101b2083f82fd1971b4108296aa8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page