k-means with scikit-learn

scikit-learn's KMeans runs the whole k-means loop, with fit_predict giving each example a group number and cluster_centers_ holding the centers, but its distances weigh features by their units, so the features are scaled first in a pipeline, several starts are run (n_init) with a fixed random_state, and the result suits round groups of similar spread.

By

Updated

Cheat sheet: k-means with scikit-learn
Category
Machine Learning
Level
Journeyman
Tags
ai, fit_predict(), KMeans, k-means++, Pipeline (python), python, StandardScaler