Inferensys

Glossary

Anomaly Detection

An unsupervised or semi-supervised machine learning technique that identifies rare items, events, or observations deviating from a learned normality distribution, critical for detecting novel manufacturing defects.
ML engineer detecting AI hallucinations on laptop, fact-checking interface visible, technical debugging moment.
UNSUPERVISED DEFECT DISCOVERY

What is Anomaly Detection?

Anomaly detection is an unsupervised or semi-supervised machine learning technique that identifies rare items, events, or observations which deviate significantly from a learned distribution of normality, making it critical for discovering novel and previously unseen manufacturing defects.

Anomaly detection algorithms model the statistical signature of a conforming product by training exclusively on a corpus of non-defective images. By learning the manifold of normal variance—including acceptable lighting shifts and surface textures—the model can flag any pattern that falls outside this high-dimensional boundary as a potential defect without requiring prior examples of failure modes.

In manufacturing, this technique is essential for catching novel defects that were not represented in a supervised training set. Architectures like autoencoders and generative adversarial networks (GANs) reconstruct a normal image from an input; a high reconstruction error signals an anomaly. This approach directly reduces the escape rate in quality inspection systems.

FOUNDATIONAL METHODS

Core Anomaly Detection Techniques

The mathematical and algorithmic approaches that power unsupervised defect discovery in manufacturing. These techniques learn the statistical signature of normality to flag deviations without requiring labeled examples of every possible flaw.

01

Isolation Forest

An ensemble method that explicitly isolates anomalies rather than profiling normal data points. It constructs an ensemble of random decision trees and exploits the property that anomalous instances are few and different—they require fewer random splits to be isolated from the rest of the data.

  • Anomaly Score: Derived from the average path length across all trees; shorter paths indicate higher anomaly likelihood.
  • Linear Time Complexity: Scales efficiently to high-dimensional sensor telemetry with low memory requirements.
  • No Distance Metric: Unlike k-Nearest Neighbors, it does not rely on pairwise distance calculations, making it robust to the curse of dimensionality.

Manufacturing Use Case: Detecting a sudden deviation in vibration frequency from a CNC spindle that has never failed before, without a pre-labeled failure dataset.

O(n)
Training Complexity
02

Autoencoder Reconstruction Error

A neural network architecture trained to compress high-dimensional input data into a lower-dimensional latent bottleneck and then reconstruct the original input. The core assumption is that the network will learn the dominant patterns of normality.

  • Anomaly Score: The Mean Squared Error (MSE) between the input and its reconstruction. Normal data reconstructs with low error; anomalous data, containing unseen patterns, yields high error.
  • Non-Linear Manifold Learning: Captures complex, non-linear relationships between sensor readings that linear methods like PCA miss.
  • Variational Autoencoders (VAEs): A probabilistic variant that learns a distribution over the latent space, providing a more principled anomaly score via reconstruction probability.

Manufacturing Use Case: A convolutional autoencoder processing images of pristine circuit boards will produce a high reconstruction error when presented with a board containing a subtle, previously unseen solder bridge.

High-Dim
Input Space
03

One-Class Support Vector Machine (OC-SVM)

A kernel method that learns a decision boundary encapsulating the region of the feature space where normal data points are densely concentrated. It separates the normal data distribution from the origin in a high-dimensional space.

  • Nu Parameter: Controls the upper bound on the fraction of training errors and the lower bound on the fraction of support vectors, effectively setting the sensitivity to outliers.
  • Kernel Trick: Using a Radial Basis Function (RBF) kernel allows the algorithm to learn complex, non-spherical decision boundaries around the normal class.
  • Unsupervised by Design: Trained exclusively on data assumed to be normal, making it ideal for cold-start scenarios where failure data is nonexistent.

Manufacturing Use Case: Modeling the normal operating envelope of a hydraulic press's pressure and temperature curves to detect a slow internal leak that manifests as a subtle drift outside the learned boundary.

Single-Class
Training Data
04

Local Outlier Factor (LOF)

A density-based algorithm that computes the local density deviation of a given data point with respect to its neighbors. It identifies anomalies as points that have a substantially lower density than their neighbors, rather than just being far from the global mass of data.

  • Local vs. Global: Excels at detecting anomalies in datasets with varying density clusters, where a point might be normal in one region but anomalous in another.
  • Reachability Distance: The core metric, which is the maximum of the k-distance of a neighbor and the actual distance to that neighbor, used to stabilize density estimates.
  • LOF Score ~1: Indicates a point has similar density to its neighbors. A score significantly greater than 1 flags a local outlier.

Manufacturing Use Case: Identifying a specific production batch that, while within global spec limits, exhibits a unique combination of process parameters that is locally sparse compared to all other batches, indicating a subtle process drift.

