Doubt while fitting Kmeans object

Why did prateek bhaiya used y values in
kmeans.fit(X,y)
using y values in fit() will make it a supervised learning, and i guess the whole purpose is gone,
beacuse in clustering we dont have class labels (y) , and considering only X features, our algo try to finds the similiar points and group them together,

And when, y values are already provided, its just a normal classifier. then No use of kmeans…

Because this dataset was self generated so we had y labels. but in real world challenge, we wont have y labels for dataset.
So, Would not it be just :
kmeans.fit(X)

1 Like

Hello Mohit,
kmeans.fit() accepts only X as a parameter and when Y is passed, it automatically ignores it (as specified in the documentation https://scikit-learn.org/stable/modules/generated/sklearn.cluster.KMeans.html). So, even if we only pass X as a parameter here, the results won’t get effected.
Great job on noticing that though.

I hope I resolved your query.

1 Like