Outlier detection

On this page 7

Outlier detection is the process of identifying observations that deviate markedly from the pattern of the rest of a dataset, either because they are errors or because they represent rare but genuine behavior. In data processing, it is a standard step of data cleaning and validation that decides whether an extreme value should be corrected, removed, flagged or kept, before the data feeds reports, statistics or machine learning models.

An outlier is defined relative to a model of normal data, not in absolute terms. A salary of 900,000 is extreme among junior employees and ordinary among executives, so every detection method rests on an explicit or implicit assumption about what typical data looks like.

How outlier detection separates unusual from typical values

Every method follows the same logic: build a reference description of normal data, measure how far each point lies from it, and apply a threshold above which a point is flagged. The reference can be a distribution, a set of quantiles, a neighborhood density or a learned model. The threshold controls the trade-off between false alarms and missed outliers.

Outliers themselves fall into several types, and the type determines which method can find them.

Outlier typeDescriptionExample
Global (point) outlierExtreme compared with the whole datasetA body temperature of 52 degrees Celsius
Contextual outlierUnusual only in a given contextHeating demand peak in midsummer
Collective outlierA group of values unusual togetherA flat sensor signal for six hours
Multivariate outlierNormal per variable, odd in combinationHeight 150 cm with weight 120 kg
Types of outliers

Multivariate and collective outliers are the hardest to catch, because univariate checks miss them entirely. A record can pass every single-column rule while still being implausible as a whole.

Statistical and machine learning methods

Methods range from simple rule-based statistics to unsupervised learning algorithms. Simple methods are transparent and fast but assume a particular data shape; advanced methods handle many dimensions but require careful tuning and interpretation.

MethodCore ideaBest suited for
Z-scoreFlags points beyond about 3 standard deviationsRoughly normal, single variables
Modified z-scoreUses median and median absolute deviationSkewed data, contaminated samples
Interquartile range ruleFlags values beyond 1.5 times the IQRQuick univariate screening
Mahalanobis distanceDistance accounting for correlationsMultivariate, roughly elliptical data
Local Outlier FactorCompares local density with neighborsClusters of varying density
Isolation ForestOutliers need fewer random splits to isolateHigh-dimensional tabular data
DBSCANPoints outside dense clusters are noiseSpatial and clustered data
Common outlier detection methods

A key subtlety is masking: when several outliers are present, they inflate the mean and standard deviation, so the plain z-score fails to flag them. Robust statistics such as the median and the median absolute deviation resist this effect, which is why the modified z-score, with a common threshold of 3.5, is often preferred in cleaning pipelines.

Outlier detection compared with anomaly detection and data validation

Outlier detection overlaps with anomaly detection and data validation, yet the terms emphasize different goals and timing. Outlier detection is usually a batch, data-quality activity on an existing dataset, while anomaly detection usually monitors live streams for events that need action.

TaskPrimary goalTypical timing
Outlier detectionFind extreme or inconsistent valuesDuring cleaning and exploration
Anomaly detectionSpot unusual events worth acting onContinuous, often real time
Data validationEnforce explicit rules and schemasAt ingestion and before loading
ImputationReplace missing or removed valuesAfter detection and removal
Outlier detection and related processing tasks

Validation rules catch impossible values, such as a negative age, with certainty. Outlier detection catches improbable values, such as an age of 104, which need judgment. A robust pipeline uses both, with validation first and statistical detection second.

Deciding what to do with detected outliers

Detection is only half of the task; the treatment decision matters more. Deleting every flagged point is a well-known mistake, because genuine extremes often carry the most valuable information, such as fraud, equipment failure or a high-value customer.

SituationRecommended treatmentReason
Confirmed entry errorCorrect from source or removeThe value is simply wrong
Unit or scale mismatchConvert to the standard unitGrams logged as kilograms
Genuine but extreme valueKeep and use robust methodsIt reflects real behavior
Uncertain originFlag and investigateAvoid silent information loss
Heavy-tailed variableTransform or winsorizeLimit influence without deleting
Treatment options for detected outliers
  • Record every removal or correction in a data lineage log so analyses stay reproducible.
  • Compare model results with and without outliers to measure their influence.
  • Involve a domain expert before discarding values in regulated or safety-critical data.

Limitations and common pitfalls

Fixed thresholds such as three standard deviations assume normally distributed data; on heavy-tailed variables like income or transaction amounts, they flag many legitimate values. In high-dimensional data, the curse of dimensionality makes distances between points converge, so distance-based methods lose discriminating power unless features are selected or reduced first.

Unsupervised detectors also require a contamination estimate, the expected share of outliers, which is rarely known in advance. Setting it too high creates noise for reviewers; setting it too low hides real problems. Teams should validate thresholds on labeled samples whenever possible and revisit them as the data drifts.

Order of operations matters as well. Running detection after imputation or aggregation can hide outliers inside averages or create artificial ones from filled values. In most pipelines, detection belongs after validation and before imputation, with seasonal or grouped baselines used whenever the data has strong temporal or categorical structure.

In plain words

Outlier detection is a way of spotting the odd ones out in a pile of data. Imagine checking a class register of heights and finding one student listed at 4 meters tall. Someone almost certainly typed the number wrong.

Not every odd value is a mistake, though. A record sales day may be real and important. The skill lies in finding unusual values first and then deciding carefully whether to fix them, keep them or look closer.

A real-world example

A regional electricity distributor processes readings from about 200,000 smart meters every 15 minutes before the data reaches its billing system. The data team first applies validation rules that reject negative consumption and impossible timestamps. It then runs a modified z-score per meter, comparing each reading with that household’s own recent history rather than with the whole network.

Each week, the pipeline flags roughly 0.3 percent of readings. Reviewers find that most are meter replacement resets and decimal shifts after firmware updates, which are corrected automatically. A smaller group of persistent zero readings at occupied addresses points to meter tampering and is passed to the investigation team. The outcome is fewer disputed bills and a cleaner dataset for demand forecasting.