View source: R/sphere_gskmeans.R
| gskmeans | R Documentation |
Geodesic spherical k-means algorithm is an counterpart of the spherical k-means
algorithm by replacing the cosine similarity with the squared geodesic distance,
which is the great-circle distance under the intrinsic geometry regime
on the unit hypersphere. If the data is not
normalized, it performs the normalization and proceeds thereafter.
gskmeans(data, k = 2, ...)
data |
an |
k |
the number of clusters (default: 2). |
... |
extra parameters including
|
a named list of S3 class T4cluster containing
a length-n vector of class labels (from 1:k).
a value of the cost function.
an (k\times p) matrix where each row is a unit-norm class mean.
name of the algorithm.
# -------------------------------------------------------------
# clustering with 'household' dataset
# -------------------------------------------------------------
## PREPARE
data(household, package="T4cluster")
X = household$data
lab = as.integer(household$gender)
## EXECUTE GSKMEANS WITH VARYING K's
vec.rand = rep(0, 9)
for (i in 1:9){
clust_i = gskmeans(X, k=(i+1))$cluster
vec.rand[i] = compare.rand(clust_i, lab)
}
## VISUALIZE THE RAND INDEX
opar <- par(no.readonly=TRUE)
plot(2:10, vec.rand, type="b", pch=19, ylim=c(0.5, 1),
ylab="Rand index",xlab="number of clusters",
main="clustering quality index over varying k's.")
par(opar)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.