Clustering: Hierarchical Clustering and K- Means Clustering - - PowerPoint PPT Presentation

clustering hierarchical clustering and k means clustering
SMART_READER_LITE
LIVE PREVIEW

Clustering: Hierarchical Clustering and K- Means Clustering - - PowerPoint PPT Presentation

Clustering: Hierarchical Clustering and K- Means Clustering Machine Learning 10-601B Seyoung Kim Many of these slides are derived from William Cohen,


slide-1
SLIDE 1

Clustering: ¡Hierarchical ¡Clustering ¡and ¡K-­‑ Means ¡Clustering ¡

Machine ¡Learning ¡10-­‑601B ¡ Seyoung ¡Kim ¡

Many ¡of ¡these ¡slides ¡are ¡derived ¡from ¡William ¡ Cohen, ¡Ziv ¡Bar-­‑Joseph, ¡Eric ¡Xing. ¡Thanks! ¡

slide-2
SLIDE 2

Two ¡Classes ¡of ¡Learning ¡Problems ¡

  • Supervised ¡learning ¡= ¡learning ¡from ¡labeled ¡data, ¡where ¡class ¡

labels ¡(in ¡classificaNon) ¡or ¡output ¡values ¡(regression) ¡are ¡given ¡ ¡ ¡ ¡

– Train ¡data: ¡(X, ¡Y) ¡for ¡inputs ¡X ¡and ¡labels ¡Y ¡

  • Unsupervised ¡learning ¡= ¡learning ¡from ¡unlabeled, ¡

unannotated ¡data ¡

– Train ¡data: ¡X ¡for ¡unlabeled ¡data ¡ – we ¡do ¡not ¡have ¡a ¡teacher ¡that ¡provides ¡examples ¡with ¡their ¡labels ¡ ¡

slide-3
SLIDE 3
  • Organizing ¡data ¡into ¡

clusters ¡such ¡that ¡there ¡is ¡

  • ¡high ¡intra-­‑cluster ¡similarity ¡
  • ¡low ¡inter-­‑cluster ¡similarity ¡ ¡
  • Informally, ¡finding ¡natural ¡

groupings ¡among ¡objects. ¡

  • Why ¡do ¡we ¡want ¡to ¡do ¡that? ¡
  • Any ¡REAL ¡applicaNon? ¡
slide-4
SLIDE 4

Examples ¡

  • People ¡
  • Images ¡
  • Language ¡
  • species ¡
slide-5
SLIDE 5

Unsupervised ¡learning ¡

  • ¡Clustering ¡methods ¡

– Non-­‑probabilisNc ¡method ¡

  • Hierarchical ¡clustering ¡
  • K ¡means ¡algorithm ¡

– ProbabilisNc ¡method ¡

  • Mixture ¡model ¡
  • ¡We ¡will ¡also ¡discuss ¡dimensionality ¡reducNon, ¡another ¡

unsupervised ¡learning ¡method ¡later ¡in ¡the ¡course ¡

slide-6
SLIDE 6

The ¡quality ¡or ¡state ¡of ¡being ¡similar; ¡likeness; ¡resemblance; ¡as, ¡a ¡similarity ¡of ¡features. ¡

Similarity ¡is ¡hard ¡ to ¡define, ¡but… ¡ ¡ “We ¡know ¡it ¡ when ¡we ¡see ¡it” ¡ The ¡real ¡meaning ¡

  • f ¡similarity ¡is ¡a ¡

philosophical ¡

  • quesNon. ¡We ¡will ¡

take ¡a ¡more ¡ pragmaNc ¡

  • approach. ¡ ¡ ¡

Webster's ¡DicEonary ¡

slide-7
SLIDE 7

DefiniEon: ¡Let ¡O1 ¡and ¡O2 ¡be ¡two ¡objects ¡from ¡the ¡universe ¡

  • f ¡possible ¡objects. ¡The ¡distance ¡(dissimilarity) ¡between ¡

O1 ¡and ¡O2 ¡is ¡a ¡real ¡number ¡denoted ¡by ¡D(O1,O2) ¡

