batchkmeans.kenelmatrix: Kernel K-means Clustering

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Performs K-means clustering via an implicit mapping to a kernel induced feature space.

Usage

1
2
3
## S3 method for class 'kernelmatrix'
batchkmeans(data, ncenters, init = c("prototypes", "random", "cluster"),
prototypes, weights, max.iter, verbose = FALSE, keepdata = TRUE, ...)

Arguments

data

the data to cluster represented by a kernel matrix (an object of class "kernelmatrix", see as.kernelmatrix).

ncenters

the number of clusters

init

the initialisation method (see batchkmeans for details)

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 (ncenters) and has many columns as data points. If missing, initial prototypes are chosen via the method specified by the init parameter (see details)

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 TRUE, the original data are returned as part of the result object

...

not used

Details

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.

Value

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 keepdata = TRUE

weights

the weights of the data points if the function is called with keepdata = TRUE and if the weights is given

Author(s)

Fabrice Rossi

See Also

See batchsom.kernelmatrix for Self-Oganising Map which provides both clustering and visualisation.

Examples

 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)

yasomi documentation built on May 2, 2019, 5:59 p.m.