# Low Dimensional Topology

## July 5, 2012

### Finding clusters in data

Filed under: Data topology — Jesse Johnson @ 1:02 pm

I want to switch gears now, in my series on the topology of data sets, to the the problem of clustering. Recall that we are looking for ways to analyze large sets of data, where each point is a vector that we think of as having been sampled from some distribution. If this distribution is a union of a number of disjoint distributions then we would expect the geometry of the data points to reflect this by forming a number of distinguishable, tightly packed “clusters”. The goal of a clustering algorithm (called unsupervised learning in the machine learning parlance) is to partition the data set into some number of subsets based only on its geometric structure.

Here’s an approach that many people first think of: Choose a parameter $\epsilon$, connect any two points within distance $\epsilon$ by an edge, then define each connected component of the graph to be a cluster. This, of course, depends on the parameter $\epsilon$, so you really need to do something more along the lines of persistent homology to look at all different parameters and choose the best one. The data structure that encodes this process is called a dendrogram. But there are still some problems; for example, different clusters in the same data set often have different densities and thus are recognized by different values of $\epsilon$. Carlsson-Memoli have dealt with many of these problems by introducing a multiparameter version (PDF) of this algorithm. They’ve gotten some very impressive results with it, but that’s not what I’m going to focus on in this post.

Based on what I’ve read and heard, the most commonly used clustering algorithm appears to be K-means. This algorithm progressively improves a model for the data as a union of spherical Gaussian distributions. The progressive nature is reminiscent of a neural network, though there is no explicit gradient function. Here’s how it works:

We start out with a positive integer $K$ and a set of $K$ random, distinct points $p_1,\ldots,p_K$ in the space containing the data. For step 1, we assign each data point to the cluster $C_i$ corresponding to the point $p_i$ that it is closest to. For step 2, we replace each $p_i$ with the centroid (essentially the average) of the points assigned to the cluster $C_i$. Then we cycle through steps 1 and 2 until either the clusters become stable or we choose an arbitrary cutoff. So, roughly speaking, the algorithm makes clusters from the Vornoi cells defined by the points $p_1,\ldots,p_K$ and attempts to choose the points so that the Vornoi cells are as round as possible. The idea is that if the data comes from a union of spherical Gaussian distributions, the final points $p_1,\ldots,p_K$ will be the centers of these distributions.

K-means is easy to understand and relatively fast, but it also has a number of drawbacks. First, you have to choose the value $K$ in advance. In some cases, there will be an a priori reason to fix a certain $K$, but in cases where you don’t know how many clusters to expect, you essentially have to use trial and error. Second, the final result is highly dependent on the initial points $p_1,\ldots,p_K$. One can get around this problem by running the algorithm repeatedly from different starting points, or there are a number of heuristic algorithms for choosing initial values.

But the major problem with K-means, which was also a problem with the other data mining algorithms I’ve discussed, is that it only works if the data fits the model, i.e. if the natural clusters in the data are “convex” enough. If the data doesn’t, then K-means still gives you an answer, but it’s essentially meaningless. (Data miners like the expression “Garbage in, garbage out” and I suspect K-means is one of the main reasons.) This problem can be fixed in some cases by preprocessing such as applying a kernel. But it seems like what one really needs are more flexible methods, and this is where topology (even low-dimensional topology) comes in. In my next post, I will discuss how ideas from low-dimensional geometry/topology can be used to create better clustering algorithms.

1. The points you make about K-means are all valid. That is why people use information theoretic clustering these days. Look at Tishby and Still Geometric Clustering using Information Bottleneck. In fact there is a massive ongoing project to parallelize this version. You should look into it.

Comment by Dan Marthaler — July 5, 2012 @ 11:00 pm

• Thanks for the suggestion. I see that Tishby has written a lot of papers on this. I’ll look into it and, if see if it’s appropriate for a future post.

Comment by Jesse Johnson — July 6, 2012 @ 1:47 pm

2. Agreed, nice post and all points are valid. But please note that there are a number of K-Means variants that address each of these issues, with different degrees of success. Also, K-Means allows you to use different distance measures giving you different shapes for the clusters.

Comment by Renato Cordeiro de Amorim — July 30, 2012 @ 6:47 am

• Yes, that’s true. A lot of work has been done to address these issues with K-means, and I understand that there are some very effective versions of the algorithm. But if one starts with a more flexible basic algorithm (such as the one I describe in the next post) then I think there’s even more potential to refine it and add to it as has been done with K-means.

Comment by Jesse Johnson — July 30, 2012 @ 9:07 pm

3. […] additional interesting approach for Option 1 would be to apply topological clustering techniques to the contact network so that we can identify the hubs with the least desirable network […]

Blog at WordPress.com.
{"ft_lang_label":"__label__en","ft_lang_prob":0.9379435,"math_prob":0.9687465,"size":5612,"snap":"2021-43-2021-49","text_gpt3_token_len":1206,"char_repetition_ratio":0.11358773,"word_repetition_ratio":0.010256411,"special_character_ratio":0.21311475,"punctuation_ratio":0.09182736,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9857916,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42],"im_url_duplicate_count":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,3,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-10-23T23:31:36Z\",\"WARC-Record-ID\":\"<urn:uuid:1b6f7449-b63d-48c2-a643-ac2cafc05a17>\",\"Content-Length\":\"94134\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:2a4d822c-2a6e-4b35-9fc2-61c87cbf4a1c>\",\"WARC-Concurrent-To\":\"<urn:uuid:8bc887ec-ec81-4c22-8539-2d098cf6438a>\",\"WARC-IP-Address\":\"192.0.78.12\",\"WARC-Target-URI\":\"https://ldtopology.wordpress.com/2012/07/05/finding-clusters-in-data/\",\"WARC-Payload-Digest\":\"sha1:ILO4PFIATX53JHYPMLOLLSKZUPVRQISH\",\"WARC-Block-Digest\":\"sha1:XXKCMJ62UNWPAMROXUOTC27WOV3XPCJ5\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-43/CC-MAIN-2021-43_segments_1634323585828.15_warc_CC-MAIN-20211023224247-20211024014247-00149.warc.gz\"}"}