Function to calculate distance matrix in high-dimensional input space but according to neighborhood relationships in 2D output space

Description

sDmat is supposed to calculate distance (measured in high-dimensional input space) to neighbors (defined by based on 2D output space) for each of hexagons/rectangles

Usage

sDmat(sMap, which_neigh = 1, distMeasure = c("median", "mean", "min", "max"))

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

Value

  • dMat: a vector with the length of nHex. It stores the distance a hexaon/rectangle is away from its output-space-defined neighbors in high-dimensional input space

Note

"which_neigh" is defined in output 2D space, but "distMeasure" is defined in high-dimensional input space

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:53 First, define topology of a map grid (2017-03-27 18:54:53)... Second, initialise the codebook matrix (61 X 10) using 'linear' initialisation, given a topology and input data (2017-03-27 18:54:53)... Third, get training at the rough stage (2017-03-27 18:54:53)... 1 out of 7 (2017-03-27 18:54:53) updated (2017-03-27 18:54:53) 2 out of 7 (2017-03-27 18:54:53) updated (2017-03-27 18:54:53) 3 out of 7 (2017-03-27 18:54:53) updated (2017-03-27 18:54:53) 4 out of 7 (2017-03-27 18:54:53) updated (2017-03-27 18:54:53) 5 out of 7 (2017-03-27 18:54:53) updated (2017-03-27 18:54:53) 6 out of 7 (2017-03-27 18:54:53) updated (2017-03-27 18:54:53) 7 out of 7 (2017-03-27 18:54:53) updated (2017-03-27 18:54:53) Fourth, get training at the finetune stage (2017-03-27 18:54:53)... 1 out of 25 (2017-03-27 18:54:53) updated (2017-03-27 18:54:53) 2 out of 25 (2017-03-27 18:54:53) updated (2017-03-27 18:54:53) 3 out of 25 (2017-03-27 18:54:53) updated (2017-03-27 18:54:53) 4 out of 25 (2017-03-27 18:54:53) updated (2017-03-27 18:54:53) 5 out of 25 (2017-03-27 18:54:53) updated (2017-03-27 18:54:53) 6 out of 25 (2017-03-27 18:54:53) updated (2017-03-27 18:54:53) 7 out of 25 (2017-03-27 18:54:53) updated (2017-03-27 18:54:53) 8 out of 25 (2017-03-27 18:54:53) updated (2017-03-27 18:54:53) 9 out of 25 (2017-03-27 18:54:53) updated (2017-03-27 18:54:53) 10 out of 25 (2017-03-27 18:54:53) updated (2017-03-27 18:54:53) 11 out of 25 (2017-03-27 18:54:53) updated (2017-03-27 18:54:53) 12 out of 25 (2017-03-27 18:54:53) updated (2017-03-27 18:54:53) 13 out of 25 (2017-03-27 18:54:53) updated (2017-03-27 18:54:53) 14 out of 25 (2017-03-27 18:54:53) updated (2017-03-27 18:54:53) 15 out of 25 (2017-03-27 18:54:53) updated (2017-03-27 18:54:53) 16 out of 25 (2017-03-27 18:54:53) updated (2017-03-27 18:54:53) 17 out of 25 (2017-03-27 18:54:53) updated (2017-03-27 18:54:53) 18 out of 25 (2017-03-27 18:54:53) updated (2017-03-27 18:54:53) 19 out of 25 (2017-03-27 18:54:53) updated (2017-03-27 18:54:53) 20 out of 25 (2017-03-27 18:54:53) updated (2017-03-27 18:54:53) 21 out of 25 (2017-03-27 18:54:53) updated (2017-03-27 18:54:53) 22 out of 25 (2017-03-27 18:54:53) updated (2017-03-27 18:54:53) 23 out of 25 (2017-03-27 18:54:53) updated (2017-03-27 18:54:53) 24 out of 25 (2017-03-27 18:54:53) updated (2017-03-27 18:54:53) 25 out of 25 (2017-03-27 18:54:53) updated (2017-03-27 18:54:53) Next, identify the best-matching hexagon/rectangle for the input data (2017-03-27 18:54:53)... Finally, append the response data (hits and mqe) into the sMap object (2017-03-27 18:54:53)... 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:53 Runtime in total is: 0 secs
# 3) calculate "median" distances in INPUT space to different neighbors in 2D OUTPUT space # 3a) using direct neighbors in 2D OUTPUT space dMat <- sDmat(sMap=sMap, which_neigh=1, distMeasure="median") # 3b) using no more than 2-topological neighbors in 2D OUTPUT space # dMat <- sDmat(sMap=sMap, which_neigh=2, distMeasure="median")

Source code

sDmat.r

Source man

sDmat.Rd sDmat.pdf

See also

sNeighAny