Docsity

Text Clustering - Parte 1, Dispense di Sistemi Elettronici A Basso Consumo

Anteprima parziale del testo

Scarica Text Clustering - Parte 1 e più Dispense in PDF di Sistemi Elettronici A Basso Consumo solo su Docsity!

Text Clustering

Clustering

-^ Partition unlabeled examples into disjointsubsets of

clusters , such that:

-^ Examples within a cluster are very similar –^ Examples in different clusters are very different -^ Discover new categories in an

unsupervised

manner (no sample category labels provided).

Hierarchical Clustering

-^ Build a tree-based hierarchical taxonomy( dendrogram

) from a set of unlabeled examples.

animal vertebrate^

invertebrate fish reptile amphib. mammal • Recursive application of a standard clusteringalgorithm can produce a hierarchical clustering.

worm insect crustacean

Aglommerative vs. Divisive Clustering • Aglommerative

( bottom-up

) methods start

with each example in its own cluster anditeratively combine them to form larger andlarger clusters.

-^ Divisive

( partitional, top-down

) separate all

examples immediately into clusters.

Hierarchical Agglomerative Clustering

(HAC)

-^ Assumes a

similarity function

for determining

the similarity of two instances. • Starts with all instances in a separate cluster and then repeatedly joins the two clusters that and then repeatedly joins the two clusters that are most similar until there is only one cluster. • The history of merging forms a binary tree orhierarchy.

HAC Algorithm

Start with all instances in their own cluster.Until there is only one cluster:^ Among the current clusters, determine the two Among the current clusters, determine the two^ clusters,

c and^ c , that are most similar. i^ j Replace^ ci

and^ c with a single cluster j^

c ∪^ ci^ j

Single Link Agglomerative Clustering • Use maximum similarity of pairs: • Can result in “straggly” (long and thin)

),( max), (^

,

yxsim ccsim

cycxji = ji ∈∈

-^ Can result in “straggly” (long and thin)^ clusters due to

chaining effect

-^ Appropriate in some domains, such asclustering islands.

Single Link Example

Complete Link Example

Computational Complexity • In the first iteration, all HAC methods needto compute similarity of all pairs of

n

individual instances which is O(

(^2) n ).

-^ In each of the subsequent

n −2 merging iterations, it must compute the distance iterations, it must compute the distance between the most recently created clusterand all other existing clusters. • In order to maintain an overall O(

(^2) n )

performance, computing similarity to eachother cluster must be done in constant time.

Group Average Agglomerative Clustering^ •^ Use average similarity across all pairs within themerged cluster to measure the similarity of twoclusters.

∑^ ∑∪∈

≠∪∈ −∪ =^ ∪

)( :)(

),( ) 1 (^1) ( ),(

ccx xyccy^ ji ji jij ji i

yxsim ccc cc c sim^

r^

rr rrr^16

-^ Compromise between single and complete link. •^ Averaged across all ordered pairs in the mergedcluster instead of unordered pairs

between^ the two

clusters (to encourage tighter final clusters)

∪. ∈^

≠∪∈ −∪ ∪^

) 1 )(^ :)( (^

ccx xyccyji ji jij i^

ccc c

Computing Group Average Similarity • Assume cosine similarity and normalizedvectors with unit length. • Always maintain sum of vectors in each^ cluster.

rr = xcs )( ∑ cluster. • Compute similarity of clusters in constanttime:

rr = xcs )( ∑ j r∈ cx j

) (^1) ||| |)(|||(|

|)||(| ))()( ())( )(( ) ,(

−+

+− +•

  • =

ji ji

ji ji ji ji

cc cc

cc cscs cscs ccsim

rr rr

K-Means

-^ Assumes instances are real-valued vectors. •^ Clusters based on

centroids

,^ center of

gravity , or mean of points in a cluster,

c : rr 1 = x (c) ∑ μ

-^ Reassignment of instances to clusters isbased on distance to the current clustercentroids.

rr (^1) = x (c) ∑r c ||∈ cx μ

Distance Metrics

-^ Euclidian distance (L

norm): 2

-^ Lnorm:^1

(^21) 2

)( ),( m yxii^ i yxL

rr^ m −=^ ∑^

yx^ ii rr yxL ),( (^1)

-^ Cosine Similarity (transform to a distanceby subtracting from 1):

−= yxyxL ),( ∑^ ii 1 = i 1 rr yx • − 1 rr yx ⋅