clustering and distance metrics · machine learning 1010--701/15701/15--781, fall 781, fall...

51
Machine Learning Machine Learning 10 10-701/15 701/15-781, Fall 781, Fall 2012 2012 Clustering and Distance Metrics Clustering and Distance Metrics Eric Xing Eric Xing Lecture 10, October 15, 2012 Reading: Chap. 9, C.B book 1 © Eric Xing @ CMU, 2006-2012

Upload: others

Post on 31-Aug-2020

10 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

Machine LearningMachine Learning

1010--701/15701/15--781, Fall 781, Fall 20122012

Clustering and Distance MetricsClustering and Distance Metrics

Eric XingEric Xing

Lecture 10, October 15, 2012

Reading: Chap. 9, C.B book1© Eric Xing @ CMU, 2006-2012

Page 2: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

What is clustering?What is clustering?

Are there any “grouping” among them ?What is each group ?How many ?How many ?How to identify them?

2© Eric Xing @ CMU, 2006-2012

Page 3: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

What is clustering?What is clustering?Clustering: the process of grouping a set of objects into g p g p g jclasses of similar objects

high intra-class similaritylow inter-class similarityyIt is the commonest form of unsupervised learning

Unsupervised learning = learning from raw (unlabeled, unannotated, etc) data, as opposed to supervised data where a classification of examples is given

A common and important task that finds many applications in Science, Engineering, information Science, and other places

Group genes that perform the same functionGroup individuals that has similar political viewCategorize documents of similar topics Ideality similar objects from pictures

3© Eric Xing @ CMU, 2006-2012

Page 4: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

ExamplesExamplesPeoplep

Images

Language

species

4© Eric Xing @ CMU, 2006-2012

Page 5: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

Issues for clusteringIssues for clusteringWhat is a natural grouping among these objects?g p g g j

Definition of "groupness"

What makes objects “related”?Definition of "similarity/distance"Definition of similarity/distance

Representation for objectsVector space? Normalization?

How many clusters?Fixed a priori?Completely data driven?

Avoid “trivial” clusters - too large or small

Clustering AlgorithmsPartitional algorithmsgHierarchical algorithms

Formal foundation and convergence5© Eric Xing @ CMU, 2006-2012

Page 6: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

What is a natural grouping among these objects?among these objects?

6© Eric Xing @ CMU, 2006-2012

Page 7: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

What is Similarity?What is Similarity?

Hard to define! Hard to define! ButBut we know it we know it when we see itwhen we see itwhen we see itwhen we see it

The real meaning of similarity is a philosophical question. We will take a more pragmatic approachDepends on representation and algorithm. For many rep./alg., easier to think in terms of a distance (rather than similarity) between vectors.

7© Eric Xing @ CMU, 2006-2012

Page 8: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

What properties should a distance measure have?distance measure have?

D(A,B) = D(B,A) Symmetry( ) ( ) y y

D(A A) 0 C t f S lf Si il itD(A,A) = 0 Constancy of Self-Similarity

D(A,B) = 0 IIf A= B Positivity Separation

D(A,B) ≤ D(A,C) + D(B,C) Triangular Inequality

8© Eric Xing @ CMU, 2006-2012

Page 9: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

Intuitions behind desirable distance measure properties

D(A,B) = D(B,A) Symmetry

distance measure properties( ) ( ) y y

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

D(A A) 0 C t f S lf Si il itD(A,A) = 0 Constancy of Self-SimilarityOtherwise you could claim "Alex looks more like Bob, than Bob does"

D(A,B) = 0 IIf A= B Positivity SeparationOtherwise there are objects in your world that are different, but you cannot tell apart.p

D(A,B) ≤ D(A,C) + D(B,C) Triangular InequalityOtherwise you could claim "Alex is very like Bob, and Alex is very like Carl, but Bob is very unlike Carl"

9© Eric Xing @ CMU, 2006-2012

Page 10: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

Distance Measures: Minkowski MetricMetric

