Algorithms
Algorithms
www.jntuworld.com
Cluster analysis
Grouping a set of data objects into clusters
Pattern Recognition
Spatial Data Analysis
create thematic maps in GIS by clustering feature
spaces
detect spatial clusters and explain them in spatial data
mining
Image Processing
Economic Science (especially market research)
WWW
Document classification
access patterns
Scalability
Ability to deal with different types of attributes
Discovery of clusters with arbitrary shape
Minimal requirements for domain knowledge to
determine input parameters
Able to deal with noise and outliers
Insensitive to order of input records
High dimensionality
Incorporation of user-specified constraints
Interpretability and usability
June 9, 2014 Data Mining: Concepts and Techniques 7
Chapter 8. Cluster Analysis
Dissimilarity matrix 0
(one mode) d(2,1) 0
d(3,1) d ( 3,2) 0
: : :
d ( n,1) d ( n,2) ... ... 0
Interval-scaled variables:
Binary variables:
Nominal, ordinal, and ratio variables:
Variables of mixed types:
Standardize data
Calculate the mean absolute deviation:
s f = 1n (| x1 f − m f | + | x2 f − m f | +...+ | xnf − m f |)
d (i, j) =| x − x | + | x − x | + ...+ | x − x |
i1 j1 i2 j 2 ip jp
If q = 2, d is Euclidean distance:
d (i, j) = (| x − x | 2 + | x − x |2 +...+ | x − x | 2 )
i1 j1 i2 j2 ip jp
Properties
d(i,j) ≥ 0
d(i,i) = 0
d(i,j) = d(j,i)
d(i,j) ≤ d(i,k) + d(k,j)
Also, one can use weighted distance, parametric
Pearson product moment correlation, or other
disimilarity measures
f is ordinal or ratio-scaled
Example
10 10
10
9 9
9
8 8
8
7 7
7
6 6
6
5 5
5
4 4
4
Assign 3 Update 3
the
3
each
2 2
2
1
objects
1
0
cluster 1
0
0
0 1 2 3 4 5 6 7 8 9 10 to most
0 1 2 3 4 5 6 7 8 9 10 means 0 1 2 3 4 5 6 7 8 9 10
similar
center reassign reassign
10 10
K=2 9 9
8 8
Arbitrarily choose K 7 7
object as initial
6 6
5 5
2
the 3
1 cluster 1
0
0 1 2 3 4 5 6 7 8 9 10
means 0
0 1 2 3 4 5 6 7 8 9 10
9 9 9
8 8 8
Arbitrary Assign
7 7 7
6 6 6
5
choose k 5
each 5
4 object as 4 remainin 4
3
initial 3 g object 3
2
medoids 2
to 2
nearest
1 1 1
0 0 0
0 1 2 3 4 5 6 7 8 9 10 0 1 2 3 4 5 6 7 8 9 10 medoids 0 1 2 3 4 5 6 7 8 9 10
Do loop 9
Compute
9
Swapping O
8 8
total cost of
Until no
7 7
and Oramdom 6
swapping 6
change
5 5
If quality is 4 4
improved. 3
2
3
1 1
0 0
0 1 2 3 4 5 6 7 8 9 10 0 1 2 3 4 5 6 7 8 9 10
9 9
j
8
t 8 t
7 7
5
j 6
4
i h 4
h
3 3
i
2 2
1 1
0 0
0 1 2 3 4 5 6 7 8 9 10 0 1 2 3 4 5 6 7 8 9 10
10
10
9
9
8
h 8
j
7
7
6
6
5
5 i
i h j
t
4
4
3
3
2
2
t
1
1
0
0
0 1 2 3 4 5 6 7 8 9 10
0 1 2 3 4 5 6 7 8 9 10
9 9 9
8 8 8
7 7 7
6 6 6
5 5 5
4 4 4
3 3 3
2 2 2
1 1 1
0 0 0
0 1 2 3 4 5 6 7 8 9 10 0 1 2 3 4 5 6 7 8 9 10 0 1 2 3 4 5 6 7 8 9 10
10 10
10
9 9
9
8 8
8
7 7
7
6 6
6
5 5
5
4 4
4
3 3
3
2 2
2
1 1
1
0 0
0
0 1 2 3 4 5 6 7 8 9 10 0 1 2 3 4 5 6 7 8 9 10
0 1 2 3 4 5 6 7 8 9 10
dynamic modeling
June 9, 2014 Data Mining: Concepts and Techniques 42
BIRCH (1996)
9
(3,4)
(2,6)
8
4 (4,5)
3
1
(4,7)
(3,8)
0
0 1 2 3 4 5 6 7 8 9 10
Clustering feature:
summary of the statistics for a given subcluster: the 0-th, 1st and
2nd moments of the subcluster from the statistical point of view.
registers crucial measurements for computing cluster and utilizes
storage efficiently
A CF tree is a height-balanced tree that stores the clustering features
for a hierarchical clustering
A nonleaf node in a tree has descendants or “children”
The nonleaf nodes store sums of the CFs of their children
A CF tree has two parameters
Branching factor: specify the maximum number of children.
threshold: max diameter of sub-clusters stored at the leaf nodes
June 9, 2014 Data Mining: Concepts and Techniques 45
CF Tree
Root
Non-leaf node
CF1 CF2 CF3 CF5
child1 child2 child3 child5
x
y y
x x
x x
June 9, 2014 Data Mining: Concepts and Techniques 50
Cure: Shrinking Representative Points
y y
x x
T ∪T
1 2
{3} 1
Sim( T 1, T 2) = = =0.2
{1,2,3,4,5} 5
June 9, 2014 Data Mining: Concepts and Techniques 52
Rock: Algorithm
Data Set
Merge Partition
Final Clusters
Handle noise
One scan
Density-reachable:
p
A point p is density-reachable from
a point q wrt. Eps, MinPts if there p1
q
is a chain of points p1, …, pn, p1 = q,
pn = p such that pi+1 is directly
density-reachable from pi
Density-connected
p q
A point p is density-connected to a
point q wrt. Eps, MinPts if there is
a point o such that both, p and q o
are density-reachable from o wrt.
Eps and MinPts.
June 9, 2014 Data Mining: Concepts and Techniques 60
DBSCAN: Density Based Spatial
Clustering of Applications with Noise
Outlier
Border
Eps = 1cm
Core MinPts = 5
techniques
June 9, 2014 Data Mining: Concepts and Techniques 63
OPTICS: Some Extension from
DBSCAN
Index-based:
k = number of dimensions
N = 20
p = 75% D
M = N(1-p) = 5
Complexity: O(kN2)
Core Distance p1
o
Reachability Distance p2
o
Max (core-distance (o), d (o, p))
MinPts = 5
r(p1, o) = 2.8cm. r(p2,o) = 4cm
June 9, 2014 ε = 3 cm
Data Mining: Concepts and Techniques 64
Reachability
-distance
undefined
ε
ε
ε ‘
Cluster-order
June 9, 2014 Data Mining: Concepts and Techniques
of the objects 65
Density-Based Cluster analysis:
OPTICS & Its Applications
d ( x , y )2
−
f Gaussian ( x , y ) = e 2σ 2
d ( x , xi ) 2
−
( x) = ∑i =1 e
D N
2σ 2
f Gaussian
d ( x , xi ) 2
−
( x, xi ) = ∑ i =1 ( xi − x) ⋅ e
N
∇f D
Gaussian
2σ 2
Multi-resolution
Cost efficiency
Major features:
Complexity O(N)
Partition the data space and find the number of points that
lie inside each cell of the partition.
Identify the subspaces that contain clusters using the
Apriori principle
Identify clusters:
Determine dense units in all subspaces of interests
Determine connected dense units in all subspaces of
interests.
Generate minimal description for the clusters
Determine maximal regions that cover a cluster of
(week)
Salary
0 1 2 3 4 5 6 7
0 1 2 3 4 5 6 7
age age
20 30 40 50 60 20 30 40 50 60
τ=3
Vacation
ry 30 50
a la age
S
Strength
It automatically finds subspaces of the highest
A classification tree
continuous data
suffers similar problems as COBWEB
number of clusters
Popular in industry
(neurons)
Neurons compete in a “winner-takes-all” fashion for
Problem
Find top n outlier points
Applications:
Credit card fraud detection
Customer segmentation
Medical analysis
Drawbacks
most tests are for single attribute
data distribution.
Distance-based outlier: A DB(p, D)-outlier is an object O
in a dataset T such that at least a fraction p of the objects
in T lies at a distance greater than D from O
Algorithms for mining distance-based outliers
Index-based algorithm
Nested-loop algorithm
Cell-based algorithm
Outlier Discovery: Deviation-
Based Approach
Identifies outliers by examining the main characteristics
of objects in a group
Objects that “deviate” from this description are
considered outliers
sequential exception technique
simulates the way in which humans can distinguish
unusual objects from among a series of supposedly
like objects
OLAP data cube technique
uses data cubes to identify regions of anomalies in
large multidimensional data
June 9, 2014 Data Mining: Concepts and Techniques 100
Chapter 8. Cluster Analysis