Function to partition a grid map into clusters

Description

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

Usage

sDmatCluster(sMap, which_neigh = 1, distMeasure = c("median", "mean", "min", "max"), 
  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
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:

  • seeds: the vector to store cluster seeds, i.e., a list of local minima (in 2D output space) of distance matrix (in input space). They are represented by the indexes of hexagons/rectangles
  • bases: the vector with the length of nHex to store the cluster memberships/bases, where nHex is the total number of hexagons/rectanges in the grid
  • call: the call that produced this result

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

Examples

# 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)
Start at 2017-03-27 18:54:54 First, define topology of a map grid (2017-03-27 18:54:54)... Second, initialise the codebook matrix (61 X 10) using 'linear' initialisation, given a topology and input data (2017-03-27 18:54:54)... Third, get training at the rough stage (2017-03-27 18:54:54)... 1 out of 7 (2017-03-27 18:54:54) updated (2017-03-27 18:54:54) 2 out of 7 (2017-03-27 18:54:54) updated (2017-03-27 18:54:54) 3 out of 7 (2017-03-27 18:54:54) updated (2017-03-27 18:54:54) 4 out of 7 (2017-03-27 18:54:54) updated (2017-03-27 18:54:54) 5 out of 7 (2017-03-27 18:54:54) updated (2017-03-27 18:54:54) 6 out of 7 (2017-03-27 18:54:54) updated (2017-03-27 18:54:54) 7 out of 7 (2017-03-27 18:54:54) updated (2017-03-27 18:54:54) Fourth, get training at the finetune stage (2017-03-27 18:54:54)... 1 out of 25 (2017-03-27 18:54:54) updated (2017-03-27 18:54:54) 2 out of 25 (2017-03-27 18:54:54) updated (2017-03-27 18:54:54) 3 out of 25 (2017-03-27 18:54:54) updated (2017-03-27 18:54:54) 4 out of 25 (2017-03-27 18:54:54) updated (2017-03-27 18:54:54) 5 out of 25 (2017-03-27 18:54:54) updated (2017-03-27 18:54:54) 6 out of 25 (2017-03-27 18:54:54) updated (2017-03-27 18:54:54) 7 out of 25 (2017-03-27 18:54:54) updated (2017-03-27 18:54:54) 8 out of 25 (2017-03-27 18:54:54) updated (2017-03-27 18:54:54) 9 out of 25 (2017-03-27 18:54:54) updated (2017-03-27 18:54:54) 10 out of 25 (2017-03-27 18:54:54) updated (2017-03-27 18:54:54) 11 out of 25 (2017-03-27 18:54:54) updated (2017-03-27 18:54:54) 12 out of 25 (2017-03-27 18:54:54) updated (2017-03-27 18:54:54) 13 out of 25 (2017-03-27 18:54:54) updated (2017-03-27 18:54:54) 14 out of 25 (2017-03-27 18:54:54) updated (2017-03-27 18:54:54) 15 out of 25 (2017-03-27 18:54:54) updated (2017-03-27 18:54:54) 16 out of 25 (2017-03-27 18:54:54) updated (2017-03-27 18:54:54) 17 out of 25 (2017-03-27 18:54:54) updated (2017-03-27 18:54:54) 18 out of 25 (2017-03-27 18:54:54) updated (2017-03-27 18:54:54) 19 out of 25 (2017-03-27 18:54:54) updated (2017-03-27 18:54:54) 20 out of 25 (2017-03-27 18:54:54) updated (2017-03-27 18:54:54) 21 out of 25 (2017-03-27 18:54:54) updated (2017-03-27 18:54:54) 22 out of 25 (2017-03-27 18:54:54) updated (2017-03-27 18:54:54) 23 out of 25 (2017-03-27 18:54:54) updated (2017-03-27 18:54:54) 24 out of 25 (2017-03-27 18:54:54) updated (2017-03-27 18:54:54) 25 out of 25 (2017-03-27 18:54:54) updated (2017-03-27 18:54:54) Next, identify the best-matching hexagon/rectangle for the input data (2017-03-27 18:54:54)... Finally, append the response data (hits and mqe) into the sMap object (2017-03-27 18:54:54)... 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: 4.87294660591056 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 2017-03-27 18:54:54 Runtime in total is: 0 secs
# 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)