Docsity

Clustering - Machine Learning - Slides | CMPS 242, Study notes of Computer Science

Toggle sidebar
bg1
1
Copyright 2005 by David Helmbold 1
Clustering
Reference:
THESE ARE FAR TOO VERBOSE/REPETATIVE
Data Mining by Margaret Dunham (a slide source)
2
Clustering Outline
• Clustering Problem Overview
• Clustering Techniques
– Hierarchical Algorithms
– Partitional Algorithms
Goal:
Goal:
Provide an overview of the clustering
Provide an overview of the clustering
problem and introduce some of the basic
problem and introduce some of the basic
algorithms
algorithms
3
Clustering Examples
•Segment customer database based on
similar buying patterns.
• Group houses in a town into
neighborhoods based on similar
features.
• Identify new plant species
• Identify similar Web usage patterns
4
Clustering Example
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download Clustering - Machine Learning - Slides | CMPS 242 and more Study notes Computer Science in PDF only on Docsity!

Copyright 2005 by David Helmbold 1

Clustering

Reference:

THESE ARE FAR TOO VERBOSE/REPETATIVE Data Mining by Margaret Dunham (a slide source) 2

Clustering Outline

  • Clustering Problem Overview
  • Clustering Techniques
    • Hierarchical Algorithms
    • Partitional Algorithms Goal:Goal:^ Provide an overview of the clusteringProvide an overview of the clustering problem and introduce some of the basicproblem and introduce some of the basic algorithmsalgorithms 3

Clustering Examples

  • Segment customer database based on

similar buying patterns.

  • Group houses in a town into

neighborhoods based on similar

features.

  • Identify new plant species
  • Identify similar Web usage patterns 4

Clustering Example

5

Clustering Houses

Geographic Distance Based Size Based 6

Clustering vs. Classification

  • No prior knowledge
    • Number of clusters
    • Meaning of clusters
  • Unsupervised learning 7

Clustering Issues

  • Outlier handling
  • Dynamic data
  • Interpreting results
  • Evaluating results
  • Number of clusters
  • Data to be used
  • Scalability 8

Impact of Outliers on

Clustering

13

Distance Between Clusters

  • Single Link : smallest distance between points
  • Complete Link: largest distance between points
  • Average Link: average distance between points
  • Centroid: distance between centroids 14

Hierarchical Clustering

  • Clusters are created in levels actually creating sets of clusters at each level.
  • Agglomerative
    • Initially each item in its own cluster
    • Iteratively clusters are merged together
    • Bottom Up
  • Divisive
    • Initially all items in one cluster
    • Large clusters are successively divided
    • Top Down 15

Hierarchical Algorithms

  • Single Link
  • MST Single Link
  • Complete Link
  • Average Link 16

Dendrogram

  • Dendrogram: a tree data structure which illustrates hierarchical clustering techniques.
  • Each level shows clusters for that level. - Leaf – individual clusters - Root – one cluster
  • A cluster at level i is the union of its children clusters at level i+1.

17

Levels of Clustering

18

Agglomerative Example

E 3 3 5 3 0 D 2 4 1 0 3 C 2 2 0 1 5 B 1 0 2 4 3 A 0 1 2 2 3 A BCD E A B E C D 4 Threshold of 12 3 5 A B C D E 19

MST Example

E 3 3 5 3 0 D 2 4 1 0 3 C 2 2 0 1 5 B 1 0 2 4 3 A 0 1 2 2 3 ABC D E A B E C D 20

Agglomerative Algorithm

25

Partitional Algorithms

  • MST
  • Squared Error
  • K-Means
  • Nearest Neighbor
  • PAM
  • Gaussian mixtures
  • Many others 26

MST Algorithm

27

Squared Error

  • Minimized squared error 28

Squared Error Algorithm

29

K-Means

  • Initial set of clusters randomly chosen.
  • Iteratively, items are moved among sets of clusters until the desired set is reached.
  • High degree of similarity among elements in a cluster is obtained.
  • Given a cluster Ki={ti1,ti2,…,tim}, the cluster mean is mi = (1/m)(ti1 + … + tim) 30

K-Means Example

  • Given: {2,4,10,12,3,20,30,11,25}, k=
  • Randomly assign means: m 1 =3,m 2 =
  • K 1 ={2,3}, K 2 ={4,10,12,20,30,11,25}, m 1 =2.5,m 2 =
  • K 1 ={2,3,4},K 2 ={10,12,20,30,11,25}, m 1 =3,m 2 =
  • K 1 ={2,3,4,10},K 2 ={12,20,30,11,25}, m 1 =4.75,m 2 =19.
  • K 1 ={2,3,4,10,11,12},K 2 ={20,30,25}, m 1 =7,m 2 =
  • Stop as the clusters with these means are the same. 31

