between and we can see this as the data being represented using components (that iswe have new features)with all features being apart from the one that represents the cluster center the point is assigned to using this -dimensional representationit would now be possible to separate the two half-moon shapes using linear modelwhich would not have been possible using the original two features it is also possible to get an even more expressive representation of the data by using the distances to each of the cluster centers as features this can be accomplished using the transform method of kmeansin[ ]distance_features kmeans transform(xprint("distance feature shape{}format(distance_features shape)print("distance features:\ {}format(distance_features)out[ ]distance feature shape( distance features[ ] -means is very popular algorithm for clusteringnot only because it is relatively easy to understand and implementbut also because it runs relatively quickly kmeans scales easily to large datasetsand scikit-learn even includes more scalable variant in the minibatchkmeans classwhich can handle very large datasets one of the drawbacks of -means is that it relies on random initializationwhich means the outcome of the algorithm depends on random seed by defaultscikitlearn runs the algorithm times with different random initializationsand returns the best result further downsides of -means are the relatively restrictive assumptions made on the shape of clustersand the requirement to specify the number of clusters you are looking for (which might not be known in real-world applicationnextwe will look at two more clustering algorithms that improve upon these properties in some ways in this case"bestmeans that the sum of variances of the clusters is small clustering