powered by
Solves the K-means problem using kmeans++ for the initialization and then runs Lloyd's algorithm.
gforce.kmeans(X, K, R_only = FALSE)
\(n x m\) matrix. Each row is treated as a point in \(R^m\).
integer. The number of clusters to group the data into.
logical expression. If R_only == FALSE, then the included native code implementation will be used. Otherwise, an R implementation is used.
R_only == FALSE
Returns an object with the components:
clusters
a \(n\) dimensional integer vector. Entry \(i\) to the cluster assignment of the data point given by row \(i\) of X.
X
centers
a \(K x m\) numeric matrix. Row \(i\) corresponds to the center of cluster \(i\).
num_iters
an integer. Number of iterations of Lloyd's Algorithm.
time
a numeric. Runtime of Lloyd's Algorithm.
S.P. Lloyd. Least Squares Quantization in PCM. IEEE Transactions on Information Theory, 1982.
D. Arthur and S. Vassilvitskii. k-means++: The Advantages of Careful Seeding. SODA, 2007.
# NOT RUN { m <- 10 n <- 10 X <- matrix(MASS::mvrnorm(m*n,rep(0,m*n),diag(m*n)), nrow = n) km_res <- gforce.kmeans(X,3) # }
Run the code above in your browser using DataLab