I am new to machine learning and i am using
from sklearn import datasets
iris=datasets.load_iris()
to learn about the KMeans. So i used the data to fit using KMeans like this
kmeans=KMeans(n_clusters=1,random_state=42).fit(iris['data'])
print(kmeans.cluster_centers_)
and what i see is, i am getting 4 co-ordinates instead of 2
[[5.84333333 3.05733333 3.758 1.19933333]]
i went through this article to learn about KMeans but this article also demonstrates with two co-ordinates
question
why am i getting 4 co-ordiantes instead of 2, what am i doing wrong and what am i missing
Iris dataset contains 4 features describing the three different types of flowers (i.e. 3 classes). Therefore, each point in the dataset is located in a 4-dimensional space and the same applies to the centroids, so to describe their position you need the 4 coordinates.
In examples, it's easier to use 2-dimensional data (sometimes 3-dimensional) as it is easier to plot it out and display for teaching purposes, but the centroids will have as many coordinates as your data has dimensions (i.e. features), so with the Iris dataset, you would expect the 4 coordinates.