AutoencoderDetector<T>

Models & Types · AiDotNet.AnomalyDetection.NeuralNetwork

Implements an Autoencoder-based method for anomaly detection using reconstruction error.

Inheritance: ModelBase<T, Matrix<T>, Vector<T>> → AnomalyDetectorBase<T> → AutoencoderDetector<T>

Implements: IGeneratedParameterRegistrar<T>

For Beginners

An autoencoder is a neural network that learns to compress data into a smaller representation and then reconstruct it. Normal data can be reconstructed well, but anomalies (which the autoencoder hasn’t learned to represent) will have high reconstruction error.

How It Works

The algorithm works by:

  1. Training a simple autoencoder (encoder-decoder network) on the data
  2. For each data point, computing the reconstruction error (how different the output is from input)
  3. Points with high reconstruction error are likely anomalies

When to use: Autoencoder-based detection is particularly effective for:

  • High-dimensional data
  • Data with complex patterns
  • When you want the detector to automatically learn important features

Industry Standard Defaults:

  • Encoding dimension: Auto (input_dim/2)
  • Epochs: 50
  • Learning rate: 0.01
  • Batch size: 32
  • Contamination: 0.1 (10%)

This implementation uses a simple fully-connected autoencoder with one hidden layer. For more complex scenarios, consider using a deeper architecture.

Constructors

Constructor Summary
AutoencoderDetector(int encodingDim, int epochs, double learningRate, int batchSize, double contamination, int randomSeed) Creates a new Autoencoder-based anomaly detector.

Properties

Property Summary
double LearningRate { get; } Gets the learning rate.
int EncodingDim { get; } Gets the encoding dimension (bottleneck size).
int Epochs { get; } Gets the number of training epochs.

Methods

Method Summary
Matrix<T> Encode(Matrix<T> X) Gets the encoded representation of the input data.
Vector<T> ScoreAnomalies(Matrix<T> X)
void Fit(Matrix<T> X)