0.23 ¡ 3 ¡ 342.7 ¡

gene2 gene1

slide-8
SLIDE 8

What ¡properEes ¡should ¡a ¡distance ¡measure ¡ have? ¡

  • D(A,B) ¡= ¡D(B,A) ¡ ¡ ¡

¡ Symmetry ¡

  • D(A,A) ¡= ¡0 ¡ ¡ ¡

¡ ¡ Constancy ¡of ¡Self-­‑Similarity ¡

  • D(A,B) ¡= ¡0 ¡IIf ¡A= ¡B ¡ ¡ ¡

¡ Posi:vity ¡Separa:on ¡

  • D(A,B) ¡≤ ¡D(A,C) ¡+ ¡D(B,C) ¡ ¡ ¡

Triangular ¡Inequality ¡

slide-9
SLIDE 9
  • D(A,B) ¡= ¡D(B,A) ¡ ¡ ¡

¡ Symmetry ¡

– Otherwise ¡you ¡could ¡claim ¡"Alex ¡looks ¡like ¡Bob, ¡but ¡Bob ¡looks ¡nothing ¡like ¡ Alex" ¡

  • D(A,A) ¡= ¡0 ¡ ¡ ¡

¡ ¡ Constancy ¡of ¡Self-­‑Similarity ¡

– Otherwise ¡you ¡could ¡claim ¡"Alex ¡looks ¡more ¡like ¡Bob, ¡than ¡Bob ¡does" ¡

  • D(A,B) ¡= ¡0 ¡IIf ¡A= ¡B ¡ ¡

¡ ¡ Posi:vity ¡Separa:on ¡

– Otherwise ¡there ¡are ¡objects ¡in ¡your ¡world ¡that ¡are ¡different, ¡but ¡you ¡ cannot ¡tell ¡apart. ¡

  • D(A,B) ¡≤ ¡D(A,C) ¡+ ¡D(B,C) ¡ ¡ ¡

Triangular ¡Inequality ¡

– Otherwise ¡you ¡could ¡claim ¡"Alex ¡is ¡very ¡like ¡Bob, ¡and ¡Alex ¡is ¡very ¡like ¡Carl, ¡ but ¡Bob ¡is ¡very ¡unlike ¡Carl" ¡

IntuiEons ¡behind ¡desirable ¡distance ¡measure ¡ properEes ¡

slide-10
SLIDE 10

Distance ¡Measures ¡

  • Suppose ¡two ¡object ¡x ¡and ¡y ¡both ¡have ¡p ¡features ¡
  • Euclidean ¡distance ¡
  • CorrelaNon ¡coefficient ¡

d(x,y) = | xi − yi

i=1 p

|2

2

slide-11
SLIDE 11

Similarity ¡Measures: ¡CorrelaEon ¡Coefficient ¡

Time Gene A Gene A Time Gene B Expression Level Expression Level Expression Level Time Gene A Gene B Gene B

slide-12
SLIDE 12
  • Hierarchical ¡algorithms: ¡Create ¡a ¡hierarchical ¡decomposiNon ¡
  • f ¡the ¡set ¡of ¡objects ¡using ¡some ¡criterion ¡
  • ParEEonal ¡algorithms: ¡Construct ¡various ¡parNNons ¡and ¡then ¡

evaluate ¡them ¡by ¡some ¡criterion ¡

Top ¡down ¡ Bojom ¡up ¡or ¡top ¡down ¡

slide-13
SLIDE 13

(How-­‑to) ¡Hierarchical ¡Clustering ¡

BoOom-­‑Up ¡(agglomeraEve): ¡StarNng ¡ with ¡each ¡item ¡in ¡its ¡own ¡cluster, ¡find ¡ the ¡best ¡pair ¡to ¡merge ¡into ¡a ¡new ¡

  • cluster. ¡Repeat ¡unNl ¡all ¡clusters ¡are ¡

fused ¡together. ¡ ¡

slide-14
SLIDE 14

