# Find all possible clusterizations

I need help to find all possible clusterizations via the k-means method in Python. Let's assume for simplicity that I have the following table:

height | weight | country of origin (X/Y/Z) | flag (1/0)

So a n_people x 4 size table.

I inserted the data artificially to specifically give the possibility to choose between two different clusterizations.

Now using k-means method "I find" that all people taller than 180 cm are from country X.

This is the piece of code to find the first clustering (all people taller than 180 cm are from country X):

df = pd.read_csv('survey.csv')
x = df.iloc[:, :].values
kmeans2 = KMeans(n_clusters=2)
y_kmeans2 = kmeans2.fit_predict(x)


But I also know that all people shorter than 170 cm have the flag variable equal to 0.

Is there a way to find this clustering by "ignoring" the previous one? Does redefining x by excluding the third column (country of origin) make sense? If the k-means method were not the best one, what could be an alternative?

Thanks to anyone who will answer.

• Can you please explain what your aim is? Do you use all four features for clustering, or only height and weight? As you apparently already have the cluster label (presumably either "country" or "flag"), it would be more natural to use a linear discriminant analysis (LDA) instead of ignoring the class labels. Note that weight and height are presumably highly correlated, but an LDA shoud figure this out on itself. – cdalitz Jan 12 at 14:50
• I use all four features for clustering. Beyond the example I have proposed, which may not be the best to explain my purpose, my question is: how do I, in general, identify all the possible clusterizations (that is, in how many "legitimate" ways I can group data)? Applying the k-means method, I only get one. – LJG Jan 12 at 15:01
• You cannot apply k-means to categorical data such as "country" – ttnphns Jan 13 at 18:29
• Yes, only to the quantitative parameters, in my case height and weight – LJG Jan 14 at 9:41