muHVT: Collection of functions used for vector quantization and construction of hierarchical Voronoi Tessellations for data analysis in R

Meet Dave, Avinash Joshi, Zubin Dowlaty

2018-08-17

Abstract

The muHVT package is a collection of R functions for vector quantization and construction of hierarchical voronoi tessellations as a data visualization tool to visualize cells using quantization. The hierarchical cells are computed using Hierarchical K-means where a quantization threshold governs the levels in the hierarchy for a set \(k\) parameter (the maximum number of cells at each level). The package is particularly helpful to visualize rich mutlivariate data.

This package additionally provides functions for computing the Sammon’s projection and plotting the heat map of the variables on the tiles of the tessellations.

Vector Quantization

This package performs vector quantization using the following algorithm -

Hierarchical VQ using k-means

k-means

  1. The k-means algorithm randomly selects k data points as initial means.
  2. k clusters are formed by assigning each data point to its closest cluster mean. The algorithm uses the Euclidean distance.
  3. Virtual means for each cluster are calculated by using all datapoints contained in a cluster.

The second and third step is iterated until a predefined number of iteration is reached or the clusters converge. The runtime for the algorithm is O(n).

Hierarchical VQ using k-means

The algorithm divides the dataset recursively into cells. The \(k-means\) algorithm is used by setting \(k\) to say, two in order to divide the dataset into two subsets.Then, the two subsets are divided again into two subsets by setting \(k\) to two to result in a total of four subsets. The recursion terminates when the cells contain single data point or a stop criterion is reached. In this case, the stop criterion is when the cell error exceeds the quantization threshold.

Following are the steps for the method :-

  1. Select k(number of cells), depth and quantization error threshold
  2. Perform k-means on the input dataset
  3. Calculate quantization error for each of the k cells
  4. Compare the quantization error for each cell to quantization threshold error
  5. Repeat steps 2 to 4 for each of the k cells whose quantization error is above threshold until stop criterion is reached. The stop criterion is when the quantization error of a cell reaches below quantization error threshold or there is a single point in the cell or we have reached the user specified depth.

The quantization error for a cell is defined as follows :

\[QE = \max_i(||A-F_i||_{p})\]

where

  • \(A\) is the centroid of the cell
  • \(F_i\) represents a data point in the cell
  • \(m\) is the number of points in the cell.
  • \(p\) is the \(p\)-norm metric. Here \(p\) = 1 represents L1 Norm and \(p\) = 2 represents L2 Norm.

Quantization error

Let’s try to understand quantization error with an example

Figure 1: The Voronoi tessellation for level 1 shown for the 5 cells with the points overlayed

Figure 1: The Voronoi tessellation for level 1 shown for the 5 cells with the points overlayed

An example of 2 dimensional VQ is shown above.

In the above image, we can see that there are 5 cells and each cells contain certain number of points. The centroid for each cell is shown in blue. We can also call the centroids as codewords as they represent all the points in that cell. The set of all codewords is called a codebook.

Now we want to calculate quantization error for each cell. For the sake of simplicity, let’s consider only once cell having centroid A and m data points \(F_i\) for calculating quantization error.

For each point, we calculate the distance between the point and the centroid.

\[ d = ||A - F_i||_{p} \]

In the above equation, p = 1 means L1_Norm distance whereas p = 2 means L2_Norm distance.In the package, the L1_Norm distance is chosen by default. The user can pass either L1_Norm or L2_Norm or a custom function to calculate the distance between two points in n dimensions.

\[QE = \max_i(||A-F_i||_{p})\]

Now, we take the max of the distance of all m points. This gives us the max distance of a point in the cell from the centroid which we refer to as Quantization Error. If the quantization error is higher than the given threshold, this means that the centroid/codevector is not a good representation for the points in the cell. Now we can perform vector quantization on this points further and repeat the steps above.

Please note that the user can select mean, max or any custom function to calculate the quantization error. The custom function takes a vector of m value (where each value is a distance between point in n dimensions and centroids) and returns a single value which is the quantization error for the cell.

If we select mean as the error metric, the above Quantization Error equation will look like this :-

\[QE = \frac{1}{m}\sum_{i=1}^m||A-F_i||_{p}\]

Voronoi Tessellations

A Voronoi diagram is a way of dividing space into a number of regions. A set of points (called seeds, sites, or generators) is specified beforehand and for each seed there will be a corresponding region consisting of all points closer to that seed than to any other. The regions are called Voronoi cells. It is dual to the Delaunay triangulation.

Sammon’s projection

Sammon projection is an algorithm that maps a high-dimensional space to a space of lower dimensionality by trying to preserve the structure of inter-point distances in high-dimensional space in the lower-dimension projection. It is particularly suited for use in exploratory data analysis. It is considered a non-linear approach as the mapping cannot be represented as a linear combination of the original variables. The centroids are plotted in 2D after performing Sammon’s projection at every level of the tessellation.

Denote the distance between \(i^{th}\) and \(j^{th}\) objects in the original space by \(d_{ij}^*\), and the distance between their projections by \(d_{ij}\). Sammon’s mapping aims to minimize the following error function, which is often referred to as Sammon’s stress or Sammon’s error:

\[E=\frac{1}{\sum_{i<j} d_{ij}^*}\sum_{i<j}\frac{(d_{ij}^*-d_{ij})^2}{d_{ij}^*}\]

The minimization can be performed either by gradient descent, as proposed initially, or by other means, usually involving iterative methods. The number of iterations need to be experimentally determined and convergent solutions are not always guaranteed. Many implementations prefer to use the first Principal Components as a starting configuration.

Constructing Voronoi tesselations

In this package, we use sammons from the package MASS to project higher dimensional data to 2D space. The function hvq called inside from function HVT returns hierarchical quantized data which will be the input for construction tesselations. The data is then represented in 2d coordinates and the tessellations are plotted using these coordinates as centroids. We use the package deldir for this purpose. The deldir package computes the Delaunay triangulation (and hence the Dirichlet or Voronoi tesselation) of a planar point set according to the second (iterative) algorithm of Lee and Schacter.For subsequent levels, transformation is performed on the 2d coordinates to get all the points within its parent tile. Tessellations are plotted using these transformed points as centroids. The lines in the tessellations are chopped in places so that they do not protrude outside the parent polygon. This is done for all the subsequent levels.

Example Usage 1

In this section, we will use the Prices of Personal Computers dataset. This dataset contains 6259 observations and 10 features. The dataset observes the price from 1993 to 1995 of 486 personal computers in the US. The variables are price,speed,ram,screen,cd,etc. The dataset can be downloaded from here

In this example, we will compress this dataset by using hierarhical VQ using k-means and visualize the Voronoi tesselation plots using Sammons projection. Later on, we will overlay price,speed and screen variable as heatmap to generate further insights.

Here, we load the data and store into a variable computers.

set.seed(240)
# Load data from csv files
computers <- read.csv("https://raw.githubusercontent.com/thomaspernet/data_csv_r/master/data/Computers.csv")

Let’s have a look at sample of the data

# Quick peek
Table(head(computers))
X price speed hd ram screen cd multi premium ads trend
1 1499 25 80 4 14 no no yes 94 1
2 1795 33 85 2 14 no no yes 94 1
3 1595 25 170 4 15 no no yes 94 1
4 1849 25 170 8 14 no no no 94 1
5 3295 33 340 16 14 no no yes 94 1
6 3695 66 340 16 14 no no yes 94 1

Now let us check the structure of the data

str(computers)
#> 'data.frame':    6259 obs. of  11 variables:
#>  $ X      : int  1 2 3 4 5 6 7 8 9 10 ...
#>  $ price  : int  1499 1795 1595 1849 3295 3695 1720 1995 2225 2575 ...
#>  $ speed  : int  25 33 25 25 33 66 25 50 50 50 ...
#>  $ hd     : int  80 85 170 170 340 340 170 85 210 210 ...
#>  $ ram    : int  4 2 4 8 16 16 4 2 8 4 ...
#>  $ screen : int  14 14 15 14 14 14 14 14 14 15 ...
#>  $ cd     : Factor w/ 2 levels "no","yes": 1 1 1 1 1 1 2 1 1 1 ...
#>  $ multi  : Factor w/ 2 levels "no","yes": 1 1 1 1 1 1 1 1 1 1 ...
#>  $ premium: Factor w/ 2 levels "no","yes": 2 2 2 1 2 2 2 2 2 2 ...
#>  $ ads    : int  94 94 94 94 94 94 94 94 94 94 ...
#>  $ trend  : int  1 1 1 1 1 1 1 1 1 1 ...

Let’s get a summary of the data

