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.