Suppose two object x and y both have p featurespp j y p

),,,(

),,,(

p

p

yyyy

xxxx

L

L

21

21

=

=

The Minkowski metric is defined by

rp

ii

r

yxyxd ||),( ∑ −=

Most Common Minkowski Metricsi

yy ||),( ∑=1

||),( distance) (Manhattan1 2,

||),( ) distance (Euclidean2 1, 2 2

1

p

ii

p

iii

yxyxd r

yxyxd r

−==

−===

||max),( ) distance sup"(" 3,1

1

iipi

i

yxyxd r −=+∞=≤≤

=

10© Eric Xing @ CMU, 2006-2012

Page 11: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

An ExampleAn Example

3

x

4

3 y

:distanceEuclidean:1 5342 22 =+

.},{max:distancesup"":3. :distanceManhattan :2

. :distanceEuclidean :1

434734

534

==+

=+

.},{max :distancesup :3 434

11© Eric Xing @ CMU, 2006-2012

Page 12: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

Hamming distanceManhattan distance is called Hamming distance when all features

Hamming distance

are binary.

Gene Expression Levels Under 17 Conditions (1-High,0-Low)

1716151413121110987654321

1101111110000111010011100100100110

GeneBGeneA

:DistanceHamming 5141001 =+=+ )#()#( . :DistanceHamming 5141001 =+=+ )#()#(

12© Eric Xing @ CMU, 2006-2012

Page 13: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

Similarity Measures: Correlation CoefficientCoefficient

Gene AGene B

Expression Level

Expression Level

Time

Gene B Gene A

Time

Expression Level

Gene A

Gene B

Time

13© Eric Xing @ CMU, 2006-2012

Page 14: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

Similarity Measures: Correlation CoefficientCoefficient

