gforce.kmeans: K-means Clustering.

Description Usage Arguments Value References Examples

View source: R/kmeans.R

Description

Solves the K-means problem using kmeans++ for the initialization and then runs Lloyd's algorithm.

Usage

1
gforce.kmeans(X, K, R_only = FALSE)

Arguments

X

n x m matrix. Each row is treated as a point in R^m.

K

integer. The number of clusters to group the data into.

R_only

logical expression. If R_only == FALSE, then the included native code implementation will be used. Otherwise, an R implementation is used.

Value

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.

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.

References

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.

Examples

1
2
3
4
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)

GFORCE documentation built on May 2, 2019, 3:44 a.m.