更新时间:2021-10-04 01:34:57
centers
参数采用整数k
,在这种情况下,选择data
中的k
随机点作为初始中心,或者初始中心的矩阵,其列与data
一样多.试试这个:
The centers
parameter takes either an integer k
, in which case k
random points from data
are chosen as initial centers, or a matrix of initial centers, with as many columns as data
. Try this:
x <- rbind(matrix(rnorm(100, sd = 0.3), ncol = 2),
matrix(rnorm(100, mean = 1, sd = 0.3), ncol = 2))
kmeans(x,centers=3)
kmeans(x,centers=x[1:3,])