Anomaly Detection

Anomaly detection, also known as outlier detection, refers to the identification of patterns in a dataset that do not conform to expected behavior. These non-conforming patterns are termed anomalies or outliers, and they often provide critical and actionable information in various application domains.

How Anomaly Detection Works

Approaches to Anomaly Detection:

1. Statistical‍

Based on the assumption that the normal data follows a particular distribution and outliers deviate from this distribution.

2. Machine Learning-Based:

  1. Supervised Anomaly Detection: Requires a labeled dataset containing both normal and anomalous samples. Classic algorithms like SVM, Decision Trees, or Neural Networks can be trained for classification.
  2. Unsupervised Anomaly Detection: Doesn't need labeled data. Algorithms such as k-means clustering, DBSCAN, or autoencoders can be employed.
  3. Semi-Supervised Anomaly Detection: Uses only normal data for training, assuming that anomalies are very rare and shouldn't significantly impact the model. One-class SVM is an example.


Detect anomalies based on the distance of a data point from its neighbors. If a data point's distance from its neighbors exceeds a threshold, it's considered an anomaly.


Compares the density of a data point with its neighbors. Anomalies are data points in low-density regions.


  • Fraud Detection: Spotting unusual patterns in transaction data.
  • Network Security: Identifying intrusions or malicious activities.
  • Health Monitoring: Detecting disease outbreaks or malfunctioning machinery.
  • Quality Assurance: Detecting defects in products.
Lakera LLM Security Playbook
Learn how to protect against the most common LLM vulnerabilities

Download this guide to delve into the most common LLM security risks and ways to mitigate them.

Related terms
No items found.
untouchable mode.
Get started for free.

Lakera Guard protects your LLM applications from cybersecurity risks with a single line of code. Get started in minutes. Become stronger every day.

Join our Slack Community.

Several people are typing about AI/ML security. 
Come join us and 1000+ others in a chat that’s thoroughly SFW.