07 Outlier Detection
07 Outlier Detection
OUTLIER
DETECTION
Chapter 12. Outlier Analysis
• Outlier and Outlier Analysis
• Outlier Detection Methods
• Statistical Approaches
• Proximity-Base Approaches
• Clustering-Base Approaches
• Classification Approaches
• Mining Contextual and Collective Outliers
• Outlier Detection in High Dimensional Data
2
• Summary
• If a purchase amount is much bigger than usual for a card
owner, and if the purchase occurs far from the owner’s
resident city, then the purchase is suspicious.
• You want to detect such transactions as soon as they occur
and contact the card owner for verification. What data
mining techniques can help detect suspicious transactions?
• Outlier detection (also known as anomaly detection) is the
process of finding data objects with behaviors that are very
different from expectation.
• Outlier detection tries to capture those exceptional cases that
deviate substantially from the majority patterns.
What Are Outliers?
• Outlier: A data object that deviates significantly from the normal objects as if it
were generated by a different mechanism
– Ex.: Unusual credit card purchase
• Outliers are different from the noise data
– Noise is random error or variance in a measured variable
– Noise should be removed before outlier detection
• Outliers are interesting: It violates the mechanism that generates the normal data
• Outlier detection vs. novelty detection: early stage, outlier; but later merged into the
model
• Applications:
– Credit card fraud detection
– Telecom fraud detection(large data packets)
– Customer segmentation
– Medical analysis
4
Types of Outliers (I)
• Three kinds: global, contextual and collective outliers Global Outlier
• Global outlier (or point anomaly)
– Object is Og if it significantly deviates from the rest of the data set
• Ex. Intrusion detection in computer networks(a large number of packages is
broadcast in a short time)
– Issue: Find an appropriate measurement of deviation
• Contextual outlier (or conditional outlier)
– Object is Oc if it deviates significantly based on a selected context
– Ex. 80o F in Urbana: outlier? (depending on summer or winter?)
– Attributes of data objects should be divided into two groups
• Contextual attributes: defines the context, e.g., time & location
• Behavioral attributes: characteristics of the object, used in outlier
evaluation, e.g., temperature
– Can be viewed as a generalization of local outliers—whose density
significantly deviates from its local area
– Issue: How to define or formulate meaningful context?
5
Example of contextual outlier
• Consider customers who use more than 90% of their
credit limit. If one such customer is viewed as belonging
to a group of customers with low credit limits, then such
behavior may not be considered an outlier.
• However, similar behavior of customers from a high-
income group may be considered outliers if their balance
often exceeds their credit limit. Such outliers may lead to
business opportunities—raising credit limits for such
customers can bring in new revenue.
• “How can we formulate meaningful contexts in
contextual outlier detection?”
Types of Outliers (II)
• Collective Outliers
– A subset of data objects collectively deviate significantly from
the whole data set, even if the individual data objects may not
be outliers
– Single delay of delivery and 100 delays.(coincidence)
Collective Outlier
– Applications: E.g., intrusion detection:
• When a number of computers keep sending denial-of-
service packages to each other
13
Outlier Detection (1): Statistical Methods
• Statistical methods (also known as model-based methods) assume that the normal data
follow some statistical model (a stochastic model)
– The data not following the model are outliers.
14
Outlier Detection (2): Proximity-Based Methods
• An object is an outlier if the nearest neighbors of the object are far away, i.e., the proximity
of the object is significantly deviates from the proximity of most of the other objects in the
same data set
Since there are many clustering methods, there are many clustering-based
outlier detection methods as well
Clustering is expensive: straightforward adaption of a clustering method for
outlier detection can be costly and does not scale up well for large data sets
16
Chapter 12. Outlier Analysis
• Outlier and Outlier Analysis
• Outlier Detection Methods
• Statistical Approaches
• Proximity-Base Approaches
• Clustering-Base Approaches
• Classification Approaches
• Mining Contextual and Collective Outliers
• Outlier Detection in High Dimensional Data
• Summary
17
Statistical Approaches
• Statistical approaches assume that the objects in a data set are generated by a
stochastic process (a generative model)
• Idea: learn a generative model fitting the given data set, and then identify the
objects in low probability regions of the model as outliers
• Methods are divided into two categories: parametric vs. non-parametric
• Parametric method
– Assumes that the normal data is generated by a parametric distribution
with parameter θ
– The probability density function of the parametric distribution f(x, θ)
gives the probability that object x is generated by the distribution
– The smaller this value, the more likely x is an outlier
• Non-parametric method
– Not assume an a-priori statistical model and determine the model from the
input data
– Not completely parameter free but consider the number and nature of the
parameters are flexible and not fixed in advance
– Examples: histogram and kernel density estimation
18
Parametric Methods I: Detection Univariate Outliers
Based on Normal Distribution
• Univariate data: A data set involving only one attribute or variable
• Often assume that data are generated from a normal distribution, learn the
parameters from the input data, and identify the points with low probability as
outliers
• Ex: Avg. temp.: {24.0, 28.9, 28.9, 29.0, 29.1, 29.1, 29.2, 29.2, 29.3, 29.4}
– Use the maximum likelihood method to estimate μ and σ
19
Parametric Methods I: The Grubb’s Test
• Univariate outlier detection: The Grubb's test (maximum normed residual test)
─ another statistical method under normal distribution
– For each object x in a data set, compute its z-score: x is an outlier if
20
Parametric Methods II: Detection of
Multivariate Outliers
• Multivariate data: A data set involving two or more attributes or variables
• Transform the multivariate outlier detection task into a univariate outlier
detection problem
• Method 1. Compute Mahalaobis distance
– Let ō be the mean vector for a multivariate data set. Mahalaobis distance
for an object o to ō is MDist(o, ō) = (o – ō )T S –1(o – ō) where S is the
covariance matrix
– Use the Grubb's test on this measure to detect outliers
• Method 2. Use χ2 –statistic:
– where Ei is the mean of the i-dimension among all objects, and n is the
dimensionality
– If χ2 –statistic is large, then object oi is an outlier
21
Parametric Methods III: Using Mixture of Parametric
Distributions
• Assuming data generated by a normal distribution could
be sometimes overly simplified
• Example (right figure): The objects between the two
clusters cannot be captured as outliers since they are
close to the estimated mean
To overcome this problem, assume the normal data is generated by two
normal distributions. For any object o in the data set, the probability that
o is generated by the mixture of the two distributions is given by
where fθ1 and fθ2 are the probability density functions of θ1 and θ2
Then use EM algorithm to learn the parameters μ1, σ1, μ2, σ2 from data
An object o is an outlier if it does not belong to any cluster
22
Non-Parametric Methods: Detection Using Histogram
• Intuition: Objects that are far away from the others are outliers
• Assumption of proximity-based approach: The proximity of an
outlier deviates significantly from that of most of the others in
the data set
• Two types of proximity-based outlier detection methods
– Distance-based outlier detection: An object o is an outlier if
its neighborhood does not have enough other points
– Density-based outlier detection: An object o is an outlier if
its density is relatively much lower than that of its neighbors
25
Distance-Based Outlier Detection
• For each object o, examine the # of other objects in the r-neighborhood of o, where r is a user-
specified distance threshold
• An object o is an outlier if most (taking π as a fraction threshold) of the objects in D are far
away from o, i.e., not in the r-neighborhood of o
26
Distance-Based Outlier Detection: A Grid-Based Method
• Why efficiency is still a concern? When the complete set of objects cannot be
held into main memory, cost I/O swapping
• The major cost: (1) each object tests against the whole data set, why not only
its close neighbor? (2) check objects one by one, why not group by group?
• Grid-based method (CELL): Data space is partitioned into a multi-D grid.
Each cell is a hyper cube with diagonal length r/2
Pruning using the level-1 & level 2 cell properties:
For any possible point x in cell C and any
possible point y in a level-1 cell, dist(x,y) ≤ r
For any possible point x in cell C and any point y
such that dist(x,y) ≥ r, y is in a level-2 cell
Thus we only need to check the objects that cannot be pruned, and even for
such an object o, only need to compute the distance between o and the
objects in the level-2 cells (since beyond level-2, the distance from o is more
than r)
27
Density-Based Outlier Detection
The lower the local reachability density of o, and the higher the local
reachability density of the kNN of o, the higher LOF
This captures a local outlier whose local density is relatively low
comparing to the local densities of its kNN
29
Chapter 12. Outlier Analysis
• Outlier and Outlier Analysis
• Outlier Detection Methods
• Statistical Approaches
• Proximity-Base Approaches
• Clustering-Base Approaches
• Classification Approaches
• Mining Contextual and Collective Outliers
• Outlier Detection in High Dimensional Data
• Summary
30
Clustering-Based Outlier Detection (1 & 2):
Not belong to any cluster, or far from the closest one
• An object is an outlier if (1) it does not belong to any cluster, (2) there is a
large distance between the object and its closest cluster , or (3) it belongs to a
small or sparse cluster
Case I: Not belong to any cluster
Identify animals not part of a flock: Using a density-
based clustering method such as DBSCAN
Case 2: Far from its closest cluster
Using k-means, partition data points of into clusters
For each object o, assign an outlier score based on
its distance from its closest center
If dist(o, c )/avg_dist(c ) is large, likely an outlier
o o
Ex. Intrusion detection: Consider the similarity between
data points and the clusters in a training data set
Use a training set to find patterns of “normal” data, e.g., frequent
itemsets in each segment, and cluster similar connections into groups
Compare new data points with the clusters mined—Outliers are
possible attacks 31
Clustering-Based Outlier Detection (3):
Detecting Outliers in Small Clusters
• FindCBLOF: Detect outliers in small clusters
– Find clusters, and sort them in decreasing size
– To each data point, assign a cluster-based local
outlier factor (CBLOF):
– If obj p belongs to a large cluster, CBLOF =
cluster_size X similarity between p and cluster
– If p belongs to a small one, CBLOF = cluster size X
similarity betw. p and the closest large cluster
Ex. In the figure, o is outlier since its closest large cluster is C 1, but the
similarity between o and C1 is small. For any point in C3, its closest
large cluster is C2 but its similarity from C2 is low, plus |C3| = 3 is small
32
Clustering-Based Method: Strength and Weakness
• Strength
– Detect outliers without requiring any labeled data
– Work for many types of data
– Clusters can be regarded as summaries of the data
– Once the cluster are obtained, need only compare any object against the clusters to
determine whether it is an outlier (fast)
• Weakness
– Effectiveness depends highly on the clustering method used—they may not be
optimized for outlier detection
– High computational cost: Need to first find clusters
– A method to reduce the cost: Fixed-width clustering
• A point is assigned to a cluster if the center of the cluster is within a pre-defined
distance threshold from the point
• If a point cannot be assigned to any existing cluster, a new cluster is created and the
distance threshold may be learned from the training data under certain conditions
Chapter 12. Outlier Analysis
• Outlier and Outlier Analysis
• Outlier Detection Methods
• Statistical Approaches
• Proximity-Base Approaches
• Clustering-Base Approaches
• Classification Approaches
• Mining Contextual and Collective Outliers
• Outlier Detection in High Dimensional Data
• Summary
34
Classification-Based Method I: One-Class Model
• Idea: Train a classification model that can
distinguish “normal” data from outliers
• A brute-force approach: Consider a training set that
contains samples labeled as “normal” and others
labeled as “outlier”
– But, the training set is typically heavily biased:
# of “normal” samples likely far exceeds # of
outlier samples
– Cannot detect unseen anomaly
One-class model: A classifier is built to describe only the normal class.
Learn the decision boundary of the normal class using classification
35
Classification-Based Method II: Semi-Supervised Learning
• Semi-supervised learning: Combining classification-based and
clustering-based methods
• Method
– Using a clustering-based approach, find a large cluster, C,
and a small cluster, C1
– Since some objects in C carry the label “normal”, treat all
objects in C as normal
– Use the one-class model of this cluster to identify normal
objects in outlier detection
– Since some objects in cluster C1 carry the label “outlier”,
declare all objects in C1 as outliers
– Any object that does not fall into the model for C (such as
a) is considered an outlier as well
Comments on classification-based outlier detection methods
the training set, but often difficult to obtain representative and high-
quality training data
36
Chapter 12. Outlier Analysis
• Outlier and Outlier Analysis
• Outlier Detection Methods
• Statistical Approaches
• Proximity-Base Approaches
• Clustering-Base Approaches
• Classification Approaches
• Mining Contextual and Collective Outliers
• Outlier Detection in High Dimensional Data
• Summary
37
Mining Contextual Outliers I: Transform into
Conventional Outlier Detection
• If the contexts can be clearly identified, transform it to conventional
outlier detection
1. Identify the context of the object using the contextual attributes
2. Calculate the outlier score for the object in the context using a
conventional outlier detection method
• Ex. Detect outlier customers in the context of customer groups
– Contextual attributes: age group, postal code
– Behavioral attributes: # of trans/yr, annual total trans. amount
• Steps: (1) locate c’s context, (2) compare c with the other customers in
the same group, and (3) use a conventional outlier detection method
• If the context contains very few customers, generalize contexts
– Ex. Learn a mixture model U on the contextual attributes, and
another mixture model V of the data on the behavior attributes
– Learn a mapping p(Vi|Uj): the probability that a data object o
belonging to cluster Uj on the contextual attributes is generated by
cluster Vi on the behavior attributes
– Outlier score:
38
Mining Contextual Outliers II: Modeling Normal
Behavior with Respect to Contexts
• In some applications, one cannot clearly partition the data into contexts
– Ex. if a customer suddenly purchased a product that is unrelated to those
she recently browsed, it is unclear how many products browsed earlier
should be considered as the context
• Model the “normal” behavior with respect to contexts
– Using a training data set, train a model that predicts the expected behavior
attribute values with respect to the contextual attribute values
– An object is a contextual outlier if its behavior attribute values
significantly deviate from the values predicted by the model
• Using a prediction model that links the contexts and behavior, these methods
avoid the explicit identification of specific contexts
• Methods: A number of classification and prediction techniques can be used to
build such models, such as regression, Markov Models, and Finite State
Automaton
39
Mining Collective Outliers I: On the Set of
“Structured Objects”
• Collective outlier if objects as a group deviate significantly
from the entire data
• Need to examine the structure of the data set, i.e, the
relationships between multiple data objects
Each of these structures is inherent to its respective type of data
For temporal data (such as time series and sequences), we explore
the structures formed by time, which occur in segments of the time
series or subsequences
For spatial data, explore local areas
For graph and network data, we explore subgraphs
Difference from the contextual outlier detection: the structures are
often not explicitly defined, and have to be discovered as part of the
outlier detection process.
Collective outlier detection methods: two categories
Reduce the problem to conventional outlier detection
Identify structure units, treat each structure unit (e.g.,
subsequence, time series segment, local area, or subgraph) as
a data object, and extract features
Then outlier detection on the set of “structured objects”
constructed as such using the extracted features
40
Mining Collective Outliers II: Direct Modeling of the
Expected Behavior of Structure Units
• Models the expected behavior of structure units directly
• Ex. 1. Detect collective outliers in online social network of customers
– Treat each possible subgraph of the network as a structure unit
– Collective outlier: An outlier subgraph in the social network
• Small subgraphs that are of very low frequency
• Large subgraphs that are surprisingly frequent
• Ex. 2. Detect collective outliers in temporal sequences
– Learn a Markov model from the sequences
– A subsequence can then be declared as a collective outlier if it
significantly deviates from the model
• Collective outlier detection is subtle due to the challenge of exploring the
structures in data
– The exploration typically uses heuristics, and thus may be application
dependent
– The computational cost is often high due to the sophisticated mining
process
41
Chapter 12. Outlier Analysis
• Outlier and Outlier Analysis
• Outlier Detection Methods
• Statistical Approaches
• Proximity-Base Approaches
• Clustering-Base Approaches
• Classification Approaches
• Mining Contextual and Collective Outliers
• Outlier Detection in High Dimensional Data
• Summary
42
Challenges for Outlier Detection in High-
Dimensional Data
• Interpretation of outliers
– Detecting outliers without saying why they are outliers is not very useful in high-D
due to many features (or dimensions) are involved in a high-dimensional data set
– E.g., which subspaces that manifest the outliers or an assessment regarding the
“outlier-ness” of the objects
• Data sparsity
– Data in high-D spaces are often sparse
– The distance between objects becomes heavily dominated by noise as the
dimensionality increases
• Data subspaces
– Adaptive to the subspaces signifying the outliers
– Capturing the local behavior of data
• Scalable with respect to dimensionality
– # of subspaces increases exponentially
43
Approach I: Extending Conventional Outlier Detection
• Method 1: Detect outliers in the full space, e.g., HilOut Algorithm
– Find distance-based outliers, but use the ranks of distance instead of the
absolute distance in outlier detection
– For each object o, find its k-nearest neighbors: nn1(o), . . . , nnk(o)
– The weight of object o: