rclust.dbscan: DBSCAN for Manifold-valued Data

Description Usage Arguments Value References See Also Examples

View source: R/rclust.dbscan.R

Description

Density-Based Spatial Clustering of Applications with Noise (DBSCAN) is a generally applicable clustering algorithm as long as we have concept of dissimilarity. We adopt dbscan algorithm by dbscan package. See dbscan for more details.

Usage

1
rclust.dbscan(input, type = c("extrinsic", "intrinsic"), eps, minPts = 5, ...)

Arguments

input

a S3 object of riemdata class. See riemfactory for more details.

type

type of distance, either "intrinsic" or "extrinsic".

eps

size of the epsilon neighborhood.

minPts

number of minimum points in the eps region (for core points). Default is 5 points.

...

extra parameters for DBSCAN algorithms including eps or minPts. See dbscan for more details.

Value

an object of class dbscan_fast containing

eps

value of the eps parameter.

minPts

value of the minPts parameter.

cluster

An integer vector with cluster assignments. Zero indicates noise points.

References

\insertRef

ester_density-based_1996RiemBaseExt

\insertRef

hahsler_dbscan_2019RiemBaseExt

See Also

See dbscan for details.

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
## generate 50 points near (0,0,1)  and
##          50 points near (0,0,-1) on Sphere S^2 
ndata = 50
theta = seq(from=-0.99,to=0.99,length.out=ndata)*pi
tmpx  = cos(theta) + rnorm(ndata,sd=0.1)
tmpy  = sin(theta) + rnorm(ndata,sd=0.1)

## wrap it as 'riemdata' class
data  = list()
for (i in 1:ndata){
  tgt = c(tmpx[i],tmpy[i],1)
  data[[i]] = tgt/sqrt(sum(tgt^2)) # project onto Sphere
}
for (i in 1:ndata){
  tgt = c(tmpx[i],tmpy[i],-1)
  data[[i+ndata]] = tgt/sqrt(sum(tgt^2)) # project onto Sphere
}
data = RiemBase::riemfactory(data, name="sphere")

## compare extrinsic and intrinsic DBSCAN
dbext <- rclust.dbscan(data, eps=0.5, type="extrinsic")
dbint <- rclust.dbscan(data, eps=0.5, type="intrinsic")

## let's visualize the results via MDS in R^2
pdist = stats::as.dist(RiemBase::rbase.pdist(data))
dat2d = stats::cmdscale(pdist, k=2)

opar <- par(no.readonly=TRUE)
par(mfrow=c(1,2))
plot(dat2d[,1], dat2d[,2], col=dbext$cluster, pch=19, main="extrinsic+dbscan")
plot(dat2d[,1], dat2d[,2], col=dbint$cluster, pch=19, main="intrinsic+dbscan")
par(opar)

kyoustat/RiemBaseExt documentation built on March 28, 2020, 2:08 a.m.