liveBook · Manning

Anomaly detection

As explained in Machine Learning Algorithms in Depth

A technique for identifying observations that differ substantially from established data patterns.

Anomaly detection identifies observations that differ substantially from established data patterns. In unsupervised learning, a point far from existing clusters can be treated as an anomaly without labeled targets. section 1.1

For time series, an LSTM-VAE learns normal behavior from nonanomalous data. It outputs the log probability of each sensor input under learned Gaussian parameters; an anomaly lowers that likelihood, which can then be thresholded. section 11.1.1

The VAE detector proceeds through these modeling steps:

  • Represent each of n sensors with a mean and variance, producing 2n output parameters under a Gaussian likelihood. section 11.1.1
  • Embed the input signals jointly in a latent Gaussian space that approximates standard normal N(0,1) by minimizing KL divergence. section 11.1.1
  • Train with an objective that maximizes average sensor log likelihood while structuring the latent embedding. section 11.1.1
  • Score new inputs through their log likelihood and signal anomalies when the score drops below a selected threshold. section 11.1.1

Square-wave time series

A simple square-wave input produces a detectable drop in log likelihood when anomalous behavior occurs. Training also shows decreasing total loss across epochs. section 11.1.1

Figure 11.3 LSTM-VAE anomaly detector architecture
figure

Use the architecture figure to trace the LSTM-VAE from multivariate time-series inputs through latent sampling to probabilistic anomaly scores. section 11.1.1

How Machine Learning Algorithms in Depth covers it

How deep it goes
Derives Gaussian likelihoods, latent-space regularization, training objectives, thresholding, and a from-scratch LSTM-VAE implementation.
Examples
Uses distant points from clusters, multivariate sensor signals, a square wave, and the Numenta Anomaly Benchmark.
What you can do after
Implement an LSTM-VAE anomaly detector from scratch with Keras/TensorFlow and threshold log-likelihood drops.
How it connects
Connects unsupervised learning, clustering, variational autoencoders, LSTMs, Gaussian likelihoods, latent spaces, and KL divergence.

Also explained in

Compare how 7 books explain anomaly detection →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Machine Learning Algorithms in Depth. The section links point to the parts of the book it draws on.