Ensemble Autoencoder Anomaly Detection

Machine Learning
Introduced by
Chen, J., Sathe, S., Aggarwal, C., & Turaga, D.
Year
2017
Type
Ensemble unsupervised anomaly detection
Family
Machine learning

What does it do?

Ensemble Autoencoder Anomaly Detection trains several autoencoder neural networks on data assumed to be normal and combines their reconstruction errors into one anomaly score.

Because the individual networks differ in initialisation, architecture or input features, the combined score may depend less on any single network's random starting point or architecture choice than a score from one autoencoder does.

The intuition behind the method

A single autoencoder learns to compress and then reconstruct normal observations, so anomalies, which fit the learned pattern poorly, tend to produce high reconstruction error. The weakness is that one autoencoder's score depends on its particular random initialisation and architecture, so rankings can change between runs. An ensemble trains several autoencoders that differ in these respects, then aggregates their reconstruction errors. Idiosyncrasies of individual networks are less likely to dominate the final score, which may make the anomaly signal more stable across runs. Whether this holds for a given dataset should be checked by repeating runs on that data.

History

Autoencoders are neural networks trained to reconstruct their own input, and their reconstruction error can be used as an outlier signal. Using an ensemble of autoencoders, with the member scores aggregated into one anomaly score, extends this idea. The ensemble formulation described on this page is listed with its reference in the citations below.

When to use it

Use this method when most of your data is unlabelled, the features are continuous and numeric, and you want to flag rare unusual observations. Typical cases include sensor streams, transaction logs and physiological signals. It is also a reasonable choice when a single autoencoder gives noticeably different anomaly rankings across random seeds. Avoid it when the training set is very small relative to the number of features, since the autoencoders may not learn a useful representation of normal data. Do not apply it directly to categorical or sparse text data without suitable embedding preprocessing. If a single well-tuned isolation forest or one-class SVM already gives stable, useful results, the extra training cost and tuning of an autoencoder ensemble may not be justified.

Limitations and considerations

  • Training K autoencoders multiplies compute and memory requirements; large ensembles of deep networks are expensive.
  • Assumes anomalies are characterised by high reconstruction error; anomalies that the autoencoders can reconstruct well, including those that lie on the learned normal manifold, may be missed.
  • Sensitive to the proportion of anomalies in training data; heavy contamination degrades the learned normal manifold.
  • Hyperparameter choices (number of models, architecture, aggregation function) require validation data or domain knowledge.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • May reduce the variance of anomaly scores compared with a single autoencoder, which can make rankings more stable across random seeds; verify this by repeating runs on your data.
  • Diverse detectors may capture different aspects of normal behaviour, which can help when anomalies of different kinds are expected.
  • Fully unsupervised: it needs no anomaly labels, only training data assumed to be mostly normal.
  • Applicable to multivariate continuous numeric features, with each network learning a compressed representation of the normal data.
  • Compatible with several autoencoder designs (vanilla, variational, convolutional), so the architecture can be matched to the data structure.
  • Averaging several networks may give a smoother score distribution; the threshold still has to be calibrated on held-out normal data.

Applications

  • Network intrusion detection from high-dimensional packet or flow features.
  • Predictive maintenance anomaly scoring on multivariate sensor time-series.
  • Financial transaction fraud detection in unlabelled or weakly labelled streams.
  • Medical biosignal monitoring (ECG, EEG) for rare pathological patterns.
  • Quality control in manufacturing where defect examples are scarce.
  • Baseline unsupervised outlier scoring before active-learning labelling campaigns.

How it works

How it works

1

K autoencoders are trained independently on the assumed-normal training data. They differ in random initialisation and may also differ in input feature subsets or network architecture. Each network is trained to minimise reconstruction loss on normal samples, so it learns a representation of normal behaviour. Numeric features should be standardised before training, using means and variances computed on the training data only, so that high-variance features do not dominate the reconstruction error.

2

For each observation, every autoencoder encodes it to a latent representation and decodes it back. The per-network error e_i^(k) is the L2 norm (Euclidean distance) between the original input and its reconstruction, as defined in the formula above, computed on the standardised features. A large error means the observation departs from the pattern that network has learned for normal data.

Formula
e_i^{(k)} = \|x_i - \hat{x}_i^{(k)}\|_2
3

The K individual errors are combined into one anomaly score per observation using an aggregation function f. The common options are: the mean of the K errors; the maximum of the K errors, which flags an observation if any one network reports a large error; and a rank-normalised combination, which converts each network's errors into ranks across observations and averages those ranks, so that networks with different error scales contribute comparably. Averaging can reduce the influence of any single network's noise. Because the score distribution changes with f, the threshold must be recalibrated after changing the aggregation.

Formula
s_i = f(e_i^{(1)}, e_i^{(2)}, \ldots, e_i^{(K)})
4

A threshold on the aggregated score labels observations as anomalous. The threshold is often set from a target false-positive rate on held-out normal data. When no labels are available, the highest-scoring observations can be treated as anomalies, but this requires validation before the labels are trusted.

Common pitfalls

  • Including anomalies in the training set without awareness corrupts the learned normal manifold and suppresses anomaly scores for the contaminated observations.
  • Evaluating only on the training set without a held-out normal sample to calibrate the threshold leads to over-confident anomaly labels.
  • Using reconstruction error alone without checking per-dimension contributions, which can hide the features that drive the anomaly score.
  • Feeding raw, unscaled numeric features: reconstruction error is then dominated by high-variance features, so rankings reflect measurement units rather than unusual structure. Standardise features using training-set statistics only.
  • Treating the ensemble as requiring no tuning: the number of autoencoders, their depth and the aggregation function all affect performance and should be validated.
  • Applying the method to datasets with very few observations relative to feature count, where autoencoders cannot generalise and many ordinary points may appear anomalous.

Frequently asked questions

How many autoencoders should the ensemble contain?

There is no fixed number that suits all datasets. Start with a modest ensemble and check whether the aggregated score stays stable across repeated runs. If it still varies noticeably, add members or increase diversity, for example through feature subsampling.

How do I introduce diversity among the autoencoders?

Common strategies include random initialisation, random subsets of input features (feature bagging), different latent dimension sizes, dropout rates, or different architectures (shallow vs. deep). Feature bagging is a straightforward option for tabular data.

Does the training data need to be anomaly-free?

Ideally yes. The more anomalies the training data contains, the more the autoencoders can learn to reconstruct them, which shrinks their anomaly scores. Moderate contamination can be tolerated, but the acceptable level depends on the data and should be checked. A simpler detector, such as an isolation forest, can be used to pre-filter the training data before the autoencoders are trained; check on your data whether this improves the normal reference set.

How should I set the anomaly threshold?

If you have a target false-positive rate (e.g. 1%), set the threshold at the corresponding percentile of the score distribution on held-out normal data. Without any labels, treat the top p% of scores as anomalies and validate with domain experts or downstream evaluation metrics.

When is a single autoencoder better than an ensemble?

When compute is severely constrained, the dataset is small, or one well-tuned autoencoder already shows stable performance across seeds. Ensembles are most likely to help when individual model variance is high or when diverse anomaly types are expected.

Related methods

Sources

  1. Chen, J., Sathe, S., Aggarwal, C., & Turaga, D. (2017). Outlier Detection with Autoencoder Ensembles. In Proceedings of the 2017 SIAM International Conference on Data Mining (SDM), pp. 90–98. SIAM.

    Open publication reference
  2. Aggarwal, C. C. (2017). Outlier Analysis (2nd ed., Ch. 3 & 9). Springer.

    ISBN: 978-3-319-47578-3