summary(computers)
#>        X            price          speed              hd        
#>  Min.   :   1   Min.   : 949   Min.   : 25.00   Min.   :  80.0  
#>  1st Qu.:1566   1st Qu.:1794   1st Qu.: 33.00   1st Qu.: 214.0  
#>  Median :3130   Median :2144   Median : 50.00   Median : 340.0  
#>  Mean   :3130   Mean   :2220   Mean   : 52.01   Mean   : 416.6  
#>  3rd Qu.:4694   3rd Qu.:2595   3rd Qu.: 66.00   3rd Qu.: 528.0  
#>  Max.   :6259   Max.   :5399   Max.   :100.00   Max.   :2100.0  
#>       ram             screen        cd       multi      premium   
#>  Min.   : 2.000   Min.   :14.00   no :3351   no :5386   no : 612  
#>  1st Qu.: 4.000   1st Qu.:14.00   yes:2908   yes: 873   yes:5647  
#>  Median : 8.000   Median :14.00                                   
#>  Mean   : 8.287   Mean   :14.61                                   
#>  3rd Qu.: 8.000   3rd Qu.:15.00                                   
#>  Max.   :32.000   Max.   :17.00                                   
#>       ads            trend      
#>  Min.   : 39.0   Min.   : 1.00  
#>  1st Qu.:162.5   1st Qu.:10.00  
#>  Median :246.0   Median :16.00  
#>  Mean   :221.3   Mean   :15.93  
#>  3rd Qu.:275.0   3rd Qu.:21.50  
#>  Max.   :339.0   Max.   :35.00

Let us first split the data into train and test. We will use 80% of the data as train and remaining as test.

noOfPoints <- dim(computers)[1]
trainLength <- as.integer(noOfPoints * 0.8)

trainComputers <- computers[1:trainLength,]
testComputers <- computers[(trainLength+1):noOfPoints,]

K-means in not suitable for factor variables as the sample space for factor variables is discrete. A Euclidean distance function on such a space isn’t really meaningful. Hence we will delete the factor variables in our dataset.

Here we keep the original trainComputers and testComputers as we will use price variable from this dataset to overlay as heatmap and generate some insights.

trainComputers <- trainComputers %>% dplyr::select(-c(X,cd,multi,premium,trend))
testComputers <- testComputers %>% dplyr::select(-c(X,cd,multi,premium,trend))

Let us try to understand HVT function first.

HVT(dataset, nclust, depth, quant.err, projection.scale, normalize = T, distance_metric = c("L1_Norm","L2_Norm"), error_metric = c("mean","max"))

Here I have explained all the parameters in detail

  • dataset - Dataframe. A dataframe with numeric columns

  • nlcust - Numeric. An integer indicating the number of cells per hierarchy (level)

  • depth - An integer indicating the number of levels. (1 = No hierarchy, 2 = 2 levels, etc …)

  • quant.error - A number indicating the quantization error threshold. A cell will only breakdown into further cells only if the quantization error of the cell is above quantization error threshold.

  • projection.scale - A number indicating the scale factor for the tesselations so as to visualize the sub-tesselations well enough.

  • normalize - A logical value indicating if the columns in your dataset should be normalized. Default value is TRUE. The algorithm supports Z-score normalization.

  • distance_metric - The distance metric can be L1_Norm or L2_Norm. L1_Norm is selected by default. The distance metric is used to calculate the distance between a n dimensional point and centroid. The user can also pass a custom function to calculate the distance.

  • error_metric - The error metric can be mean or max. The max will return the max of m values. The mean will take mean of m values where each value is a distance between a point and centroid of the cell. Moreover, the user can also pass a custom function to calculate the error metric.

First we will perform hierarchical vector quantization at level 1 by setting the parameter depth to 1. Here level 1 signifies no hierarchy. Let’s keep the no of cells as 15.

set.seed(240)
hvt.results <- list()
hvt.results <- muHVT::HVT(trainComputers,
                          nclust = 15,
                          depth = 1,
                          quant.err = 0.2,
                          projection.scale = 10,
                          normalize = T)

Now let’s try to understand plotHVT function. Here I have explained all the parameters in detail

plotHVT(hvt.results, line.width, color.vec, pch1 = 21, centroid.size = 3, title = NULL)
  • hvt.results - A list containing the ouput of HVT function which has the details of the tessellations to be plotted

  • line.width - A vector indicating the line widths of the tessellation boundaries for each level

  • color.vec - A vector indicating the colors of the boundaries of the tessellations at each level

  • pch1 - Symbol type of the centroids of the tessellations (parent levels). Refer points. (default = 21)

  • centroid.size - Size of centroids of first level tessellations. (default = 3)

  • title - Set a title for the plot. (default = NULL)

Let’s plot the voronoi tesselation

# Voronoi tesselation plot for level one
plotHVT(hvt.results,
        line.width = c(1.2), 
        color.vec = c("#141B41"))
Figure 2: The Voronoi tessellation for level 1 shown for the 15 cells in the dataset ’computers’

Figure 2: The Voronoi tessellation for level 1 shown for the 15 cells in the dataset ’computers’

As per the manual, hvt.results[[3]] gives us detailed information about the hierarchical vector quantized data

hvt.results[[3]][['summary']] gives a nice tabular data containing no of points, quantization error and the codebook.

Now let us understand what each column in the summary table means

  • Segment Level - Level of the cell. In this case, we have performed vector quantization for depth 1. Hence Segment Level is 1

  • Segment Parent - Parent Segment of the cell

  • Segment Child - The children of a particular cell. In this case, first level has 15 cells Hence, we can see Segment Child 1,2,3,4,5 ,..,15.

  • n - No of points in each cell

  • Quant.Error - Quantization error for each cell

All the columns after this will contains centroids for each cell for all the variables. They can be also called as codebook as is the collection of centroids for all cells (codewords)

summaryTable(hvt.results[[3]][['summary']])
Segment.Level Segment.Parent Segment.Child n Quant.Error price speed hd ram screen ads
1 1 1 557 2.58 0.88 -0.01 0.83 1.63 -0.10 0.25
1 1 2 465 1.64 -0.17 -0.78 0.33 -0.01 -0.35 0.44
1 1 3 562 1.4 -1.25 -0.93 -0.84 -0.80 -0.51 0.65
1 1 4 480 2.3 0.71 0.69 0.24 -0.02 0.06 0.56
1 1 5 384 3.33 0.80 0.17 0.03 0.09 2.88 0.11
1 1 6 139 2.38 0.22 2.67 0.09 -0.21 -0.15 0.76
1 1 7 302 2.09 -0.32 -0.54 -0.80 -0.50 -0.43 -2.15
1 1 8 248 2.21 -0.37 0.67 0.84 0.04 -0.13 -0.59
1 1 9 397 2.05 -0.52 0.57 -0.62 -0.75 -0.32 0.78
1 1 10 230 3.16 1.10 0.34 -0.16 0.35 -0.14 -1.93
1 1 11 423 1.5 -0.49 -0.86 -0.74 -0.67 -0.28 0.36
1 1 12 294 1.69 -1.14 -0.79 -0.58 -0.70 -0.39 -0.78
1 1 13 169 3.82 1.58 0.00 3.29 2.64 0.28 -0.25
1 1 14 87 3.43 1.59 2.67 1.62 1.70 0.13 0.32
1 1 15 270 1.94 -0.40 0.66 -0.66 -0.72 -0.40 -0.38

Let’s have a look at Quant.Error variable in the above table. It seems that none of the cells have hit the quantization threshold error.

Now let’s check the compression summary. The table below shows no of cells, no of cells having quantization error below threshold and percentage of cells having quantization error below threshold for each level.

compressionSummaryTable(hvt.results[[3]]$compression_summary)
segmentLevel noOfCells noOfCellsBelowQuantizationError percentOfCellsBelowQuantizationErrorThreshold
1 15 0 0

As it can be seen in the table above, percentage of cells in level1 having quantization error below threshold is 0%. Hence we can go one level deeper and try to compress it further.

We will now overlay the Quant.Error variable as heatmap over the voronoi tesselation plot to visualize the quantization error better.

Let’s have look at the function hvtHmap which we will use to overlay a variable as heatmap.

hvtHmap(hvt.results, dataset, child.level, hmap.cols, color.vec ,line.width, palette.color = 6)
  • hvt.results - A list of hvt.results obtained from the HVT function.

  • dataset - A dataframe containing the variables that you want to overlay as heatmap. The user can pass an external dataset or the dataset that was used to perform hierarchical vector quantization. The dataset should have same number of points as the dataset used to perform hierarchical vector quantization in the HVT function

  • child.level - A number indicating the level for which the heat map is to be plotted.

  • hmap.cols - The column number of column name from the dataset indicating the variables for which the heat map is to be plotted. To plot the quantization error as heatmap, pass 'quant_error'. Similary to plot the no of points in each cell as heatmap, pass 'no_of_points' as a parameter

  • color.vec - A color vector such that length(color.vec) = child.level (default = NULL)

  • line.width - A line width vector such that length(line.width) = child.level. (default = NULL)

  • palette.color - A number indicating the heat map color palette. 1 - rainbow, 2 - heat.colors, 3 - terrain.colors, 4 - topo.colors, 5 - cm.colors, 6 - BlCyGrYlRd (Blue,Cyan,Green,Yellow,Red) color. (default = 6)

  • show.points - A boolean indicating if the centroids should be plotted on the tesselations. (default = FALSE)

Now let’s plot the quantization error for each cell at level one as heatmap.

hvtHmap(hvt.results, 
        trainComputers, 
        child.level = 1,
        hmap.cols = "quant_error", 
        line.width = c(0.2),
        color.vec = c("#141B41"),
        palette.color = 6,
        centroid.size = 3,
        show.points = T)
Figure 3: The Voronoi tessellation with the heat map overlaid for variable ’quant_error’ in the ’computers’ dataset

