kplane: k-Plane Clustering Algorithm

Description Usage Arguments Value References Examples

View source: R/kplane.R

Description

It is one of the first methods proposed in 2000 for fitting (p-1)-dimensional planes for data in R^p by EM-like algorithm that updates parametrization of a plane and assigning data points to the nearest plane in an alternating manner. Empirically, its performance is not competitive against newer methods but we include this as a test benchmark as well as it is simple and fast enough.

Usage

1
kplane(X, K = 2, iter = 496, print.progress = TRUE)

Arguments

X

an (n\times p) data matrix.

K

the number of clusters.

iter

the number of EM-type updating.

print.progress

a logical; TRUE to show completion of iterations by 10, FALSE otherwise.

Value

a list whose elements are also lists of following elements:

cluster

length-n vector of cluster label.

w

an (p\times K) matrix of orthonormal columns.

gamma

a length-K vector of projection values.

name

name of the algorithm.

References

\insertRef

bradley_k-plane_2000Rsubclust

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
## generate a toy example of two plane components
set.seed(18)
tester = simLP(n=100, nl=0, np=2)
data   = tester$data
label  = tester$class

## do PCA for data reduction
proj = base::eigen(stats::cov(data))$vectors[,1:2]
dat2 = data%*%proj

## run k-plane algorithm with K=2, 3, and 4
kplane2 = kplane(data, K=2)
kplane3 = kplane(data, K=3)
kplane4 = kplane(data, K=4)

## extract clustering
finc2 = kplane2$cluster
finc3 = kplane3$cluster
finc4 = kplane4$cluster

## visualize
opar <- par(mfrow=c(3,4), no.readonly=TRUE)
plot(dat2[,1],dat2[,2],pch=19,cex=0.3,col=finc2+1,main="K=2:PCA")
plot(data[,1],data[,2],pch=19,cex=0.3,col=finc2+1,main="K=2:Axis(1,2)")
plot(data[,1],data[,3],pch=19,cex=0.3,col=finc2+1,main="K=2:Axis(1,3)")
plot(data[,2],data[,3],pch=19,cex=0.3,col=finc2+1,main="K=2:Axis(2,3)")

plot(dat2[,1],dat2[,2],pch=19,cex=0.3,col=finc3+1,main="K=3:PCA")
plot(data[,1],data[,2],pch=19,cex=0.3,col=finc3+1,main="K=3:Axis(1,2)")
plot(data[,1],data[,3],pch=19,cex=0.3,col=finc3+1,main="K=3:Axis(1,3)")
plot(data[,2],data[,3],pch=19,cex=0.3,col=finc3+1,main="K=3:Axis(2,3)")

plot(dat2[,1],dat2[,2],pch=19,cex=0.3,col=finc4+1,main="K=4:PCA")
plot(data[,1],data[,2],pch=19,cex=0.3,col=finc4+1,main="K=4:Axis(1,2)")
plot(data[,1],data[,3],pch=19,cex=0.3,col=finc4+1,main="K=4:Axis(1,3)")
plot(data[,2],data[,3],pch=19,cex=0.3,col=finc4+1,main="K=4:Axis(2,3)")
par(opar)

kyoustat/Rsubclust documentation built on Feb. 22, 2020, 12:20 a.m.