0 ¡ 8 ¡ 8 ¡ 7 ¡ 7 ¡ 0 ¡ 2 ¡ 4 ¡ 4 ¡ 0 ¡ 3 ¡ 3 ¡ 0 ¡ 1 ¡ 0 ¡

D( ¡ ¡, ¡ ¡) ¡= ¡8 ¡ D( ¡ ¡, ¡ ¡) ¡= ¡1 ¡

We ¡begin ¡with ¡a ¡distance ¡matrix ¡which ¡ contains ¡the ¡distances ¡between ¡every ¡ pair ¡of ¡objects ¡in ¡our ¡database. ¡

slide-15
SLIDE 15

… ¡ Consider ¡all ¡ possible ¡ merges… ¡ Choose ¡ the ¡best ¡

slide-16
SLIDE 16

… ¡ Consider ¡all ¡ possible ¡ merges… ¡ Choose ¡ the ¡best ¡ Consider ¡all ¡ possible ¡ merges… ¡ … ¡ Choose ¡ the ¡best ¡

slide-17
SLIDE 17

… ¡ Consider ¡all ¡ possible ¡ merges… ¡ Choose ¡ the ¡best ¡ Consider ¡all ¡ possible ¡ merges… ¡ … ¡ Choose ¡ the ¡best ¡ Consider ¡all ¡ possible ¡ merges… ¡ Choose ¡ the ¡best ¡ … ¡

slide-18
SLIDE 18

… ¡ Consider ¡all ¡ possible ¡ merges… ¡ Choose ¡ the ¡best ¡ Consider ¡all ¡ possible ¡ merges… ¡ … ¡ Choose ¡ the ¡best ¡ Consider ¡all ¡ possible ¡ merges… ¡ Choose ¡ the ¡best ¡ … ¡

But ¡how ¡do ¡we ¡compute ¡distances ¡ between ¡clusters ¡rather ¡than ¡

  • bjects? ¡
slide-19
SLIDE 19

CompuEng ¡distance ¡between ¡clusters: ¡Single ¡ Link ¡

  • cluster ¡distance ¡= ¡distance ¡of ¡two ¡closest ¡members ¡in ¡each ¡

class ¡

  • Potentially long and

skinny clusters

slide-20
SLIDE 20

CompuEng ¡distance ¡between ¡clusters: ¡ ¡ Complete ¡Link ¡

  • cluster ¡distance ¡= ¡distance ¡of ¡two ¡farthest ¡members ¡

+ tight clusters

slide-21
SLIDE 21

CompuEng ¡distance ¡between ¡clusters: ¡Average ¡ Link ¡

  • cluster ¡distance ¡= ¡average ¡distance ¡of ¡all ¡pairs ¡

the most widely used measure Robust against noise

slide-22
SLIDE 22

Example: ¡single ¡link ¡

1 ¡ 2 ¡ 3 ¡ 4 ¡ 5 ¡

slide-23
SLIDE 23

Example: ¡single ¡link ¡

1 ¡ 2 ¡ 3 ¡ 4 ¡ 5 ¡

slide-24
SLIDE 24

Example: ¡single ¡link ¡

1 ¡ 2 ¡ 3 ¡ 4 ¡ 5 ¡

slide-25
SLIDE 25

Example: ¡single ¡link ¡

1 ¡ 2 ¡ 3 ¡ 4 ¡ 5 ¡

slide-26
SLIDE 26

Average ¡linkage ¡ Single ¡linkage ¡ Height ¡represents ¡distance ¡ between ¡objects ¡/ ¡clusters ¡

slide-27
SLIDE 27

Summary ¡of ¡Hierarchal ¡Clustering ¡Methods ¡

  • No ¡need ¡to ¡specify ¡the ¡number ¡of ¡clusters ¡in ¡advance. ¡ ¡
  • ¡Hierarchical ¡structure ¡maps ¡nicely ¡onto ¡human ¡intuiNon ¡for ¡

some ¡domains ¡

  • ¡They ¡do ¡not ¡scale ¡well: ¡Nme ¡complexity ¡of ¡at ¡least ¡O(n2), ¡

