Course contentsShow
← Machine Learning and Deep Learning
Lesson 374 of 3,5388. Unsupervised Learning: ClusteringFree lesson

Statistical Approaches to Anomaly Detection

Use z-scores, modified z-scores, and IQR methods to detect outliers in univariate and multivariate data.

Statistical Approaches to Anomaly Detection

What you'll learn: How to use z-scores, modified z-scores, and the IQR method to mathematically identify unusual data points in your datasets.

The Core Idea

Statistical anomaly detection treats outliers as data points that are "too far" from the typical values in your dataset. Think of it like spotting a 7-foot-tall person in a crowd—they're not wrong, just statistically rare. These methods quantify "how unusual" each data point is using basic statistical measures.

Three Common Approaches

Z-Score Method

The z-score tells you how many standard deviations a point is from the mean. A z-score of +3 or -3 is a common threshold—anything beyond that is considered unusual.

Analogy: If average test scores are 75 with a standard deviation of 10, a score of 105 (z-score = 3) is flagged as exceptional.

Modified Z-Score

Uses the median and median absolute deviation (MAD) instead of mean and standard deviation. This approach is more robust to existing outliers—they don't skew your detection as much.

IQR Method (Interquartile Range)

Identifies outliers as points falling below Q1 - 1.5×IQR or above Q3 + 1.5×IQR, where IQR = Q3 - Q1. This is what box plots use to show "whiskers" and outlier dots.

Univariate vs Multivariate

Univariate: Apply these methods to one feature at a time (e.g., detecting unusual heights in a population).

Multivariate: Detect points that are unusual in combination across multiple features (e.g., unusual height-weight pairs), often using distances like Mahalanobis distance.

Key Takeaway: Statistical anomaly detection uses simple, interpretable math—z-scores, modified z-scores, and IQR—to flag data points that deviate significantly from normal patterns, working on single features or combinations thereof.