Figure 3: The Voronoi tessellation with the heat map overlaid for variable ’quant_error’ in the ’computers’ dataset

Now let’s go one level deeper and perform hierarchical vector quantization.

set.seed(240)
hvt.results2 <- list()
# depth=2 is used for level2 in the hierarchy
hvt.results2 <- muHVT::HVT(trainComputers,
                           nclust = 15,
                           depth = 2,
                           quant.err = 0.2,
                           projection.scale = 10,
                           normalize = T)

Let’s plot the voronoi tesselation for both the levels.

# Voronoi tesselation plot for level two
plotHVT(hvt.results2, 
        line.width = c(1.2, 0.8), 
        color.vec = c("#141B41","#0582CA"))
Figure 4: The Voronoi tessellation for level 2 shown for the 225 cells in the dataset ’computers’

Figure 4: The Voronoi tessellation for level 2 shown for the 225 cells in the dataset ’computers’

In the table below, Segment Level signifies the depth.

Level 1 has 15 cells

Level 2 has 225 cells .i.e. each cell in level1 is divided into 225 cells

Let’s analyze the summary table again for Quant.Error and see if any of the cells in the 2nd level have quantization error below quantization error threshold. In the table below, the values for Quant.Error of the cells which have hit the quantization error threshold are shown in red. Here we are showing just top 50 rows for the sake of brevity.

summaryTable(hvt.results2[[3]][['summary']],limit = 50)
Segment.Level Segment.Parent Segment.Child n Quant.Error price speed hd ram screen ads
1 1 1 557 2.58 0.88 -0.01 0.83 1.63 -0.10 0.25
1 1 2 465 1.64 -0.17 -0.78 0.33 -0.01 -0.35 0.44
1 1 3 562 1.4 -1.25 -0.93 -0.84 -0.80 -0.51 0.65
1 1 4 480 2.3 0.71 0.69 0.24 -0.02 0.06 0.56
1 1 5 384 3.33 0.80 0.17 0.03 0.09 2.88 0.11
1 1 6 139 2.38 0.22 2.67 0.09 -0.21 -0.15 0.76
1 1 7 302 2.09 -0.32 -0.54 -0.80 -0.50 -0.43 -2.15
1 1 8 248 2.21 -0.37 0.67 0.84 0.04 -0.13 -0.59
1 1 9 397 2.05 -0.52 0.57 -0.62 -0.75 -0.32 0.78
1 1 10 230 3.16 1.10 0.34 -0.16 0.35 -0.14 -1.93
1 1 11 423 1.5 -0.49 -0.86 -0.74 -0.67 -0.28 0.36
1 1 12 294 1.69 -1.14 -0.79 -0.58 -0.70 -0.39 -0.78
1 1 13 169 3.82 1.58 0.00 3.29 2.64 0.28 -0.25
1 1 14 87 3.43 1.59 2.67 1.62 1.70 0.13 0.32
1 1 15 270 1.94 -0.40 0.66 -0.66 -0.72 -0.40 -0.38
2 1 1 43 1.02 0.82 0.81 0.72 1.63 0.55 0.90
2 1 2 1 0 2.90 0.92 0.32 4.76 0.55 0.50
2 1 3 29 0.88 0.84 0.92 0.82 1.63 -0.61 1.18
2 1 4 22 1.3 0.95 0.69 0.96 1.63 -0.61 -0.41
2 1 5 43 0.63 1.52 0.92 0.77 1.63 -0.61 0.41
2 1 6 30 0.46 0.31 -0.78 1.73 1.63 0.55 -0.86
2 1 7 28 1.06 0.97 0.84 0.62 1.63 0.55 -0.46
2 1 8 54 0.89 0.89 -0.90 0.68 1.63 -0.61 -0.15
2 1 9 30 0.94 0.60 0.56 1.75 1.63 0.55 -0.91
2 1 10 60 0.52 0.84 -0.90 0.83 1.63 -0.61 0.69
2 1 11 41 0.61 1.15 0.09 0.78 1.63 -0.61 0.50
2 1 12 22 0.92 0.26 -1.03 0.82 1.63 -0.46 1.28
2 1 13 45 0.86 0.27 -0.87 1.01 1.63 -0.61 0.16
2 1 14 67 0.86 1.42 0.89 0.35 1.63 0.55 0.44
2 1 15 42 1.12 0.70 -0.88 0.64 1.63 0.55 0.17
2 2 1 15 0.74 -0.48 -0.84 0.52 0.06 0.55 -0.30
2 2 2 17 0.66 -0.57 -0.83 0.29 0.06 0.55 1.37
2 2 3 32 0.77 0.02 -0.78 0.49 0.04 0.55 0.41
2 2 4 60 0.48 0.09 -0.86 0.33 0.06 -0.61 0.71
2 2 5 2 0.13 0.07 -0.78 3.06 0.06 -0.61 0.07
2 2 6 14 0.68 -1.05 -0.75 0.05 0.06 -0.61 0.46
2 2 7 28 0.53 -0.22 -0.84 0.83 0.06 -0.61 0.30
2 2 8 42 1.01 0.55 -0.78 -0.13 -0.20 -0.61 0.20
2 2 9 6 0.76 0.42 -0.78 -0.15 -0.59 0.55 0.82
2 2 10 48 0.81 -0.33 -0.83 0.56 0.05 -0.61 -0.53
2 2 11 43 0.75 -0.41 -0.92 0.36 0.06 -0.61 1.22
2 2 12 71 0.67 -0.24 -0.92 0.25 0.06 -0.61 0.32
2 2 13 32 0.72 -0.03 0.09 0.36 0.04 -0.61 0.74
2 2 14 34 0.81 -0.51 -0.87 0.15 0.02 0.55 0.48
2 2 15 21 0.85 -0.24 -0.80 0.13 -0.72 -0.61 0.69
2 3 1 50 0.53 -1.12 -0.71 -1.18 -1.09 -0.61 0.68
2 3 2 32 0.82 -1.38 -0.86 -0.04 -0.60 -0.61 0.45
2 3 3 45 0.52 -1.35 -1.20 -1.16 -0.90 -0.61 0.66
2 3 4 11 0.85 -1.49 -0.90 -0.56 -0.79 0.55 0.28
2 3 5 11 0.74 -1.26 -0.82 -0.49 -0.72 0.55 1.23

The users can look at the compression summary to get a quick summary on the compression as it becomes quite cumbersome to look at the summary table above as we go deeper.

compressionSummaryTable(hvt.results2[[3]]$compression_summary)
segmentLevel noOfCells noOfCellsBelowQuantizationError percentOfCellsBelowQuantizationErrorThreshold
1 15 0 0
2 225 11 0.05

As it can be seen in the table above, only 5% cells in the 2nd level have quantization error below threshold. Therefore, we can go one more level deeper and try to compress the data further.

We will look at the heatmap for quantization error for level 2.

hvtHmap(hvt.results2, 
        trainComputers, 
        child.level = 2,
        hmap.cols = "quant_error", 
        line.width = c(0.8,0.2),
        color.vec = c("#141B41","#0582CA"),
        palette.color = 6,
        centroid.size = 2,
        show.points = T)
Figure 5: The Voronoi tessellation with the heat map overlaid for variable ’quant_error’ in the ’computers’ dataset

Figure 5: The Voronoi tessellation with the heat map overlaid for variable ’quant_error’ in the ’computers’ dataset

As the quantization error criteria is not met, let’s do hierarchical vector quantization at level 3.

set.seed(240)
hvt.results3 <- list()
# depth=3 is used for level3 in the hierarchy
hvt.results3 <- muHVT::HVT(trainComputers,
                           nclust = 15,
                           depth = 3,
                           quant.err = 0.2,
                           projection.scale = 10,
                           normalize = T)

Let’s plot the voronoi tesselation for all 3 levels.

# Voronoi tesselation plot for level three
plotHVT(hvt.results3,
        line.width = c(1.2,0.8,0.4),
        color.vec = c("#141B41","#0582CA","#8BA0B4"),
        centroid.size = 3)
Figure 6: The Voronoi tessellation for level 3 shown for the 1905 cells in the dataset ’computers’

Figure 6: The Voronoi tessellation for level 3 shown for the 1905 cells in the dataset ’computers’

Each of the 225 cells whose quantization is above threshold in level 2 will break down into 15 cells each in level 3. Hence, as it can be seen below, level 3 has 3375 rows. So it will have 3615 rows in total. We will only show first 500 rows here.