where ¡n ¡is ¡the ¡number ¡of ¡total ¡objects. ¡

  • ¡Like ¡any ¡heurisNc ¡search ¡algorithms, ¡local ¡opNma ¡are ¡a ¡
  • problem. ¡
  • ¡InterpretaNon ¡of ¡results ¡is ¡(very) ¡subjecNve. ¡ ¡
slide-28
SLIDE 28

In ¡some ¡cases ¡we ¡can ¡determine ¡the ¡“correct” ¡number ¡of ¡clusters. ¡However, ¡things ¡are ¡rarely ¡ this ¡clear ¡cut, ¡unfortunately. ¡

But ¡what ¡are ¡the ¡clusters? ¡

slide-29
SLIDE 29

Outlier ¡ The ¡single ¡isolated ¡branch ¡is ¡suggesNve ¡of ¡a ¡data ¡point ¡that ¡is ¡ very ¡different ¡to ¡all ¡others ¡

slide-30
SLIDE 30

Example: ¡clustering ¡genes ¡

  • Microarrays ¡measure ¡the ¡acNviNes ¡of ¡

all ¡genes ¡in ¡different ¡condiNons ¡

  • Group ¡genes ¡that ¡perform ¡the ¡same ¡

funcNon ¡

  • Clustering ¡genes ¡can ¡help ¡determine ¡

new ¡funcNons ¡for ¡unknown ¡genes ¡

  • An ¡early ¡“killer ¡applicaNon” ¡in ¡this ¡area ¡

– The ¡most ¡cited ¡(>12,000) ¡paper ¡in ¡PNAS! ¡

slide-31
SLIDE 31

ParEEoning ¡Algorithms ¡

  • ParNNoning ¡method: ¡Construct ¡a ¡parNNon ¡of ¡n ¡objects ¡into ¡a ¡

set ¡of ¡K ¡clusters ¡

– Given: ¡a ¡set ¡of ¡objects ¡and ¡the ¡number ¡K ¡ – Find: ¡a ¡parNNon ¡of ¡K ¡clusters ¡that ¡opNmizes ¡the ¡chosen ¡parNNoning ¡ criterion ¡

  • Globally ¡opNmal: ¡exhausNvely ¡enumerate ¡all ¡parNNons ¡
  • EffecNve ¡heurisNc ¡methods: ¡K-­‑means ¡algorithms ¡
slide-32
SLIDE 32
  • Nonhierarchical, ¡each ¡instance ¡is ¡placed ¡in ¡exactly ¡one ¡of ¡K ¡

non-­‑overlapping ¡clusters. ¡

  • Since ¡the ¡output ¡is ¡only ¡one ¡set ¡of ¡clusters, ¡the ¡user ¡has ¡to ¡

specify ¡the ¡desired ¡number ¡of ¡clusters ¡K. ¡

slide-33
SLIDE 33

k1 ¡ k2 ¡ k3 ¡ Re-­‑assign ¡and ¡move ¡centers, ¡unNl ¡ no ¡objects ¡change ¡their ¡cluster ¡membership ¡

slide-34
SLIDE 34

K-­‑Means ¡Clustering ¡Algorithm ¡

Find ¡the ¡cluster ¡ means ¡ Re-­‑assign ¡ samples ¡to ¡ clusters ¡

Iterate ¡unNl ¡ convergence ¡

slide-35
SLIDE 35

K-­‑means ¡Clustering: ¡Step ¡1 ¡

slide-36
SLIDE 36

K-­‑means ¡Clustering: ¡Step ¡2 ¡

slide-37
SLIDE 37

K-­‑means ¡Clustering: ¡Step ¡3 ¡

slide-38
SLIDE 38

K-­‑means ¡Clustering: ¡Step ¡4 ¡

slide-39
SLIDE 39

K-­‑means ¡Clustering: ¡Step ¡5 ¡

slide-40
SLIDE 40

K-­‑Means ¡

Algorithm ¡

  • 1. Decide ¡on ¡a ¡value ¡for ¡K. ¡
  • 2. IniNalize ¡the ¡K ¡cluster ¡centers ¡randomly ¡if ¡necessary. ¡
  • 3. Decide ¡the ¡class ¡memberships ¡of ¡the ¡N ¡objects ¡by ¡assigning ¡them ¡to ¡the ¡

