DaTaBomB
DaTaBomB

Reputation: 633

How to plot overlapping clusters in python

I am trying to plot a visualization for clusters obtained from the Fuzzy C-means clustering algorithm. With crisp clusters like that obtained through k-means, it is easy to visualize through a normal scatter plot such as the one obtained through matplotlib. Is there a recommended way to plot fuzzy clusters to visualize the overlaps? If yes, how?

Upvotes: 1

Views: 1843

Answers (1)

seth
seth

Reputation: 1788

One option would be to divide your data into two groups: points that are part of a cluster with degree of belonging >= X, and those less than X. Call the points with degree of belonging >= X the crisp groups. For those less than X you would make groups for each of your different clusters, call these the fuzzy groups. Every fuzzy group would have all of the data points not in the crisp groups.

Now, when you go to plot, assign a color to each of your clusters, say you have three clusters A, B, and C. Assign them colors blue, green, and red. Plot the crisp groups at 100% opacity their group color, and then for each of the fuzzy groups look at the degree of belonging for the points and plot them at some scaled back opacity in their cluster's color.

Since you would have to assign a color to each fuzzy group as a whole it may be best to "bin" them like a histogram by degree of belonging, or you could skip the groups all together and just plot each point separately.

e.g. say we have 2 clusters A and B, and

data = [(0.2,0.8),(0.5,0.5),(0.65,0.35),(0.25,0.75)]

where data represents the degree of belonging (A,B) for each our points (whose coordinates I won't list, but assume they can be represented by ptn). Then if X is .7 we would do crisp_A = [pt1] and crisp_B = [pt4]. Then fuzzy_A = [pt2, pt3] and fuzzy_B = [pt2,pt2]. Plot crisp_A and crisp_B as full colors, and then use a cm.hsv or something akin to scale fuzzy_A and fuzzy_B by their respective degrees of belonging.

Upvotes: 2

Related Questions