liveBook · Manning

Variational autoencoder

As explained in Outlier Detection in Python

A variational autoencoder is a generative neural-network model that learns a probabilistic latent representation and reconstructs or generates observations from it.

A variational autoencoder (VAE) is a generative model that compresses an input into a probabilistic latent representation and reconstructs it. Unlike a standard autoencoder, which gives an input a fixed encoding, a VAE represents each latent value with a mean and variance. Training seeks both accurate reconstruction and a well-formed latent space that can support generation of new content. section 16.2.2

For outlier detection, the generative ability is usually not the goal. Instead, reconstruction error estimates how unusual an input is: anomalous inputs tend to reconstruct less accurately. A VAE and a standard autoencoder may perform differently on a given dataset, so neither should be assumed superior. section 16.2.2

Listing 16.3 Example using the PyOD VAE detector
from pyod.models.vae import VAE
 
np.random.seed(0)
det = VAE(epochs=5, random_state=0)
det.fit(X)
 
pred = det.predict_proba(X)[:, 1]

A short PyOD example fits a VAE to X for five epochs, sets a random seed, and obtains outlier predictions with predict_proba(X)[:, 1]. It assumes X has already been collected. section 16.2.2

Check whether the VAE helps before relying on its flags. Compare it with an autoencoder and other detectors using synthetic test data or a pseudo-ground truth, and tune parameters against that evidence. A well-tuned VAE can also add a different perspective to an ensemble. On tabular data, deep-learning detectors are often slower and harder to tune than established alternatives without being more accurate, although large datasets or complex relationships among many features may favor them. section 16.2.2 section 16.0

How Outlier Detection in Python covers it

How deep it goes
Explains latent means and variances and the two training aims, but does not derive the objective or network internals.
Examples
Shows a PyOD VAE fitted to X for five epochs and queried with predict_proba.
What it assumes
Requires collected input data and a compatible deep-learning installation for PyOD; introduces the latent-space distinction without a mathematical derivation.
What you can do after
Apply it via PyOD to produce outlier predictions, then evaluate its performance against autoencoders and other detectors.
How it connects
Connects variational autoencoders to autoencoders, reconstruction error, generative models, ensembles, and Gaussian mixture models.

Also explained in

Compare how 13 books explain variational autoencoder →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Outlier Detection in Python. The section links point to the parts of the book it draws on.