Loading…
Glossary term
A clustering algorithm that groups data into k clusters around central points.
K-means picks k starting centers, assigns every point to its nearest center, moves each center to the average of its points, and repeats until the groups stop changing.
You must choose k in advance, and the result can depend on the starting centers.
K-means
from sklearn.cluster import KMeans
km = KMeans(n_clusters=3, n_init=10).fit(X)
print(km.cluster_centers_)It is the most popular simple clustering algorithm.