Scikit-learn k-means: what does the forecasting method really do?

When I use scikit-learn to implement k-environments, I usually just call the method fit(), and this is enough to get the centers of the clusters and labels. The method is predict()used to calculate labels, and even the method fit_predict()is available for convenience, but if I can only get labels using fit(), what is the purpose of the method predict()?

+4
source share
1 answer

predictas @EdChum suggested, can be used for invisible data. This method (and, moreover, the method transform) is useful when the k-tool is used to extract traits in semi-server training: you cluster a large set of samples, then use the nearest centroid / centroid distance as a function for subsequent supervised training problem. When using the result for forecasting, you get samples that were not visible using k-means.

+1
source

All Articles