kplanes: Local principal component analysis (LPCA). Extends k-means to...

Description Usage Arguments Value Examples

Description

Takes in data, number of clusters, intrinsic dimension, maximum iteration number and threshold for stopping

Usage

1
kplanes(X, k, d, iter.max = 50, thresh = 0)

Arguments

X

Data.

k

Number of clusters.

d

Intrinsic dimension.

iter.max

Maximum number of iterations.

thresh

Threshold for stopping, percentage change of normalized reconstruction error.

Value

a list of cluster membership (indicator), representaion (X.rep), average normalized reconstruction error (error).

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
38
39
40
41
42
43
44
45
46
############################## example I: Open box
## package for 3d plot
library(rgl)

## load data
data(OpenBox)

## intrinsic dimension of the data
trueDim = 2
## threshold for kplanes stopping (relative reconstruction error change ratio)
thresh = 0
## number of clusters
K = 6
set.seed(0)
temp = kplanes(OpenBox, k=K, d=trueDim, thresh=thresh)
OpenBox_rep = temp[[2]]
cluster_id = temp[[1]]
error_rep = temp[[3]]
open3d()
plot3d(OpenBox,col=cluster_id,xlim=c(0,2),ylim=c(0,2),zlim=c(0,2))


############################## example II: Swiss roll
## package for 3d plot
library(rgl)

## load data
data(SwissRoll)

## intrinsic dimension of the data
trueDim = 2

## threshold for kplanes stopping (relative reconstruction error change ratio)
thresh = 0

## number of clusters
K = 8

set.seed(0)
temp = kplanes(SwissRoll, k=K, d=trueDim, iter.max=1000, thresh=thresh)
SwissRoll_rep = temp[[2]]
cluster_id = temp[[1]]
error_rep = temp[[3]]

open3d()
plot3d(SwissRoll,col=cluster_id,xlim=c(0,2),ylim=c(0,2),zlim=c(0,2))

Yanhao29/GeoRatio documentation built on May 10, 2019, 12:05 a.m.