# ~/Cluster Tendency

## Brandon Rozek

PhD Student @ RPI studying Automated Reasoning in AI and Linux Enthusiast.

This is the assessment of the suitability of clustering. Cluster Tendency determines whether the data has any inherent grouping structure.

This is a hard task since there are so many different definitions of clusters (portioning, hierarchical, density, graph, etc.) Even after fixing a cluster type, this is still hard in defining an appropriate null model for a data set.

One way we can go about measuring cluster tendency is to compare the data against random data. On average, random data should not contain clusters.

There are some clusterability assessment methods such as Spatial histogram, distance distribution and Hopkins statistic.

## Hopkins Statistic

Let $X$ be the set of $n$ data points in $d$ dimensional space. Consider a random sample (without replacement) of $m « n$ data points. Also generate a set $Y$ of $m$ uniformly randomly distributed data points.

Now define two distance measures $u_i$ to be the distance of $y_i \in Y$ from its nearest neighbor in X and $w_i$ to be the distance of $x_i \in X$ from its nearest neighbor in X

We can then define Hopkins statistic as $$H = \frac{\sum_{i = 1}^m{u_i^d}}{\sum_{i = 1}^m{u_i^d} + \sum_{i =1}^m{w_i^d}}$$

### Properties

With this definition, uniform random data should tend to have values near 0.5, and clustered data should tend to have values nearer to 1.

### Drawbacks

However, data containing a single Gaussian will also score close to one. As this statistic measures deviation from a uniform distribution. Making this statistic less useful in application as real data is usually not remotely uniform.

## Spatial Histogram Approach

For this method, I’m not too sure how this works, but here are some key points I found.

Divide each dimension in equal width bins, and count how many points lie in each of the bins and obtain the empirical joint probability mass function.

Do the same for the randomly sampled data

Finally compute how much they differ using the Kullback-Leibler (KL) divergence value. If it differs greatly than we can say that the data is clusterable.
{"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 1, "mathjax_display_tex": 1, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "url": "https://brandonrozek.com/research/clusteranalysis/notes/lec4-3/", "fetch_time": 1685800744000000000, "content_mime_type": "text/html", "warc_filename": "crawl-data/CC-MAIN-2023-23/segments/1685224649293.44/warc/CC-MAIN-20230603133129-20230603163129-00755.warc.gz", "warc_record_offset": 175479358, "warc_record_length": 4005, "token_count": 498, "char_count": 2173, "score": 3.640625, "int_score": 4, "crawl": "CC-MAIN-2023-23", "snapshot_type": "latest", "language": "en", "language_score": 0.9039411544799805, "file_path": "/sailhome/yjruan/project/latent-lm/data/processed/finemath-4plus/finemath-4plus/train-00005-of-00064.parquet"}