Anomaly detection

Flag unusual rows without labels: set-up, algorithms and anomaly scores.

Anomaly detection finds rows that differ from the rest: a strange transaction, a sensor reading that looks wrong, an order unlike any other. You do not need labels. The detector learns what normal rows look like and gives every row a score for how unusual it is.

When to use it

Use it when anomalies are rare, you have no examples of them, or the kinds of anomaly keep changing. If you do have labeled examples of the cases you want to catch, Classification usually works better, because the model can learn from them directly.

Set it up

Create the pipeline

Open Pipelines, select New and then New pipeline. Set Task to Anomaly detection, pick the Dataset and select Create pipeline. There is no Target column. The dataset list shows only data sources added as CSV files.

Prepare the columns

Add the steps your data needs, for example imputation for missing values, encoding for categories and a scaler for distance-based detectors. Do not clip outliers with an Outlier Treatment or Winsorization step: the extreme values are what you are looking for.

Choose algorithms

Open the Models part of the pipeline editor and tick one or more detectors, then select Train N models. There is no Cross-validation card for this task.

Algorithms

The catalog has twelve detectors: Isolation Forest, Local Outlier Factor, K-Nearest Neighbors Detector, One-class SVM, Histogram-based Outlier Detection, Principal Component Analysis, Minimum Covariance Determinant, Angle-base Outlier Detection, Connectivity-Based Local Outlier, Clustering-Based Local Outlier, Subspace Outlier Detection and Stochastic Outlier Selection. They need the anomaly components installed on the server. See the Algorithms catalog.

Scores and the contamination rate

Each detector gives every training row an anomaly score: higher means more unusual. A threshold on the score turns it into a flag. The threshold is set by the contamination parameter: the share of rows you expect to be anomalous. Raising it flags more rows; lowering it flags only the most extreme ones. To change it, switch the detector to Manual and edit contamination (see Hyperparameters and tuning).

There are no labels, so there is no right value. Choose it from what an investigator can afford to review. If the team can check 50 rows a week out of 10,000, a contamination of 0.005 is a sensible start.

Plots

Open a model with View details.

TabPlots
DiagnosticsAnomaly score distribution
RawAnomaly map

The Anomaly score distribution chart shows every training row scored by the selected detector, with a dashed line at the threshold above which rows are flagged. For large datasets it scores a random sample of rows and tells you how many. The Anomaly map projects the rows to two dimensions and marks the flagged ones.

In the current version the leaderboard for anomaly runs has no metric columns. Judge a detector by its score distribution and by reviewing the rows it flags.

Next steps

Learn the theory

Lessons on learning.mlflow.es that explain the ideas behind this page.

Updated 2026-11-22