简体   繁体   中英

What is the shape (n_clusters, n_features) referring to? and how to use it

kmeans = KMeans(n_clusters = 5, init = ?, random_state = 42)

How to define it in my program (n_clusters, n_features)?

I want to define my own centroid rather than 'kmean++' or 'random'

To initialize your kmeans, you need k points (number of clusters). Each of your point is represented by features, so it produces an array of k points each of dimension d (the number of features).

So KMeans expects here a numpy array with n_clusters rows and n_features columns containing your specified points for initialization. This is what the shape is referring to.

Of course, it should be consistent with the number of clusters you expect in the first argument (so here, you should have 5 points).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM