liveBook · Manning

Autoencoder

As explained in Outlier Detection in Python

An autoencoder is a neural network trained to encode an input into a representation and reconstruct the original input.

An autoencoder is a neural network trained to reproduce its input rather than predict a separate target. An encoder compresses each input into a smaller representation; a decoder uses that representation to reconstruct the original. For a table, an input is one row, with neurons corresponding to columns. For an image, the input can be its pixels. section 16.2.1

The narrowest layer is the embedding, bottleneck, or latent representation. Its values form a compact vector for each item. Reconstruction error measures how far the output is from the input; larger errors can indicate outliers. A two-dimensional latent space can make unusual points visible without making its axes readily interpretable. section 16.2.1 section 16.3.1

Figure 16.2 Example of an AE. The neural network learns to condense any input to as many elements as appear in the middle layer and then reconstruct the data to its original values.

The narrowing and widening layers show where compression happens and how the decoder attempts to recover the input. section 16.2.1

Tabular detection with PyOD

A KDD Cup example ordinal-encodes the table, then fits PyOD’s AutoEncoder and obtains outlier probabilities with predict_proba(X)[:, 1]. The listing sets epochs=5 and a random seed. Treat the resulting scores as detector output to assess, not proof that every flagged row is meaningful. section 16.2.1 section 16.2.2

Image reconstruction

An alibi-detect OutlierAE example reconstructs CIFAR10 images. A boat image is reconstructed closely; after random noise is added, its reconstruction error is high and it is flagged. Comparing the input and reconstruction helps inspect what drove the flag. section 16.4

Autoencoders are one reconstructive approach alongside variational autoencoders and other deep-learning detectors. They can add diversity to an ensemble, but tabular results are not generally stronger than established methods and training can be slower and harder to tune. A variational autoencoder also commonly uses reconstruction error for detection, but has a probabilistic latent representation and a generative objective. Another extension, AEGMM, jointly trains an autoencoder and Gaussian mixture model to assess both reconstruction and the learned representation. section 16.0 section 16.2.2 section 16.4

How Outlier Detection in Python covers it

How deep it goes
Explains encoder, bottleneck, decoder, and reconstruction, then demonstrates library detectors rather than deriving their training algorithms.
Examples
Demonstrates a PyOD detector on encoded KDD Cup records and an alibi-detect detector on clean and noise-perturbed CIFAR10 images.
What it assumes
Introduces encoder and decoder roles while assuming familiarity with tabular rows, image pixels, and basic neural networks.
What you can do after
Apply it via PyOD or alibi-detect to score candidate outliers and inspect image reconstructions.
How it connects
Connects embeddings and reconstruction error to variational autoencoders, Gaussian mixture models, and detector ensembles.

Also explained in

Compare how 12 books explain 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.