sDmatCluster: Function to partition a grid map into clusters

Description Usage Arguments Value Note See Also Examples

View source: R/sDmatCluster.r

Description

sDmatCluster is supposed to obtain clusters from a grid map. It returns an object of class "sBase".

Usage

1
2
3
4
5
6
7
8
sDmatCluster(
sMap,
which_neigh = 1,
distMeasure = c("mean", "median", "min", "max"),
constraint = TRUE,
clusterLinkage = c("average", "complete", "single", "bmh"),
reindexSeed = c("hclust", "svd", "none")
)

Arguments

sMap

an object of class "sMap"

which_neigh

which neighbors in 2D output space are used for the calculation. By default, it sets to "1" for direct neighbors, and "2" for neighbors within neighbors no more than 2, and so on

distMeasure

distance measure used to calculate distances in high-dimensional input space. It can be one of "median", "mean", "min" and "max" measures

constraint

logic whether further constraint applied. If TRUE, only consider those hexagons 1) with 2 or more neighbors; and 2) neighbors are not within minima already found (due to the same distance)

clusterLinkage

cluster linkage used to derive clusters. It can be "bmh", which accumulates a cluster just based on best-matching hexagons/rectanges but can not ensure each cluster is continuous. Instead, each cluster is continuous when using region-growing algorithm with one of "average", "complete" and "single" linkages

reindexSeed

the way to index seed. It can be "hclust" for reindexing seeds according to hierarchical clustering of patterns seen in seeds, "svd" for reindexing seeds according to svd of patterns seen in seeds, or "none" for seeds being simply increased by the hexagon indexes (i.e. always in an increasing order as hexagons radiate outwards)

Value

an object of class "sBase", a list with following components:

Note

The first item in the return "seeds" is the first cluster, whose memberships are those in the return "bases" that equals 1. The same relationship is held for the second item, and so on

See Also

sPipeline, sDmatMinima, sBMH, sNeighDirect, sDistance, visDmatCluster

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# 1) generate an iid normal random matrix of 100x10 
data <- matrix( rnorm(100*10,mean=0,sd=1), nrow=100, ncol=10)

# 2) get trained using by default setup
sMap <- sPipeline(data=data)

# 3) partition the grid map into clusters based on different criteria
# 3a) based on "bmh" criterion
# sBase <- sDmatCluster(sMap=sMap, which_neigh=1, distMeasure="median", clusterLinkage="bmh")
# 3b) using region-growing algorithm with linkage "average"
sBase <- sDmatCluster(sMap=sMap, which_neigh=1, distMeasure="median",
clusterLinkage="average")

# 4) visualise clusters/bases partitioned from the sMap
visDmatCluster(sMap,sBase)

Example output

Loading required package: hexbin
Start at 2018-05-24 05:05:08

First, define topology of a map grid (2018-05-24 05:05:08)...
Second, initialise the codebook matrix (61 X 10) using 'linear' initialisation, given a topology and input data (2018-05-24 05:05:08)...
Third, get training at the rough stage (2018-05-24 05:05:08)...
	1 out of 7 (2018-05-24 05:05:08)
	updated (2018-05-24 05:05:08)
	2 out of 7 (2018-05-24 05:05:08)
	updated (2018-05-24 05:05:08)
	3 out of 7 (2018-05-24 05:05:08)
	updated (2018-05-24 05:05:08)
	4 out of 7 (2018-05-24 05:05:08)
	updated (2018-05-24 05:05:08)
	5 out of 7 (2018-05-24 05:05:08)
	updated (2018-05-24 05:05:08)
	6 out of 7 (2018-05-24 05:05:08)
	updated (2018-05-24 05:05:08)
	7 out of 7 (2018-05-24 05:05:08)
	updated (2018-05-24 05:05:08)
Fourth, get training at the finetune stage (2018-05-24 05:05:08)...
	1 out of 25 (2018-05-24 05:05:08)
	updated (2018-05-24 05:05:08)
	2 out of 25 (2018-05-24 05:05:08)
	updated (2018-05-24 05:05:08)
	3 out of 25 (2018-05-24 05:05:08)
	updated (2018-05-24 05:05:08)
	4 out of 25 (2018-05-24 05:05:08)
	updated (2018-05-24 05:05:08)
	5 out of 25 (2018-05-24 05:05:08)
	updated (2018-05-24 05:05:08)
	6 out of 25 (2018-05-24 05:05:08)
	updated (2018-05-24 05:05:08)
	7 out of 25 (2018-05-24 05:05:08)
	updated (2018-05-24 05:05:08)
	8 out of 25 (2018-05-24 05:05:08)
	updated (2018-05-24 05:05:08)
	9 out of 25 (2018-05-24 05:05:08)
	updated (2018-05-24 05:05:08)
	10 out of 25 (2018-05-24 05:05:08)
	updated (2018-05-24 05:05:08)
	11 out of 25 (2018-05-24 05:05:08)
	updated (2018-05-24 05:05:08)
	12 out of 25 (2018-05-24 05:05:08)
	updated (2018-05-24 05:05:08)
	13 out of 25 (2018-05-24 05:05:08)
	updated (2018-05-24 05:05:08)
	14 out of 25 (2018-05-24 05:05:08)
	updated (2018-05-24 05:05:08)
	15 out of 25 (2018-05-24 05:05:08)
	updated (2018-05-24 05:05:08)
	16 out of 25 (2018-05-24 05:05:08)
	updated (2018-05-24 05:05:08)
	17 out of 25 (2018-05-24 05:05:08)
	updated (2018-05-24 05:05:08)
	18 out of 25 (2018-05-24 05:05:08)
	updated (2018-05-24 05:05:08)
	19 out of 25 (2018-05-24 05:05:08)
	updated (2018-05-24 05:05:08)
	20 out of 25 (2018-05-24 05:05:08)
	updated (2018-05-24 05:05:08)
	21 out of 25 (2018-05-24 05:05:08)
	updated (2018-05-24 05:05:08)
	22 out of 25 (2018-05-24 05:05:08)
	updated (2018-05-24 05:05:08)
	23 out of 25 (2018-05-24 05:05:08)
	updated (2018-05-24 05:05:08)
	24 out of 25 (2018-05-24 05:05:08)
	updated (2018-05-24 05:05:08)
	25 out of 25 (2018-05-24 05:05:08)
	updated (2018-05-24 05:05:08)
Next, identify the best-matching hexagon/rectangle for the input data (2018-05-24 05:05:08)...
Finally, append the response data (hits and mqe) into the sMap object (2018-05-24 05:05:08)...

Below are the summaries of the training results:
   dimension of input data: 100x10
   xy-dimension of map grid: xdim=9, ydim=9, r=5
   grid lattice: hexa
   grid shape: suprahex
   dimension of grid coord: 61x2
   initialisation method: linear
   dimension of codebook matrix: 61x10
   mean quantization error: 5.23901546357726

Below are the details of trainology:
   training algorithm: batch
   alpha type: invert
   training neighborhood kernel: gaussian
   trainlength (x input data length): 7 at rough stage; 25 at finetune stage
   radius (at rough stage): from 3 to 1
   radius (at finetune stage): from 1 to 1

End at 2018-05-24 05:05:08
Runtime in total is: 0 secs

supraHex documentation built on May 24, 2021, 3 p.m.