Density-Based
Core Principle
05

Mahalanobis Distance

A multivariate distance metric that measures the distance between a point and a distribution. Unlike Euclidean distance, it accounts for the covariance structure of the data, effectively measuring distance in units of standard deviation along each principal component.

  • Correlation-Aware: A deviation in a highly correlated variable is weighted less than a deviation in an independent variable, preventing false alarms from normal correlated fluctuations.
  • Ellipsoidal Threshold: The decision boundary forms a hyper-ellipsoid around the mean of the normal data, defined by the chi-squared distribution.
  • Computationally Lightweight: Requires only the inverse covariance matrix and mean vector of the training data, making it suitable for real-time edge inference on a PLC.

Manufacturing Use Case: Monitoring a motor's current and rotational speed simultaneously. A high-current, low-speed reading might be normal, but a high-current, high-speed reading is a multivariate anomaly flagged by the Mahalanobis distance.

Covariance-Aware
Key Advantage
06

Gaussian Mixture Models (GMMs)

A probabilistic model that represents the normal data as a weighted sum of multiple Gaussian distributions. It assumes the data is generated from a mixture of a finite number of Gaussian distributions with unknown parameters.

  • Log-Likelihood Score: Anomalies are identified as data points with a very low probability density under the learned mixture model, falling in low-density regions between or far from the Gaussian components.
  • Soft Clustering: Unlike k-means, GMMs provide a probability of a point belonging to each component, capturing the multi-modal nature of complex manufacturing processes with distinct operating modes.
  • Expectation-Maximization (EM): The iterative algorithm used to fit the model, alternating between assigning points to components and updating the Gaussian parameters.

Manufacturing Use Case: Modeling a furnace's temperature profile, which has distinct normal distributions for 'ramp-up,' 'steady-state,' and 'cool-down' phases. A temperature reading that is improbable under any of these learned modes is flagged as anomalous.

Multi-Modal
Data Fit
ANOMALY DETECTION

Frequently Asked Questions

Clear, technically precise answers to the most common questions about applying anomaly detection techniques to automated visual quality inspection on the factory floor.

Anomaly detection in computer vision quality inspection is an unsupervised or semi-supervised machine learning technique that identifies rare items, events, or observations which deviate significantly from a learned distribution of normality, without requiring pre-labeled examples of every possible defect type. Unlike supervised defect classification models that must be trained on labeled images of specific defect categories like scratches or dents, an anomaly detection model is trained exclusively on a dataset of conforming, non-defective products. The model learns a compressed, latent representation of what 'good' looks like. During inference, when the model encounters an image that it cannot faithfully reconstruct or that falls outside the learned normal manifold, it flags that sample as anomalous. This approach is critical for manufacturing lines where novel, previously unseen defect types can appear, and where collecting a comprehensive dataset of every possible failure mode is impractical or impossible. Architecturally, these systems often leverage convolutional autoencoders, generative adversarial networks (GANs) like AnoGAN, or vision transformers (ViTs) paired with student-teacher feature distillation. The core mathematical principle involves minimizing a reconstruction error or maximizing a likelihood estimate on normal data, then setting a statistical threshold on the anomaly score—often using the Mahalanobis distance or a percentile of the reconstruction loss distribution—to trigger a defect alert.

PARADIGM COMPARISON

Anomaly Detection vs. Supervised Classification

Contrasting the core assumptions, data requirements, and operational behavior of anomaly detection against standard supervised classification for quality inspection tasks.

FeatureAnomaly DetectionSupervised Classification

Core Objective

Identify deviations from a learned normality distribution

Assign inputs to one of several predefined, known classes

Training Data Requirement

Primarily normal (non-defective) samples; few or no defect examples required

Large, balanced, and labeled dataset of all defect types and non-defective samples

Handling of Novel Defect Types

Labeling Effort

Low; only normal data needs labeling, or labels are entirely absent

High; every image must be meticulously labeled with its specific defect class

Susceptibility to Class Imbalance

Low; designed to model the majority normal class

High; severe imbalance causes bias toward the majority class, missing rare defects

Model Interpretability

Moderate; reconstruction error or distance metrics highlight anomalous regions

High; techniques like Class Activation Mapping (CAM) directly show discriminative regions for a known class

Typical Algorithms

Autoencoders, Gaussian Mixture Models, Isolation Forest, One-Class SVM

ResNet, EfficientNet, Vision Transformer (ViT), YOLO

Primary Metric

Area Under the Receiver Operating Characteristic (AUROC) for anomaly score

F1-Score, Mean Average Precision (mAP) per defect class

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.