K-Means Algorithm

32

Nearest Neighbor

  • Items are iteratively merged into the

existing clusters that are closest.

  • Incremental
  • Threshold, t, used to determine if items

are added to existing clusters or a new

cluster is created.

37

PAM Algorithm

38

Clustering

  • Clustering is unsupervised learning,

there are no class labels

  • Want to find groups of “similar”

instances

  • Need a distance measure (usually

Euclidean distance) for dissimilarity

  • Can use cluster membership/distances

as additional features

39

2 approaches:

  • Hierarchical (agglomerative/divisive)
    • Agglomerative merges closest instances/clusters
    • Creates a tree of clusterings
    • Cut at different levels to get different number of clusters
  • Iterative (k-means, Expectation-maximization)
    • Must pick number of clusters k in advance (some adaptation heuristics, Tibshirani Gap statistic)
    • Iterate to improve clustering We will emphasize iterative methods 40

K-means clustering

1. Pick k starting means, μ 1 to μk

Can use: randomly picked examples, perturbations of sample mean, or equally spaced along principle component

2. Repeat until convergence:

1. Split data into k sets, S 1 to Sk

where x ∈ Si iff μi closest mean to x

2. Update each μi to mean of Si

41

Tabular view of k-means

x 3 1 0 0 0 M x 2 0 0 1 0 x 1 1 0 0 0

42

Soft clustering

x 3 .4 .3 .1. M x 2 .2 .1 .5. x 1 .6 .2 .1.

43

From Soft clustering to EM

  • Use weighted mean based on soft-

clustering weights

  • Soft cluster values are probabilities:

P(cluster | x)

  • Uses Bayes’ rule: P(cluster | x) prop. to

P(x|cluster) P(cluster)

  • For each x, the true cluster for x is a

latent (unobserved) variable

44

Soft clustering to EM 2

  • Assume parametric forms for
    • P(cluster) (multinomial)
    • P(x| cluster) (e.g. Gaussian)
  • Iteratively:
    1. Estimate the cluster latent variables based on data and old parameters,
    2. Update parameters to maximize the likelihood assuming new estimates are “truth”
  • This is the EM algorithm - for lots more see http://citeseer.ist.psu.edu/bilmes98gentle.html

49

EM in Gaussian Mixtures

  • zti = 1 if x t^ belongs to Gi , 0 otherwise
  • assume p ( x | Gi )~ N ( μ i , (^) i ) - L c(Φ| X,Z ) = (^) t log(p( xt,zt ) | Φ) - Q (Φnew|Φold) = Z ( (^) t log(p( xt,zt ) | Φold)) P( Z | X , Φ)

( ) [ ( ) ]

l ( l )

l (^) E C l !!! !!!! M-step: argmax! | E-step: | | | (^1) Q Q L X,Z X, = =

50

EM in Gaussian Mixtures

  • zti = 1 if x t^ belongs to Gi , 0 otherwise
  • assume p ( x | Gi )~ N ( μ i , (^) i )
  • E-step:
  • M-step: Use estimated labels in place of unknown labels

[ ] (^ )^ (^ )

( i t^ l ) it

j j l j t it^ l^ t^ i^ l^ i P h p P Ez , p^ P =! = "

#^ # G , G, G X G,^ G x x x | | | ( ) ( )( )

= "^ " = = t^ t^ i l^ T l i t^ it^ t^ l^ i^ t^ i t t t i t i t t il t i i h h h h N h P 1 1 1 1 x m x m x m S G 51 52 P ( G 1 | x )= h 1 =0.

53

Mixtures of Latent Variable

Models

  • Regularize clusters Assume shared/diagonal covariance matrices Use PCA/FA to decrease dimensionality: Mixtures of PCA/FA Can use EM to learn factors V i (Ghahramani and Hinton, 1997; Tipping and Bishop, 1999)

p ( x t | Gi ) = N ( m i, V i V i^ T + øi )

54

After Clustering

  • Dimensionality reduction methods find correlations between features and group features
  • Clustering methods find similarities between instances and group instances
  • Allows knowledge extraction through number of clusters, prior probabilities, cluster parameters, i.e., center, range of features. 55

Clustering as Preprocessing

  • Estimated group labels hj (soft) or bj (hard) may be seen as the dimensions of a new k dimensional space, where we can then learn our discriminant or regressor.
  • Local representation (only one bj is 1, all others are 0; only few hj are nonzero) vs Distributed representation (After PCA; all zj are nonzero) 56

Mixture of Mixtures

  • In classification, the input comes from a

mixture of classes (supervised).

  • If each class is also a mixture, e.g., of

Gaussians, (unsupervised), we have a

mixture of mixtures:

=

=

K i i i k j i ij ij p p P p p P i 1 1 |

C C

C G G

x x x x