# Cluster Validity

last updated 23-Jun-2021

## Cluster Validity

For supervised classification we have a variety of measures to evaluate how good our model is

• Accuracy, precision, recall

For cluster analysis, the analogous question is how to evaluate the “goodness” of the resulting clusters?

But “clusters are in the eye of the beholder”!

Then why do we want to evaluate them?

• To avoid finding patterns in noise
• To compare clustering algorithms
• To compare two sets of clusters
• To compare two clusters

## Different Aspects of Cluster Validation

1. Determining the clustering tendency of a set of data, i.e., distinguishing whether non-random structure actually exists in the data.
2. Comparing the results of a cluster analysis to externally known results, e.g., to externally given class labels.
3. Evaluating how well the results of a cluster analysis fit the data without reference to external information. --Use only the data
4. Comparing the results of two different sets of cluster analyses to determine which is better.
5. Determining the ‘correct’ number of clusters.

For 2, 3, and 4, we can further distinguish whether we want to evaluate the entire clustering or just individual clusters.

## Measures of Cluster Validity

Numerical measures that are applied to judge various aspects of cluster validity, are classified into the following three types.

External Index: Used to measure the extent to which cluster labels match externally supplied class labels.
Entropy

Internal Index: Used to measure the goodness of a clustering structure without respect to external information.
Sum of Squared Error (SSE)

Relative Index: Used to compare two different clusterings or clusters.
Often an external or internal index is used for this function, e.g., SSE or entropy

Sometimes these are referred to as criteria instead of indices

• However, sometimes criterion is the general strategy and index is the numerical measure that implements the criterion.

## Recall: evaluating K-means clusters

Most common measure is Sum of Squared Error (SSE)

For each point, the error is the distance to the nearest cluster

To get SSE, we square these errors and sum them.

x is a data point in cluster Ci and mi is the representative point for cluster Ci

• can show that mi corresponds to the center (mean) of the cluster

Given two sets of clusters, we prefer the one with the smallest error

One easy way to reduce SSE is to increase K, the number of clusters

• A good clustering with smaller K can have a lower SSE than a poor clustering with higher K

## Measuring cluster validity via correlation

Two matrices

• Proximity Matrix
• Ideal Similarity Matrix
• One row and one column for each data point
• An entry is 1 if the associated pair of points belong to the same cluster
• An entry is 0 if the associated pair of points belongs to different clusters

Compute the correlation between the two matrices

• Since the matrices are symmetric, only the correlation between n(n-1) / 2 entries needs to be calculated.

High correlation indicates that points that belong to the same cluster are close to each other.

Not a good measure for some density or contiguity based clusters.

Correlation of ideal similarity and proximity matrices for the K-means clusterings of the following two data sets.

Order the similarity matrix with respect to cluster labels and inspect visually

Cluster with random data not so crisp.

## Internal Measures: SSE

Clusters in more complicated figures aren’t well separated.

Internal Index: Used to measure the goodness of a clustering structure without respect to external information -- SSE

SSE is good for comparing two clusterings or two clusters (average SSE).

SSE can also be used to estimate the number of clusters

Look for the knee bend to determine what might be the "best" number of clusters.

## Internal Measures: Cohesion and Separation

Cluster Cohesion: Measures how closely related are objects in a cluster

• Example: SSE

Cluster Separation: Measure how distinct or well-separated a cluster is from other clusters

• Example: Squared Error, overall

Cohesion is measured by the within-cluster sum of squares =

Separation is measured by the between-cluster sum of squares =

Where |Ci| is the size of cluster i and m is the mean of the means.

Note that BSS+ WSS = constant

A proximity graph based approach can also be used for cohesion and separation.

• Cluster cohesion is the sum of the weight of all links within a cluster.
• Cluster separation is the sum of the weights between nodes in the cluster and nodes outside the cluster.