nearest ¡cluster ¡centroids ¡(aka ¡the ¡center ¡of ¡gravity ¡or ¡mean) ¡

  • 4. Re-­‑esNmate ¡the ¡K ¡cluster ¡centers, ¡by ¡assuming ¡the ¡memberships ¡found ¡

above ¡are ¡correct. ¡

  • 5. If ¡none ¡of ¡the ¡N ¡objects ¡changed ¡membership ¡in ¡the ¡last ¡iteraNon, ¡exit. ¡

Otherwise ¡go ¡to ¡3. ¡

slide-41
SLIDE 41

10 ¡ 1 ¡ 2 ¡ 3 ¡ 4 ¡ 5 ¡ 6 ¡ 7 ¡ 8 ¡ 9 ¡ 10 ¡ 1 ¡ 2 ¡ 3 ¡ 4 ¡ 5 ¡ 6 ¡ 7 ¡ 8 ¡ 9 ¡

slide-42
SLIDE 42

1 ¡ 2 ¡ 3 ¡ 4 ¡ 5 ¡ 6 ¡ 7 ¡ 8 ¡ 9 ¡ 10 ¡

When ¡k ¡= ¡1, ¡the ¡objecNve ¡funcNon ¡is ¡873.0 ¡

Obj =

k

||

i

∑ xi − µk ||2

2

slide-43
SLIDE 43

1 ¡ 2 ¡ 3 ¡ 4 ¡ 5 ¡ 6 ¡ 7 ¡ 8 ¡ 9 ¡ 10 ¡

When ¡k ¡= ¡2, ¡the ¡objecNve ¡funcNon ¡is ¡173.1 ¡

Obj =

k

||

i

∑ xi − µk ||2

2

slide-44
SLIDE 44

1 ¡ 2 ¡ 3 ¡ 4 ¡ 5 ¡ 6 ¡ 7 ¡ 8 ¡ 9 ¡ 10 ¡

When ¡k ¡= ¡3, ¡the ¡objecNve ¡funcNon ¡is ¡133.6 ¡

Obj =

k

||

i

∑ xi − µk ||2

2

slide-45
SLIDE 45

0.00E+00 ¡ 1.00E+02 ¡ 2.00E+02 ¡ 3.00E+02 ¡ 4.00E+02 ¡ 5.00E+02 ¡ 6.00E+02 ¡ 7.00E+02 ¡ 8.00E+02 ¡ 9.00E+02 ¡ 1.00E+03 ¡ 1 ¡ 2 ¡ 3 ¡ 4 ¡ 5 ¡ 6 ¡

We ¡can ¡plot ¡the ¡objecNve ¡funcNon ¡values ¡for ¡k ¡equals ¡1 ¡to ¡6… ¡ The ¡abrupt ¡change ¡at ¡k ¡= ¡2, ¡is ¡highly ¡suggesNve ¡of ¡two ¡clusters ¡in ¡the ¡data. ¡This ¡ technique ¡for ¡determining ¡the ¡number ¡of ¡clusters ¡is ¡known ¡as ¡“knee ¡finding” ¡or ¡ “elbow ¡finding”. ¡ Note ¡that ¡the ¡results ¡are ¡not ¡always ¡as ¡clear ¡cut ¡as ¡in ¡this ¡toy ¡example ¡ k ¡ ObjecNve ¡FuncNon ¡

slide-46
SLIDE 46

What ¡you ¡should ¡know ¡

  • Clustering ¡as ¡an ¡unsupervised ¡learning ¡method ¡
  • What ¡are ¡the ¡different ¡types ¡of ¡clustering ¡algorithms ¡
  • What ¡are ¡the ¡assumpNons ¡we ¡are ¡making ¡for ¡each, ¡and ¡what ¡

can ¡we ¡get ¡from ¡them ¡

  • Unsolved ¡issues: ¡number ¡of ¡clusters, ¡iniNalizaNon, ¡etc. ¡