scikit-learn's k-means: what does the predict method really do?

ε祈祈猫儿з 提交于 2019-12-23 13:33:33

问题


When I use scikit-learn's implementation of k-means I usually just call the fit() method and that is enough to get the cluster centers and the labels. The predict() method is used to calculate the labels and even a fit_predict() method is available for convenience, but if I can get the labels only using fit(), what is the purpose of the predict() method?


回答1:


predict, as @EdChum suggested, can be used on unseen data. This (and more so, the transform method) is useful when k-means is used for feature extraction in semisupervised learning: you cluster a large set of samples, then use nearest centroid/distance to centroids as features for a subsequent supervised learning problem. When using the result for prediction, you get samples that were not seen by k-means.



来源:https://stackoverflow.com/questions/25012342/scikit-learns-k-means-what-does-the-predict-method-really-do

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!