Pearson correlation coefficient

))((),(

∑=

−−=

p p

p

iii yyxx

yxs 1

)()(

∑∑

∑ ∑= =

−×−

pp

p

i

p

iii yyxx

11

1 1

22

. and where ∑∑==

==i

ipi

ip yyxx1

1

1

1

1≤),( yxs

Special case: cosine distanceyx rr⋅)(

yxyyxs rr⋅

=),(

14© Eric Xing @ CMU, 2006-2012

Page 15: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

Edit Distance: A i t h i f i i il itA generic technique for measuring similarity

To measure the similarity between two objects, transform one y jof the objects into the other, and measure how much effort it took. The measure of effort becomes the distance measure.

The distance between Patty and Selma.Change dress color, 1 pointChange earring shape, 1 pointChange hair part, 1 pointChange hair part, 1 point

D(Patty,Selma) = 3

The distance between Marge and Selma.Change dress color, 1 pointAdd earrings, 1 pointDecrease height, 1 pointTake up smoking, 1 pointL i ht 1 i t

This is called the Lose weight, 1 point

DPMarge,Selma) = 5Edit distance or theTransformation distance

15© Eric Xing @ CMU, 2006-2012

Page 16: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

Learning Distance MetricLearning Distance Metric

More later …

© Eric Xing @ CMU, 2006-2012 16

Page 17: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

Clustering AlgorithmsClustering AlgorithmsPartitional algorithmsg

Usually start with a random (partial) partitioningRefine it iteratively

K means clusteringMixture-Model based clustering

Hierarchical algorithmsgBottom-up, agglomerativeTop-down, divisive

17© Eric Xing @ CMU, 2006-2012

Page 18: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

Hierarchical ClusteringHierarchical ClusteringBuild a tree-based hierarchical taxonomy (dendrogram) from y ( g )a set of documents.

Note that hierarchies are commonly used to organize information, for example in a web portal.

Yahoo! is hierarchy is manually created we will focus on automatic creation ofYahoo! is hierarchy is manually created, we will focus on automatic creation of hierarchies in data mining.

18© Eric Xing @ CMU, 2006-2012

Page 19: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

DendogramDendogramA Useful Tool for Summarizing Similarity Measurementg y

The similarity between two objects in a dendrogram is represented as the height of the lowest internal node they share.

Clustering obtained by cutting the dendrogram at a desired level: each connected component forms a cluster.

19© Eric Xing @ CMU, 2006-2012

Page 20: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

Hierarchical ClusteringHierarchical ClusteringBottom-Up Agglomerative Clusteringp gg g

Starts with each obj in a separate cluster then repeatedly joins the closest pair of clusters, until there is only one cluster.

The history of merging forms a binary tree or hierarchy.

Top-Down divisive Starting with all the data in a single cluster, Consider every possible way to divide the cluster into two. Choose the bestConsider every possible way to divide the cluster into two. Choose the best division And recursively operate on both sides.

20© Eric Xing @ CMU, 2006-2012

Page 21: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

Closest pair of clustersClosest pair of clustersThe distance between two clusters is defined as the distance between

Si l Li kSingle-Link Nearest Neighbor: their closest members.

Complete-Link pFurthest Neighbor: their furthest members.

Centroid: Clusters whose centroids (centers of gravity) are the most cosine similarClusters whose centroids (centers of gravity) are the most cosine-similar

Average: average of all cross-cluster pairs.

21© Eric Xing @ CMU, 2006-2012

Page 22: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

Single Link Method

Euclidean Distance

Single-Link Method

ba

a,b,ca,b

a,b,c,d

(1) (2) (3)

, ,cc dd d

, , ,

53652

ba

dcb

453,

cba

dc

53652

ba

dcb4,, cbad

4c

Distance M t i

4c

Matrix

22© Eric Xing @ CMU, 2006-2012

Page 23: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

Complete Link Method

Euclidean Distance

Complete-Link Method

ba a,ba,b

a,b,c,d

(1) (2) (3)cc dd c,d

, , ,

53652

ba

dcb

465,

cba

dc

53652

ba

dcb6,,

badc

4c

Distance M t i

4c

Matrix

23© Eric Xing @ CMU, 2006-2012

Page 24: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

Dendrograms

Single-Link Complete-Link

Dendrograms

a b c d a b c d0

g p

22

4

624© Eric Xing @ CMU, 2006-2012

Page 25: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

Computational ComplexityComputational ComplexityIn the first iteration, all HAC methods need to compute psimilarity of all pairs of n individual instances which is O(n2).

I h f th b t 2 i it ti tIn each of the subsequent n−2 merging iterations, compute the distance between the most recently created cluster and all other existing clusters.

In order to maintain an overall O(n2) performance, computing similarity to each other cluster must be done in constant timesimilarity to each other cluster must be done in constant time.

Else O(n2 log n) or O(n3) if done naivelyse O( og ) o O( ) do e a e y

25© Eric Xing @ CMU, 2006-2012

Page 26: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

Partitioning AlgorithmsPartitioning AlgorithmsPartitioning method: Construct a partition of n objects into a g p jset of K clusters

Gi t f bj t d th b KGiven: a set of objects and the number K

Find: a partition of K clusters that optimizes the chosenFind: a partition of K clusters that optimizes the chosen partitioning criterion

Globally optimal: exhaustively enumerate all partitionsEffective heuristic methods: K means and K medoids algorithmsEffective heuristic methods: K-means and K-medoids algorithms

26© Eric Xing @ CMU, 2006-2012

Page 27: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

K MeansK-MeansAlgorithmg

1. Decide on a value for k.2. Initialize 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-estimate the k cluster centers, by assuming the memberships found above are correct.

5. If none of the N objects changed membership in the last iteration, j g p ,exit. Otherwise go to 3.

27© Eric Xing @ CMU, 2006-2012

Page 28: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

K means Clustering: Step 1K-means Clustering: Step 1

28© Eric Xing @ CMU, 2006-2012

Page 29: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

K means Clustering: Step 2K-means Clustering: Step 2

29© Eric Xing @ CMU, 2006-2012

Page 30: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

K means Clustering: Step 3K-means Clustering: Step 3

30© Eric Xing @ CMU, 2006-2012

Page 31: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

K means Clustering: Step 4K-means Clustering: Step 4

31© Eric Xing @ CMU, 2006-2012

Page 32: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

K means Clustering: Step 5K-means Clustering: Step 5

32© Eric Xing @ CMU, 2006-2012

Page 33: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

ConvergenceConvergenceWhy should the K-means algorithm ever reach a fixed point? y g p

-- A state in which clusters don’t change.

K-means is a special case of a general procedure known as the Expectation Maximization (EM) algorithm.

EM is known to converge.Number of iterations could be large.

Goodness measure sum of squared distances from cluster centroid:

Reassignment monotonically decreases SD since each vector is assigned to the closest centroid.

33© Eric Xing @ CMU, 2006-2012

Page 34: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

Time ComplexityTime ComplexityComputing distance between two objs is O(m) where m is the p g j ( )dimensionality of the vectors.

R i i l t O(K ) di t t tiReassigning clusters: O(Kn) distance computations, or O(Knm).

Computing centroids: Each doc gets added once to some centroid: O(nm).

Assume these two steps are each done once for l iterations: O(lKnm).O(l nm)

34© Eric Xing @ CMU, 2006-2012

Page 35: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

Seed ChoiceSeed ChoiceResults can vary based on random seed selection.y

Some seeds can result in poor convergence rate orSome seeds can result in poor convergence rate, or convergence to sub-optimal clusterings.

Select good seeds using a heuristic (e.g., doc least similar to any existing mean)Try out multiple starting points (very important!!!)Try out multiple starting points (very important!!!)Initialize with the results of another method.

35© Eric Xing @ CMU, 2006-2012

Page 36: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

How Many Clusters?How Many Clusters?Number of clusters K is given g

Partition n docs into predetermined number of clusters

Finding the “right” number of clusters is part of the problemGiven objs partition into an “appropriate” number of subsetsGiven objs, partition into an appropriate number of subsets.E.g., for query results - ideal value of K not known up front - though UI may impose limits.

Solve an optimization problem: penalize having lots ofSolve an optimization problem: penalize having lots of clusters

application dependent, e.g., compressed summary of search results list.Information theoretic approaches: model based approachInformation theoretic approaches: model-based approach

Tradeoff between having more clusters (better focus within each cluster) and having too many clustersNonparametric Bayesian Inference (later in this class)

36© Eric Xing @ CMU, 2006-2012

Page 37: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

What Is A Good Clustering?What Is A Good Clustering?Internal criterion: A good clustering will produce high quality g g p g q yclusters in which:

the intra-class (that is, intra-cluster) similarity is highthe inter-class similarity is lowyThe measured quality of a clustering depends on both the obj representation and the similarity measure used

External criteria for clustering qualityQuality measured by its ability to discover some or all of the hidden patterns or latent classes in gold standard datalatent classes in gold standard dataAssesses a clustering with respect to ground truthExample:

Purityentropy of classes in clusters (or mutual information between classes and clusters)

37© Eric Xing @ CMU, 2006-2012

Page 38: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

External Evaluation of Cluster QualityQuality

Simple measure: purity, the ratio between the dominant class p p yin the cluster and the size of cluster

Assume documents with C gold standard classes, while our clustering algorithms produce K clusters, ω1, ω2, …, ωK with ni members.

ExampleExample

Cluster I: Purity = 1/6 (max(5, 1, 0)) = 5/6Cluster II: Purity = 1/6 (max(1 4 1)) = 4/6Cluster II: Purity = 1/6 (max(1, 4, 1)) = 4/6Cluster III: Purity = 1/5 (max(2, 0, 3)) = 3/5

38© Eric Xing @ CMU, 2006-2012

Page 39: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

Other measuresOther measures

© Eric Xing @ CMU, 2006-2012 39

Page 40: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

Other partitioning MethodsOther partitioning MethodsPartitioning around medioids (PAM): instead of averages, use g ( ) gmultidim medians as centroids (cluster “prototypes”). Dudoit and Freedland (2002).Self organizing maps (SOM): add an underlying “topology”Self-organizing maps (SOM): add an underlying topology (neighboring structure on a lattice) that relates cluster centroids to one another. Kohonen (1997), Tamayo et al. (1999)(1999).Fuzzy k-means: allow for a “gradation” of points between clusters; soft partitions. Gash and Eisen (2002).Mixture-based clustering: implemented through an EM (Expectation-Maximization)algorithm. This provides soft partitioning and allows for modeling of cluster centroids andpartitioning, and allows for modeling of cluster centroids and shapes. Yeung et al. (2001), McLachlan et al. (2002)

40© Eric Xing @ CMU, 2006-2012

Page 41: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

Semi-supervised Metric Learning

⇒⇒

Xing et al, NIPS 2003

41© Eric Xing @ CMU, 2006-2012

Page 42: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

What is a good metric?What is a good metric?What is a good metric over the input space for learning and g p p gdata-mining

How to convey metrics sensible to a human user (e.g., dividing traffic along highway lanes rather than between overpasses, categorizing documentshighway lanes rather than between overpasses, categorizing documents according to writing style rather than topic) to a computer data-miner using a systematic mechanism?

42© Eric Xing @ CMU, 2006-2012

Page 43: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

Issues in learning a metricIssues in learning a metricData distribution is self-informing (E.g., lies in a sub-manifold)g ( g )

Learning metric by finding an embedding of data in some space. Con: does not reflect (changing) human subjectiveness.

Explicitly labeled dataset offers clue for critical featuresExplicitly labeled dataset offers clue for critical featuresSupervised learning

Con: needs sizable homogeneous training sets.

What about side information? (E.g., x and y look (or read) similar ...)

Providing small amount of qualitative and less structured side information is often much easier than stating explicitly a metric (what should be the metric for writing style?) or labeling a large set of training data.

Can we learn a distance metric more informative thanCan we learn a distance metric more informative than Euclidean distance using a small amount of side information?

43© Eric Xing @ CMU, 2006-2012

Page 44: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

Distance Metric LearningDistance Metric Learning

44© Eric Xing @ CMU, 2006-2012

Page 45: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

Optimal Distance MetricOptimal Distance MetricLearning an optimal distance metric with respect to the side-g p pinformation leads to the following optimization problem:

This optimization problem is convex. Local-minima-free algorithms exist.Xing et al 2003 provided an efficient gradient descent + iterative constraint-projection method

45© Eric Xing @ CMU, 2006-2012

Page 46: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

Examples of learned distance metricsmetrics

Distance metrics learned on three-cluster artificial data:

46© Eric Xing @ CMU, 2006-2012

Page 47: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

Application to ClusteringApplication to ClusteringArtificial Data I: a difficult two-class dataset

47© Eric Xing @ CMU, 2006-2012

Page 48: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

Application to ClusteringApplication to ClusteringArtificial Data II: two-class data with strong irrelevant featureg

48© Eric Xing @ CMU, 2006-2012

Page 49: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

Application to ClusteringApplication to Clustering9 datasets from the UC Irvine repositoryp y

49© Eric Xing @ CMU, 2006-2012

Page 50: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

Accuracy vs. amount of side-informationinformation

Two typical examples of how the quality of the clusters found yp p q yincreases with the amount of side-information.

50© Eric Xing @ CMU, 2006-2012

Page 51: Clustering and Distance Metrics · Machine Learning 1010--701/15701/15--781, Fall 781, Fall 20122012 Clustering and Distance Metrics Eric Xing Lecture 10, October 15, 2012 Reading:

Take home messageTake home messageDistance metric learning is an important problem in machine g p plearning and data mining.A good distance metric can be learned from small amount of side information in the form of similarity and dissimilarityside-information in the form of similarity and dissimilarity constraints from data by solving a convex optimization problem.The learned distance metric can identify the most significant direction(s) in feature space that separates data well, effectively doing implicit Feature Selection.The learned distance metric can be used to improve clustering performance.

51© Eric Xing @ CMU, 2006-2012