summaryTable(hvt.results3[[3]][['summary']],scroll = T,limit = 500)
Segment.Level Segment.Parent Segment.Child n Quant.Error price speed hd ram screen ads
1 1 1 557 2.58 0.88 -0.01 0.83 1.63 -0.10 0.25
1 1 2 465 1.64 -0.17 -0.78 0.33 -0.01 -0.35 0.44
1 1 3 562 1.4 -1.25 -0.93 -0.84 -0.80 -0.51 0.65
1 1 4 480 2.3 0.71 0.69 0.24 -0.02 0.06 0.56
1 1 5 384 3.33 0.80 0.17 0.03 0.09 2.88 0.11
1 1 6 139 2.38 0.22 2.67 0.09 -0.21 -0.15 0.76
1 1 7 302 2.09 -0.32 -0.54 -0.80 -0.50 -0.43 -2.15
1 1 8 248 2.21 -0.37 0.67 0.84 0.04 -0.13 -0.59
1 1 9 397 2.05 -0.52 0.57 -0.62 -0.75 -0.32 0.78
1 1 10 230 3.16 1.10 0.34 -0.16 0.35 -0.14 -1.93
1 1 11 423 1.5 -0.49 -0.86 -0.74 -0.67 -0.28 0.36
1 1 12 294 1.69 -1.14 -0.79 -0.58 -0.70 -0.39 -0.78
1 1 13 169 3.82 1.58 0.00 3.29 2.64 0.28 -0.25
1 1 14 87 3.43 1.59 2.67 1.62 1.70 0.13 0.32
1 1 15 270 1.94 -0.40 0.66 -0.66 -0.72 -0.40 -0.38
2 1 1 43 1.02 0.82 0.81 0.72 1.63 0.55 0.90
2 1 2 1 0 2.90 0.92 0.32 4.76 0.55 0.50
2 1 3 29 0.88 0.84 0.92 0.82 1.63 -0.61 1.18
2 1 4 22 1.3 0.95 0.69 0.96 1.63 -0.61 -0.41
2 1 5 43 0.63 1.52 0.92 0.77 1.63 -0.61 0.41
2 1 6 30 0.46 0.31 -0.78 1.73 1.63 0.55 -0.86
2 1 7 28 1.06 0.97 0.84 0.62 1.63 0.55 -0.46
2 1 8 54 0.89 0.89 -0.90 0.68 1.63 -0.61 -0.15
2 1 9 30 0.94 0.60 0.56 1.75 1.63 0.55 -0.91
2 1 10 60 0.52 0.84 -0.90 0.83 1.63 -0.61 0.69
2 1 11 41 0.61 1.15 0.09 0.78 1.63 -0.61 0.50
2 1 12 22 0.92 0.26 -1.03 0.82 1.63 -0.46 1.28
2 1 13 45 0.86 0.27 -0.87 1.01 1.63 -0.61 0.16
2 1 14 67 0.86 1.42 0.89 0.35 1.63 0.55 0.44
2 1 15 42 1.12 0.70 -0.88 0.64 1.63 0.55 0.17
2 2 1 15 0.74 -0.48 -0.84 0.52 0.06 0.55 -0.30
2 2 2 17 0.66 -0.57 -0.83 0.29 0.06 0.55 1.37
2 2 3 32 0.77 0.02 -0.78 0.49 0.04 0.55 0.41
2 2 4 60 0.48 0.09 -0.86 0.33 0.06 -0.61 0.71
2 2 5 2 0.13 0.07 -0.78 3.06 0.06 -0.61 0.07
2 2 6 14 0.68 -1.05 -0.75 0.05 0.06 -0.61 0.46
2 2 7 28 0.53 -0.22 -0.84 0.83 0.06 -0.61 0.30
2 2 8 42 1.01 0.55 -0.78 -0.13 -0.20 -0.61 0.20
2 2 9 6 0.76 0.42 -0.78 -0.15 -0.59 0.55 0.82
2 2 10 48 0.81 -0.33 -0.83 0.56 0.05 -0.61 -0.53
2 2 11 43 0.75 -0.41 -0.92 0.36 0.06 -0.61 1.22
2 2 12 71 0.67 -0.24 -0.92 0.25 0.06 -0.61 0.32
2 2 13 32 0.72 -0.03 0.09 0.36 0.04 -0.61 0.74
2 2 14 34 0.81 -0.51 -0.87 0.15 0.02 0.55 0.48
2 2 15 21 0.85 -0.24 -0.80 0.13 -0.72 -0.61 0.69
2 3 1 50 0.53 -1.12 -0.71 -1.18 -1.09 -0.61 0.68
2 3 2 32 0.82 -1.38 -0.86 -0.04 -0.60 -0.61 0.45
2 3 3 45 0.52 -1.35 -1.20 -1.16 -0.90 -0.61 0.66
2 3 4 11 0.85 -1.49 -0.90 -0.56 -0.79 0.55 0.28
2 3 5 11 0.74 -1.26 -0.82 -0.49 -0.72 0.55 1.23
2 3 6 85 0.5 -1.23 -0.82 -0.69 -0.72 -0.61 0.31
2 3 7 41 0.64 -1.09 -1.03 -1.15 -0.97 -0.61 0.12
2 3 8 67 0.51 -0.97 -0.91 -0.66 -0.71 -0.61 0.85
2 3 9 51 0.59 -1.48 -0.95 -0.76 -0.72 -0.61 0.78
2 3 10 38 0.68 -1.17 -0.86 -0.54 -0.68 -0.61 1.52
2 3 11 26 0.92 -1.65 -1.04 -1.16 -1.00 -0.61 1.19
2 3 12 38 0.62 -0.88 -0.91 -1.08 -0.68 -0.61 0.69
2 3 13 14 0.83 -1.34 -1.11 -1.01 -0.86 0.55 1.01
2 3 14 40 0.8 -1.62 -1.07 -0.99 -0.81 -0.61 0.17
2 3 15 13 0.53 -1.35 -0.97 -1.18 -1.11 0.55 0.53
2 4 1 76 0.79 0.21 0.92 0.32 0.04 0.55 0.36
2 4 2 24 0.66 0.10 0.94 0.35 -0.07 -0.61 0.42
2 4 3 37 0.61 0.53 0.09 0.20 0.06 -0.61 0.49
2 4 4 28 1.14 2.29 0.86 0.69 -0.19 0.55 0.27
2 4 5 21 0.92 0.84 0.88 0.09 -0.01 -0.61 -0.13
2 4 6 12 1.15 0.92 0.44 -0.31 -0.72 -0.61 0.52
2 4 7 64 1 0.45 0.08 -0.05 -0.01 0.55 0.44
2 4 8 18 1.09 1.90 0.92 0.73 -0.02 -0.61 0.59
2 4 9 21 0.59 0.29 1.03 0.38 0.06 -0.61 0.92
2 4 10 39 1.15 0.05 0.78 0.34 0.08 0.55 1.27
2 4 11 33 1 1.26 0.89 0.54 0.04 0.55 0.59
2 4 12 38 1.12 1.01 0.92 -0.31 -0.18 0.55 0.35
2 4 13 9 1.16 2.08 -0.39 0.46 0.06 -0.49 0.46
2 4 14 37 0.61 0.87 0.92 0.29 0.06 -0.61 0.63
2 4 15 23 0.7 0.40 0.93 0.30 0.06 -0.61 1.52
2 5 1 64 1.32 0.67 0.67 0.09 0.00 2.88 0.63
2 5 2 41 1.07 0.21 -0.79 0.18 0.01 2.88 0.47
2 5 3 24 1.06 0.47 -0.87 -0.72 -0.65 2.88 0.86
2 5 4 24 1.08 -0.84 -0.64 -0.14 -0.73 2.88 -0.16
2 5 5 28 1.62 -0.13 0.71 0.09 -0.24 2.88 -0.22
2 5 6 28 1 2.11 0.92 0.40 1.63 2.88 0.52
2 5 7 14 1.43 1.05 -0.75 -0.30 -0.49 2.88 -0.44
2 5 8 27 0.97 -0.45 -0.93 -0.70 -0.72 2.88 0.71
2 5 9 19 1.72 1.49 0.44 -0.35 -0.55 2.88 0.69
2 5 10 16 2.04 3.18 0.92 0.19 1.04 2.88 -0.20
2 5 11 12 1.31 0.89 1.29 0.59 1.63 2.88 0.13
2 5 12 35 1.48 1.04 0.12 -0.54 -0.11 2.88 -2.04
2 5 13 27 2.13 1.75 1.50 0.46 0.06 2.88 0.78
2 5 14 7 1.17 2.55 -0.78 -0.06 1.63 2.88 -0.28
2 5 15 18 2.16 0.80 0.26 1.72 1.11 2.88 -0.90
2 6 1 8 0.32 0.07 2.67 0.24 0.06 0.55 1.52
2 6 2 14 0.4 0.40 2.67 0.51 0.06 0.55 0.44
2 6 3 6 0.55 0.54 2.67 0.28 0.06 0.55 1.27
2 6 4 9 0.39 -0.22 2.67 -1.18 -1.11 -0.61 1.24
2 6 5 8 0.35 -0.21 2.67 -0.68 -0.72 -0.61 0.27
2 6 6 8 0.59 0.16 2.67 0.27 0.06 -0.61 -0.43
2 6 7 6 0.29 0.31 2.67 0.26 0.06 -0.61 0.47
2 6 8 14 0.5 0.26 2.67 0.20 0.06 -0.61 1.41
2 6 9 5 0.65 -0.01 2.67 0.18 -0.72 -0.61 -0.41
2 6 10 12 0.5 0.41 2.67 0.44 0.00 0.55 -0.30
2 6 11 8 0.39 0.42 2.67 0.83 0.06 -0.61 0.22
2 6 12 13 0.71 -0.10 2.67 -0.59 -0.72 -0.61 1.25
2 6 13 8 0.93 -0.26 2.67 -0.73 -0.82 0.55 1.02
2 6 14 13 0.55 0.77 2.67 0.44 0.06 -0.61 1.25
2 6 15 7 0.14 0.48 2.67 0.85 0.06 0.55 1.52
2 7 1 19 0.44 -0.02 -0.78 -0.66 -0.72 -0.61 -2.33
2 7 2 14 1.11 -0.67 -0.84 -0.80 -0.77 0.55 -2.11
2 7 3 11 0.62 -0.76 0.09 -1.18 -0.97 -0.61 -2.16
2 7 4 27 0.63 -0.87 -1.00 -1.00 -0.67 -0.61 -2.32
2 7 5 26 0.75 -1.31 -1.04 -1.15 -0.94 -0.61 -2.29
2 7 6 24 0.43 -0.09 0.09 -0.90 -0.72 -0.61 -2.30
2 7 7 11 1.32 0.28 -0.78 -0.35 -0.15 0.02 -1.10
2 7 8 15 0.35 0.07 0.09 -0.58 0.06 -0.61 -2.26
2 7 9 50 0.75 0.02 -0.86 -0.49 0.06 -0.61 -2.13
2 7 10 7 0.87 0.31 -0.28 -0.62 -0.72 0.55 -2.25
2 7 11 23 0.58 -0.20 0.92 -1.07 -0.80 -0.61 -2.28
2 7 12 8 0.34 -0.16 0.09 -0.77 -0.72 -0.61 -1.67
2 7 13 17 0.56 -0.60 -0.83 -0.78 -0.74 -0.61 -1.67
2 7 14 28 0.48 -0.45 -0.81 -1.00 -0.63 -0.61 -2.29
2 7 15 22 0.67 0.12 -0.80 -0.61 0.06 0.55 -2.13
2 8 1 34 0.95 -0.70 0.92 0.57 -0.07 -0.61 -1.00
2 8 2 20 0.77 -0.20 0.92 1.18 0.06 0.55 0.02
2 8 3 4 0.34 -0.58 -0.78 0.82 0.06 0.55 -1.07
2 8 4 20 1.57 -0.12 0.16 3.08 0.06 -0.32 -0.78
2 8 5 22 1.08 -0.27 0.92 1.18 0.14 0.55 -0.98
2 8 6 7 0.64 0.33 0.09 0.61 0.06 -0.61 -0.61
2 8 7 28 0.92 -0.49 0.83 0.22 0.01 0.55 -0.13
2 8 8 13 0.4 -0.39 0.09 0.82 0.06 -0.61 -0.97
2 8 9 15 0.84 -0.64 0.92 0.21 0.01 0.55 -0.94
2 8 10 11 0.58 0.26 0.92 0.77 0.06 -0.61 -0.79
2 8 11 15 0.36 -0.28 0.92 0.89 0.06 -0.61 0.07
2 8 12 9 0.94 -0.83 0.09 0.75 -0.11 0.55 -0.92
2 8 13 13 0.21 -0.42 0.92 0.31 0.06 -0.61 0.10
2 8 14 29 0.41 -0.38 0.92 0.37 0.06 -0.61 -0.44
2 8 15 8 0.22 -0.37 -0.78 0.82 0.06 -0.61 -1.30
2 9 1 20 0.58 -0.96 0.92 -0.65 -0.72 -0.61 0.72
2 9 2 18 0.51 0.06 0.09 -0.73 -0.67 -0.61 0.66
2 9 3 27 0.42 -0.69 0.09 -1.18 -1.11 -0.61 0.59
2 9 4 16 1.29 -0.64 0.81 -0.11 -0.18 0.55 1.16
2 9 5 16 1.11 -0.87 1.06 -1.03 -0.99 -0.47 1.49
2 9 6 41 0.97 -0.35 0.95 -0.64 -0.79 0.55 0.65
2 9 7 47 0.69 0.00 0.93 -0.62 -0.65 -0.61 0.65
2 9 8 22 1 -1.07 0.09 -0.93 -0.86 -0.56 1.18
2 9 9 34 1.08 -0.75 0.46 0.10 -0.65 -0.61 0.53
2 9 10 11 1.3 -0.81 0.32 0.03 -0.36 -0.61 1.34
2 9 11 36 0.57 -0.55 0.98 -1.17 -1.09 -0.61 0.72
2 9 12 23 0.74 -0.27 1.10 -0.65 -0.72 -0.61 1.21
2 9 13 42 1 -0.70 0.11 -0.52 -0.73 0.55 0.56
2 9 14 29 0.67 -0.56 0.09 -0.69 -0.58 -0.61 0.62
2 9 15 15 0.69 -0.04 0.15 0.06 -0.72 -0.61 0.82
2 10 1 19 1.27 0.69 0.21 0.03 0.02 -0.61 -1.22
2 10 2 12 0.83 0.63 -0.13 -0.54 -0.07 0.55 -2.26
2 10 3 11 1 2.58 -0.31 0.40 0.06 -0.61 -2.20
2 10 4 15 0.91 2.81 0.92 0.52 0.06 -0.30 -2.34
2 10 5 10 1.12 1.41 0.83 -0.19 1.63 0.55 -1.72
2 10 6 12 1.33 2.15 0.92 0.66 0.00 -0.23 -1.33
2 10 7 20 0.75 0.65 0.05 -0.61 -0.01 -0.61 -2.25
2 10 8 12 0.88 0.78 0.92 -0.33 0.00 0.55 -1.33
2 10 9 14 1.14 1.34 0.50 0.08 1.63 -0.61 -2.10
2 10 10 15 0.5 0.88 -0.92 -0.08 1.63 -0.61 -2.28
2 10 11 32 0.81 0.62 0.92 -0.58 -0.01 -0.61 -2.15
2 10 12 9 0.84 0.82 -0.92 0.46 1.63 -0.23 -1.67
2 10 13 5 0.76 0.69 -0.43 -0.53 1.63 0.55 -2.12
2 10 14 24 1.07 1.12 0.92 -0.40 -0.23 0.55 -2.27
2 10 15 20 1.07 0.49 -0.04 -0.32 -0.01 0.55 -1.40
2 11 1 49 0.42 -0.53 -0.84 -0.66 -0.72 -0.61 0.79
2 11 2 15 0.26 -0.21 -0.78 -1.12 -0.72 -0.61 0.07
2 11 3 26 0.52 -0.11 -0.85 -0.57 -0.72 -0.61 0.51
2 11 4 27 0.62 -0.32 -1.01 -1.09 -0.73 -0.61 0.63
2 11 5 9 0.36 -0.51 -0.87 -0.64 0.06 -0.61 0.87
2 11 6 52 0.48 -0.79 -0.86 -0.61 -0.72 -0.61 0.27
2 11 7 15 0.51 -0.07 -0.81 -0.58 -0.72 -0.61 -0.31
2 11 8 13 0.47 -0.58 -0.85 -0.64 0.06 -0.61 0.07
2 11 9 48 0.82 -0.90 -0.87 -0.72 -0.79 0.55 0.28
2 11 10 41 0.86 -0.53 -0.84 -0.66 -0.59 0.55 0.84
2 11 11 45 0.39 -0.42 -0.87 -0.66 -0.72 -0.61 0.11
2 11 12 5 0.38 0.79 -0.78 -0.55 -0.72 -0.61 0.37
2 11 13 19 0.27 -0.61 -0.78 -1.18 -1.11 -0.61 0.21
2 11 14 28 0.45 -0.70 -0.93 -1.08 -0.72 -0.61 0.14
2 11 15 31 1.09 -0.13 -0.81 -0.56 -0.47 0.55 0.03
2 12 1 9 0.69 -1.16 0.09 -0.67 -0.67 -0.61 -1.12
2 12 2 22 0.94 -1.29 -1.01 -1.12 -0.91 -0.61 -1.37
2 12 3 23 0.7 -1.47 -0.82 -0.08 -0.51 -0.61 -0.55
2 12 4 10 1.16 -0.31 -0.91 -0.45 0.06 -0.27 -1.03
2 12 5 22 0.94 -1.38 -0.70 0.05 -0.70 0.55 -0.58
2 12 6 15 0.51 -1.02 -0.78 0.25 -0.72 -0.61 -0.46
2 12 7 29 0.52 -0.65 -0.83 -0.77 -0.72 -0.61 -1.10
2 12 8 17 0.5 -0.88 -0.86 -1.16 -0.95 -0.61 -0.44
2 12 9 14 0.6 -1.58 -1.11 -1.14 -0.83 -0.61 -0.46
2 12 10 9 1.01 -1.35 -0.83 0.22 -0.46 -0.61 -1.30
2 12 11 30 0.52 -1.50 -0.84 -0.66 -0.73 -0.61 -0.53
2 12 12 24 0.54 -1.36 -0.85 -0.72 -0.72 -0.61 -1.10
2 12 13 11 0.86 -1.39 0.09 -0.28 -0.58 -0.61 -0.41
2 12 14 26 0.53 -0.72 -0.93 -0.64 -0.72 -0.61 -0.49
2 12 15 33 1.1 -1.05 -0.81 -0.82 -0.81 0.55 -0.89
2 13 1 14 1.36 1.29 0.92 3.23 1.52 0.47 0.13
2 13 2 5 2.06 0.57 -0.78 3.27 0.69 -0.15 0.17
2 13 3 6 0.38 1.17 -0.78 3.06 3.19 0.55 0.08
2 13 4 16 0.52 1.54 0.92 3.06 3.19 -0.54 0.10
2 13 5 10 0.16 1.19 -0.78 3.06 3.19 -0.61 -0.30
2 13 6 10 0.16 1.19 -0.78 3.06 3.19 -0.61 0.47
2 13 7 3 0.14 5.26 0.92 4.01 4.76 2.88 0.46
2 13 8 11 2.36 1.61 0.14 4.69 -0.08 -0.40 0.49
2 13 9 10 0.16 1.19 -0.78 3.06 3.19 -0.61 0.07
2 13 10 2 0.42 2.26 0.92 8.30 1.63 0.55 0.27
2 13 11 2 0.3 2.89 0.92 3.06 1.63 -0.61 -1.37
2 13 12 12 2.56 1.63 0.21 3.16 2.67 2.88 -0.73
2 13 13 9 1.39 3.40 0.08 3.38 1.63 -0.61 0.74
2 13 14 30 1.01 1.59 0.56 3.06 3.19 0.55 -0.86
2 13 15 29 0.48 1.29 -0.78 3.06 3.19 0.55 -0.91
2 14 1 2 1.34 1.17 2.67 3.06 0.85 -0.61 -0.11
2 14 2 3 0.33 1.99 2.67 3.06 3.19 0.55 0.08
2 14 3 10 0.33 1.99 2.67 3.06 3.19 -0.61 0.27
2 14 4 3 0.03 1.40 2.67 0.81 1.63 0.55 1.52
2 14 5 8 0.1 1.28 2.67 0.81 1.63 0.55 1.01
2 14 6 5 0.52 1.67 2.67 1.77 0.06 -0.61 -0.60
2 14 7 3 0.3 2.01 2.67 3.06 1.63 0.55 1.18
2 14 8 9 2.9 2.37 2.67 1.24 0.93 2.88 0.17
2 14 9 16 0.75 1.04 2.67 1.10 1.63 -0.61 0.08
2 14 10 9 0.39 1.46 2.67 0.82 1.63 -0.61 1.29
2 14 11 2 0.04 1.27 2.67 0.81 1.63 0.55 1.52
2 14 12 5 0.99 0.76 2.67 0.81 1.63 0.55 0.08
2 14 13 5 0.12 2.08 2.67 3.06 3.19 -0.61 -0.30
2 14 14 3 1.24 1.02 2.67 1.14 1.63 -0.23 -0.92
2 14 15 4 0.51 2.70 2.67 1.77 0.06 0.55 -0.54
2 15 1 12 0.91 -0.54 0.85 -0.19 0.06 -0.61 -0.18
2 15 2 17 1.09 -0.89 0.53 -0.46 -0.74 0.55 -0.44
2 15 3 14 0.83 -0.01 0.92 -0.63 -0.49 -0.61 -1.19
2 15 4 14 0.79 -0.68 0.92 -0.94 -0.77 -0.61 -1.33
2 15 5 22 0.54 -0.25 0.92 -1.16 -1.02 -0.61 -0.02
2 15 6 20 0.83 -0.73 0.79 0.12 -0.72 -0.61 -0.21
2 15 7 21 0.42 -0.83 0.92 -0.82 -0.72 -0.61 0.07
2 15 8 18 0.43 0.13 0.09 -0.67 -0.72 -0.61 -0.07
2 15 9 21 0.59 0.47 0.92 -0.59 -0.72 -0.61 -0.12
2 15 10 22 0.7 -0.67 0.09 -1.08 -0.97 -0.61 -0.03
2 15 11 19 0.73 -0.46 0.09 -0.66 -0.70 -0.61 -0.92
2 15 12 15 0.51 -1.13 0.92 -0.61 -0.72 -0.61 -0.70
2 15 13 19 1.19 -0.27 0.66 -0.78 -0.74 0.55 -0.08
2 15 14 14 1.39 -0.27 0.56 -0.77 -0.63 0.55 -1.18
2 15 15 22 0.67 -0.10 0.92 -0.45 -0.72 -0.61 -0.23
3 1 1 2 0.26 1.04 1.38 0.82 1.63 0.55 1.27
3 1 2 1 0 0.71 0.09 0.82 1.63 0.55 0.37
3 1 3 2 0.08 0.63 0.92 0.82 1.63 0.55 1.01
3 1 4 2 0.16 1.13 0.09 0.85 1.63 0.55 0.82
3 1 5 2 0.13 1.30 0.92 0.87 1.63 0.55 0.82
3 1 6 5 0.58 0.33 1.01 0.64 1.63 0.55 0.45
3 1 7 4 0.08 1.01 0.92 0.81 1.63 0.55 1.01
3 1 8 1 0 1.21 0.09 0.82 1.63 0.55 0.63
3 1 9 7 0.34 0.97 0.92 0.67 1.63 0.55 1.52
3 1 10 1 0 0.05 0.92 -0.08 1.63 0.55 1.52
3 1 11 8 0.21 0.88 0.92 0.84 1.63 0.55 0.44
3 1 12 1 0 1.04 0.09 0.82 1.63 0.55 0.50
3 1 13 2 0.26 0.54 0.09 0.82 1.63 0.55 1.27
3 1 14 2 0.07 0.32 0.92 0.82 1.63 0.55 1.01
3 1 15 3 0.25 0.97 0.92 0.31 1.63 0.55 0.93
3 2 1 0 NA NA NA NA NA NA NA
3 2 2 0 NA NA NA NA NA NA NA
3 2 3 0 NA NA NA NA NA NA NA
3 2 4 0 NA NA NA NA NA NA NA
3 2 5 0 NA NA NA NA NA NA NA
3 2 6 0 NA NA NA NA NA NA NA
3 2 7 0 NA NA NA NA NA NA NA
3 2 8 0 NA NA NA NA NA NA NA
3 2 9 0 NA NA NA NA NA NA NA
3 2 10 0 NA NA NA NA NA NA NA
3 2 11 0 NA NA NA NA NA NA NA
3 2 12 0 NA NA NA NA NA NA NA
3 2 13 0 NA NA NA NA NA NA NA
3 2 14 0 NA NA NA NA NA NA NA
3 2 15 0 NA NA NA NA NA NA NA
3 3 1 1 0 0.38 0.09 0.82 1.63 -0.61 1.52
3 3 2 2 0.23 1.09 0.92 0.85 1.63 -0.61 0.94
3 3 3 2 0.08 1.22 1.38 0.82 1.63 -0.61 1.01
3 3 4 1 0 0.80 0.92 0.82 1.63 -0.61 0.47
3 3 5 2 0.05 0.43 0.92 0.82 1.63 -0.61 0.47
3 3 6 3 0.09 0.68 0.92 0.82 1.63 -0.61 1.01
3 3 7 2 0.04 1.34 1.38 0.82 1.63 -0.61 1.52
3 3 8 3 0.09 0.68 0.92 0.82 1.63 -0.61 1.52
3 3 9 2 0.04 0.58 0.92 0.82 1.63 -0.61 0.47
3 3 10 2 0.04 1.01 0.92 0.82 1.63 -0.61 1.52
3 3 11 1 0 0.88 0.09 0.82 1.63 -0.61 1.52
3 3 12 2 0.08 0.96 1.38 0.82 1.63 -0.61 1.01
3 3 13 2 0.05 0.58 0.09 0.82 1.63 -0.61 1.52
3 3 14 1 0 0.80 0.09 0.82 1.63 -0.61 1.52
3 3 15 3 0.09 1.02 1.38 0.82 1.63 -0.61 1.52
3 4 1 1 0 1.21 0.09 0.46 1.63 -0.61 -1.08
3 4 2 1 0 1.38 0.92 0.46 1.63 -0.61 -1.08
3 4 3 2 0.08 0.71 0.92 0.82 1.63 -0.61 -0.30
3 4 4 1 0 0.48 0.92 1.73 1.63 -0.61 0.07
3 4 5 3 0.06 0.46 0.92 0.82 1.63 -0.61 -0.30
3 4 6 1 0 1.22 0.92 0.46 1.63 -0.61 -1.08
3 4 7 1 0 0.54 0.92 1.73 1.63 -0.61 0.07
3 4 8 1 0 0.63 0.92 1.73 1.63 -0.61 0.07
3 4 9 1 0 1.05 0.09 0.46 1.63 -0.61 -1.08
3 4 10 2 0.13 1.01 0.09 0.82 1.63 -0.61 -0.44
3 4 11 1 0 0.38 0.92 1.73 1.63 -0.61 0.07
3 4 12 1 0 0.80 0.92 1.73 1.63 -0.61 0.07
3 4 13 2 0.08 1.55 0.92 0.82 1.63 -0.61 -0.44
3 4 14 2 0 1.22 0.92 0.82 1.63 -0.61 -0.44
3 4 15 2 0.12 1.42 0.09 0.82 1.63 -0.61 -0.44
3 5 1 5 0.17 1.55 0.92 0.82 1.63 -0.61 0.12
3 5 2 2 0 1.22 0.92 0.82 1.63 -0.61 0.77
3 5 3 1 0 1.88 0.92 0.82 1.63 -0.61 -0.44
3 5 4 1 0 2.72 0.92 0.68 1.63 -0.61 0.04
3 5 5 2 0.05 1.09 0.92 0.82 1.63 -0.61 0.37
3 5 6 4 0.12 1.64 0.92 0.85 1.63 -0.61 0.82
3 5 7 3 0.13 1.27 0.92 0.82 1.63 -0.61 0.58
3 5 8 3 0.1 1.27 0.92 0.84 1.63 -0.61 0.04
3 5 9 2 0.15 2.21 0.92 0.68 1.63 -0.61 0.87
3 5 10 5 0.12 1.45 0.92 0.46 1.63 -0.61 0.08
3 5 11 2 0.11 1.26 0.92 0.82 1.63 -0.61 0.31
3 5 12 4 0.12 1.42 0.92 0.85 1.63 -0.61 0.82
3 5 13 5 0.13 1.55 0.92 0.82 1.63 -0.61 0.58
3 5 14 1 0 0.88 0.92 0.82 1.63 -0.61 0.37
3 5 15 3 0.3 1.94 0.92 0.77 1.63 -0.61 0.26
3 6 1 2 0.05 0.01 -0.78 1.73 1.63 0.55 -0.84
3 6 2 1 0 0.54 -0.78 1.73 1.63 0.55 -0.84
3 6 3 2 0.05 0.09 -0.78 1.73 1.63 0.55 -0.62
3 6 4 1 0 0.71 -0.78 1.73 1.63 0.55 -0.62
3 6 5 2 0 0.29 -0.78 1.73 1.63 0.55 -1.30
3 6 6 1 0 0.71 -0.78 1.73 1.63 0.55 -1.30
3 6 7 1 0 0.04 -0.78 1.73 1.63 0.55 -1.30
3 6 8 4 0.04 0.46 -0.78 1.73 1.63 0.55 -0.62
3 6 9 2 0.05 0.33 -0.78 1.73 1.63 0.55 -0.84
3 6 10 1 0 0.20 -0.78 1.73 1.63 0.55 -1.30
3 6 11 3 0.04 0.15 -0.78 1.73 1.63 0.55 -0.84
3 6 12 1 0 0.14 -0.78 1.73 1.63 0.55 -1.30
3 6 13 4 0.04 0.46 -0.78 1.73 1.63 0.55 -1.30
3 6 14 3 0.04 0.26 -0.78 1.73 1.63 0.55 -0.62
3 6 15 2 0.13 0.24 -0.78 1.73 1.63 0.55 0.07
3 7 1 2 0.08 1.74 0.92 0.85 1.63 0.55 -0.44
3 7 2 1 0 1.21 0.09 0.46 1.63 0.55 -1.08
3 7 3 3 0.11 0.55 0.92 0.81 1.63 0.55 -0.62
3 7 4 2 0.17 1.73 0.92 0.45 1.63 0.55 -0.44
3 7 5 3 0.25 1.33 0.92 0.71 1.63 0.55 -0.44
3 7 6 3 0.09 1.02 0.92 0.81 1.63 0.55 -0.30
3 7 7 1 0 1.38 0.92 0.46 1.63 0.55 -1.08
3 7 8 1 0 0.54 0.92 0.82 1.63 0.55 -0.30
3 7 9 1 0 0.38 0.92 0.81 1.63 0.55 -1.30
3 7 10 3 0.11 1.05 0.92 -0.08 1.63 0.55 -0.44
3 7 11 1 0 0.55 0.92 0.81 1.63 0.55 -1.30
3 7 12 2 0.08 0.47 0.92 0.81 1.63 0.55 0.07
3 7 13 1 0 0.72 0.92 0.81 1.63 0.55 0.07
3 7 14 2 0.32 0.13 1.15 0.34 1.63 0.55 -0.30
3 7 15 2 0.32 1.13 0.09 0.82 1.63 0.55 -0.20
3 8 1 6 0.19 0.75 -0.78 0.82 1.63 -0.61 -0.42
3 8 2 4 0.06 0.94 -0.78 0.82 1.63 -0.61 0.04
3 8 3 2 0.08 0.46 -1.20 0.46 1.63 -0.61 -1.08
3 8 4 2 0.12 0.92 -1.20 0.82 1.63 -0.61 0.24
3 8 5 1 0 1.55 -0.78 0.82 1.63 -0.61 0.24
3 8 6 4 0.17 0.79 -0.78 0.46 1.63 -0.61 -1.08
3 8 7 4 0.09 1.17 -0.78 0.46 1.63 -0.61 0.08
3 8 8 3 0.06 0.88 -0.78 0.82 1.63 -0.61 0.24
3 8 9 3 0.09 1.24 -0.78 0.82 1.63 -0.61 -0.44
3 8 10 4 0.09 0.67 -1.20 0.46 1.63 -0.61 0.08
3 8 11 6 0.11 0.80 -0.78 0.46 1.63 -0.61 0.08
3 8 12 6 0.16 1.22 -0.78 0.82 1.63 -0.61 0.14
3 8 13 3 0.06 0.71 -1.20 0.82 1.63 -0.61 0.04
3 8 14 4 0.21 0.71 -1.20 0.82 1.63 -0.61 -0.44
3 8 15 2 0.05 0.75 -0.78 0.82 1.63 -0.61 0.04
3 9 1 2 0.03 0.51 0.92 1.73 1.63 0.55 -1.30
3 9 2 1 0 0.54 0.92 1.73 1.63 0.55 0.07
3 9 3 1 0 0.38 0.92 2.16 1.63 0.55 -1.30
3 9 4 2 0.07 0.30 0.09 1.73 1.63 0.55 -0.84
3 9 5 2 0.05 0.51 0.09 1.73 1.63 0.55 -0.62
3 9 6 2 0.08 0.63 0.09 1.73 1.63 0.55 -1.30
3 9 7 1 0 0.54 0.09 1.73 1.63 0.55 -0.84
3 9 8 5 0.12 1.07 0.92 1.73 1.63 0.55 -0.62
3 9 9 1 0 0.38 0.92 1.73 1.63 0.55 -1.30
3 9 10 2 0.04 0.67 0.09 1.73 1.63 0.55 -0.62
3 9 11 3 0.06 0.38 0.09 1.73 1.63 0.55 -1.30
3 9 12 1 0 0.88 0.09 1.73 1.63 0.55 -0.62
3 9 13 1 0 0.80 0.92 1.73 1.63 0.55 -1.30
3 9 14 1 0 0.63 0.92 1.73 1.63 0.55 -1.30
3 9 15 5 0.18 0.41 0.92 1.75 1.63 0.55 -0.84
3 10 1 3 0.06 0.55 -0.78 0.82 1.63 -0.61 0.53
3 10 2 8 0.14 0.79 -0.78 0.85 1.63 -0.61 0.82
3 10 3 5 0.1 0.81 -0.78 0.82 1.63 -0.61 0.60
3 10 4 4 0.1 1.17 -0.78 0.82 1.63 -0.61 0.56
3 10 5 4 0.12 0.58 -1.20 0.85 1.63 -0.61 0.82
3 10 6 4 0.12 0.80 -1.20 0.85 1.63 -0.61 0.82
3 10 7 3 0.15 0.57 -0.78 0.84 1.63 -0.61 0.88
3 10 8 2 0.04 1.26 -0.78 0.87 1.63 -0.61 0.87
3 10 9 3 0.13 0.43 -1.20 0.82 1.63 -0.61 0.68
3 10 10 5 0.11 1.00 -0.78 0.84 1.63 -0.61 0.81
3 10 11 3 0.11 1.16 -0.78 0.84 1.63 -0.61 0.80
3 10 12 6 0.17 0.77 -1.20 0.82 1.63 -0.61 0.56
3 10 13 4 0.09 0.98 -0.78 0.82 1.63 -0.61 0.56
3 10 14 2 0.1 1.34 -0.78 0.82 1.63 -0.61 0.56
3 10 15 4 0.11 0.69 -0.78 0.82 1.63 -0.61 0.40
3 11 1 2 0.08 1.13 0.09 0.46 1.63 -0.61 0.08
3 11 2 3 0.12 1.13 0.09 0.86 1.63 -0.61 0.83
3 11 3 3 0.16 1.10 0.09 0.82 1.63 -0.61 0.11
3 11 4 3 0.14 0.99 0.09 0.82 1.63 -0.61 0.72
3 11 5 1 0 1.55 0.09 0.82 1.63 -0.61 0.50
3 11 6 2 0.04 1.43 0.09 0.87 1.63 -0.61 0.87
3 11 7 3 0.11 1.21 0.09 0.82 1.63 -0.61 0.54
3 11 8 3 0.06 1.38 0.09 0.82 1.63 -0.61 0.63
3 11 9 3 0.11 0.88 0.09 0.82 1.63 -0.61 0.41
3 11 10 1 0 1.71 0.09 0.82 1.63 -0.61 0.24
3 11 11 5 0.17 1.38 0.09 0.82 1.63 -0.61 0.12
3 11 12 2 0.08 0.63 0.09 0.82 1.63 -0.61 0.37
3 11 13 3 0.11 1.33 0.09 0.84 1.63 -0.61 0.80
3 11 14 3 0.06 1.38 0.09 0.46 1.63 -0.61 0.08
3 11 15 4 0.13 0.58 0.09 0.82 1.63 -0.61 1.01
3 12 1 1 0 0.37 -0.78 0.82 1.63 0.55 1.52
3 12 2 1 0 0.63 -0.78 0.82 1.63 -0.61 1.52
3 12 3 1 0 -0.13 -1.20 0.82 1.63 -0.61 1.01
3 12 4 1 0 0.38 -1.20 0.87 1.63 -0.61 0.87
3 12 5 2 0.26 0.03 -1.20 0.82 1.63 0.55 1.27
3 12 6 2 0.04 0.33 -1.20 0.82 1.63 -0.61 1.01
3 12 7 1 0 0.21 -0.78 0.82 1.63 -0.61 1.52
3 12 8 1 0 0.21 -0.78 0.82 1.63 -0.61 1.01
3 12 9 2 0.05 0.08 -1.20 0.82 1.63 -0.61 1.01
3 12 10 2 0.05 0.41 -0.78 0.82 1.63 -0.61 1.52
3 12 11 3 0.09 0.01 -1.20 0.82 1.63 -0.61 1.52
3 12 12 1 0 0.46 -0.78 0.82 1.63 -0.61 1.01
3 12 13 1 0 0.71 -0.78 0.82 1.63 -0.61 1.52
3 12 14 2 0.04 0.33 -1.20 0.82 1.63 -0.61 1.52
3 12 15 1 0 0.37 -0.78 0.82 1.63 -0.61 1.01
3 13 1 2 0.03 0.00 -0.78 0.82 1.63 -0.61 0.47
3 13 2 1 0 -0.13 -0.78 0.82 1.63 -0.61 0.47
3 13 3 2 0.08 0.12 -1.20 0.82 1.63 -0.61 0.37
3 13 4 5 0.09 0.43 -0.78 1.73 1.63 -0.61 0.07
3 13 5 4 0.07 0.40 -0.78 0.82 1.63 -0.61 0.40
3 13 6 3 0.06 -0.04 -0.78 0.82 1.63 -0.61 -0.30
3 13 7 1 0 0.55 -0.78 0.82 1.63 -0.61 0.04
3 13 8 3 0.15 0.49 -1.20 0.82 1.63 -0.61 0.29
3 13 9 3 0.25 0.43 -1.20 0.70 1.63 -0.61 0.05
3 13 10 6 0.08 0.24 -0.78 0.82 1.63 -0.61 -0.30
3 13 11 4 0.07 0.25 -0.78 0.82 1.63 -0.61 0.44
3 13 12 2 0.07 0.54 -0.78 0.82 1.63 -0.61 0.31
3 13 13 2 0 0.12 -0.78 0.82 1.63 -0.61 0.47
3 13 14 5 0.08 0.11 -0.78 1.73 1.63 -0.61 0.07
3 13 15 2 0.11 0.33 -1.20 0.82 1.63 -0.61 0.44
3 14 1 6 0.25 1.08 0.92 -0.07 1.63 0.55 0.72
3 14 2 2 0.26 1.21 0.09 0.64 1.63 0.55 0.16
3 14 3 3 0.3 1.51 0.92 0.84 1.63 0.55 0.11
3 14 4 4 0.32 1.83 0.92 0.63 1.63 0.55 0.34
3 14 5 4 0.08 1.22 0.92 -0.06 1.63 0.55 0.11
3 14 6 2 0.33 2.44 0.92 0.57 1.63 0.55 0.04
3 14 7 4 0.19 1.48 0.92 0.38 1.63 0.55 0.56
3 14 8 7 0.35 1.90 0.92 0.65 1.63 0.55 0.81
3 14 9 3 0.26 1.64 0.92 -0.07 1.63 0.55 0.66
3 14 10 4 0.16 0.89 0.92 -0.07 1.63 0.55 0.29
3 14 11 6 0.2 1.23 0.92 0.38 1.63 0.55 0.75
3 14 12 8 0.24 1.11 0.92 0.35 1.63 0.55 0.37
3 14 13 5 0.19 1.40 0.92 0.84 1.63 0.55 0.63
3 14 14 4 0.23 1.67 0.92 -0.06 1.63 0.55 0.10
3 14 15 5 0.23 1.42 0.92 0.40 1.63 0.55 0.10
3 15 1 3 0.19 0.99 -0.78 0.84 1.63 0.55 0.75
3 15 2 3 0.26 0.59 -0.78 0.84 1.63 0.55 0.88
3 15 3 3 0.24 0.71 -0.78 0.70 1.63 0.55 0.12
3 15 4 2 0.29 1.01 -0.78 -0.05 1.63 0.55 0.87
3 15 5 3 0.11 0.54 -1.20 0.84 1.63 0.55 0.75
3 15 6 3 0.14 0.40 -0.78 0.82 1.63 0.55 0.40
3 15 7 2 0.2 0.54 -1.20 0.64 1.63 0.55 0.06
3 15 8 5 0.65 0.88 -0.87 0.25 1.63 0.55 -1.08
3 15 9 3 0.13 0.76 -0.78 0.82 1.63 0.55 0.54
3 15 10 5 0.46 0.49 -0.87 0.82 1.63 0.55 -0.38
3 15 11 2 0.29 1.01 -0.78 -0.05 1.63 0.55 0.08
3 15 12 2 0.1 1.04 -0.78 0.82 1.63 0.55 0.14
3 15 13 3 0.23 0.43 -1.20 0.82 1.63 0.55 0.37
3 15 14 2 0.12 1.13 -0.78 0.45 1.63 0.55 0.06
3 15 15 1 0 0.03 -0.78 0.82 1.63 0.55 0.47
3 16 1 0 NA NA NA NA NA NA NA
3 16 2 0 NA NA NA NA NA NA NA
3 16 3 0 NA NA NA NA NA NA NA
3 16 4 0 NA NA NA NA NA NA NA
3 16 5 0 NA NA NA NA NA NA NA
3 16 6 0 NA NA NA NA NA NA NA
3 16 7 0 NA NA NA NA NA NA NA
3 16 8 0 NA NA NA NA NA NA NA
3 16 9 0 NA NA NA NA NA NA NA
3 16 10 0 NA NA NA NA NA NA NA
3 16 11 0 NA NA NA NA NA NA NA
3 16 12 0 NA NA NA NA NA NA NA
3 16 13 0 NA NA NA NA NA NA NA
3 16 14 0 NA NA NA NA NA NA NA
3 16 15 0 NA NA NA NA NA NA NA
3 17 1 1 0 -0.64 -1.20 0.33 0.06 0.55 1.01
3 17 2 1 0 -0.75 -0.78 -0.08 0.06 0.55 1.52
3 17 3 2 0.02 -0.46 -0.78 0.32 0.06 0.55 1.52
3 17 4 1 0 -0.68 -0.78 0.33 0.06 0.55 1.01
3 17 5 1 0 -0.97 -0.78 0.33 0.06 0.55 1.01
3 17 6 1 0 -0.46 -0.78 -0.08 0.06 0.55 1.52
3 17 7 1 0 -0.30 -0.78 0.33 0.06 0.55 1.52
3 17 8 2 0.17 -0.40 -0.78 0.85 0.06 0.55 1.52
3 17 9 1 0 -0.66 -0.78 -0.08 0.06 0.55 1.52
3 17 10 1 0 -0.46 -0.78 -0.08 0.06 0.55 1.01
3 17 11 1 0 -0.64 -1.20 0.33 0.06 0.55 1.52
3 17 12 1 0 -0.80 -0.78 0.33 0.06 0.55 1.52
3 17 13 1 0 -0.30 -0.78 0.33 0.06 0.55 1.01
3 17 14 1 0 -0.26 -0.78 0.33 0.06 0.55 1.52
3 17 15 1 0 -1.00 -0.78 0.33 0.06 0.55 1.52
3 18 1 1 0 0.07 -0.78 0.90 -0.72 0.55 0.63
3 18 2 2 0.13 0.12 -0.78 0.33 0.06 0.55 0.82
3 18 3 2 0.02 -0.36 -0.78 0.87 0.06 0.55 0.47
3 18 4 3 0.09 -0.14 -0.78 0.33 0.06 0.55 0.75
3 18 5 1 0 0.84 -0.78 -0.08 0.06 0.55 -0.44

Let’s check the compression summary to check how many cells in each level have hit the quantization error threshold

compressionSummaryTable(hvt.results3[[3]]$compression_summary)
segmentLevel noOfCells noOfCellsBelowQuantizationError percentOfCellsBelowQuantizationErrorThreshold
1 15 0 0
2 225 11 0.05
3 1905 1702 0.89

As it can be seen from compression summary table above that the quantization error for most of the cells in level 3 fall below quantization threshold. Hence we were succesfully able to compress 89% of the data.

hvtHmap(hvt.results3, 
        trainComputers, 
        child.level = 3,
        hmap.cols = "quant_error", 
        line.width = c(1.2,0.8,0.4),
        color.vec = c("#141B41","#6369D1","#D8D2E1"),
        palette.color = 6,
        show.points = T,
        centroid.size = 1.1)