Description Usage Arguments Details Value Author(s) See Also Examples
Performs K-means clustering via an implicit mapping to a kernel induced feature space.
1 2 3 |
data |
the data to cluster represented by a
kernel matrix (an object of class |
ncenters |
the number of clusters |
init |
the initialisation method (see |
prototypes |
Initial values for the
prototypes. It contains linear coefficients that describe the
prototypes as linear combination of the initial data
points mapped in the kernel induced feature space. It has therefore
one row for each prototype ( |
weights |
optional weights for the data points |
max.iter |
maximal number of iterations of the algorithm |
verbose |
switch for tracing the clustering process |
keepdata |
if |
... |
not used |
This method implements Kernel K-means: the kernel is used to define an implicit mapping of the original data into a kernel induced feature space where a standard K-means is applied. The mapping is not explicitely carried out.
An object of class "batchkmeans"
and of class
"kernelbatchkmeans"
, a list with components
including
prototypes |
a matrix containing the coordinates of the prototypes: each row of the matrix sums to one and contains the coefficients of a linear combination of the original observations in the kernel induced feature space |
classif |
a vector of integer indicating to which cluster each observation has been assigned |
errors |
a vector containing the evolution of the quantisation error during the fitting process |
data |
the original data if the function is called with
|
weights |
the weights of the data points if the function is called with
|
Fabrice Rossi
See batchsom.kernelmatrix
for Self-Oganising Map which
provides both clustering and visualisation.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | ## inspired by the kmeans example in the stats package
require(graphics)
## 2 dimensional dataset
X <- cbind(rnorm(200,mean=2,sd=0.35),rnorm(200,mean=-1,sd=0.35))
Y <- cbind(runif(200,min=-1.5,max=-0.75),runif(200,min=0,max=0.5))
Z <- cbind(rnorm(200,sd=0.15),rnorm(200,sd=0.5))
M <- matrix(c(sin(pi/4),cos(pi/4),-cos(pi/4),sin(pi/4)),ncol=2)
U <- rbind(X,Y,Z%*%M+c(rep(0.25,200),rep(-0.5,200)))
U <- scale(U)
K <- as.kernelmatrix(tcrossprod(U))
km <- batchkmeans(K,3)
plot(U,col=km$classif,cex=0.5)
## map back the prototypes to the original space
points(km$prototypes%*%U,col=1:3,pch=20,cex=2)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.