The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.
In this vignette, we consider a novel graph embedding method, Vicus (Wang B 2017).
Here, we use the Swiss roll data, which is a well known toy model.
set.seed(1)
<- 300
N <- sqrt(2 + 2 * seq(-1, 1 - 2 / N, 2 / N))
p <- 2 * runif(N, -1, 1)
y <- cbind(p * cos(2 * pi * p), y, p * sin(2 * pi * p))
X <- scale(X, center=TRUE, scale=TRUE) * 3
X <- c(rep(1:11, each = floor(N / 11)), rep(11, length=3)) labelX
library("scatterplot3d")
# Color Setting
<- labelX
colors <- c("#9E0142", "#D53E4F", "#F46D43", "#FDAE61",
cols "#FEE08B", "#FFFFBF", "#E6F598", "#ABDDA4",
"#66C2A5", "#3288BD", "#5E4FA2")
for(i in seq_along(cols)){
which(colors == i)] <- cols[i]
colors[
}
<- par("cex")
oldpar par(cex = 1.2)
scatterplot3d(X, color=colors, pch=16, main="Original Data", angle=40)
The Vicus
package provides three types of graph
embedding algorithms: Vicus
, Laplacian Eigenmaps
(LEM
), and Hessian Locally Linear Embedding
(HLLE
).
First, the graphMatrix
function computes a matrix
containing graph information for each algorithm:
library("Vicus")
<- graphMatrix(X, algorithm="Vicus", ndim=2, K=10)
objVicus <- graphMatrix(X, algorithm="LEM", ndim=2, K=10)
objLEM <- graphMatrix(X, algorithm="HLLE", ndim=2, K=5)
objHLLE str(objVicus, 2)
## List of 3
## $ M :Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
## $ algorithm: chr "Vicus"
## $ ndim : num 2
str(objLEM, 2)
## List of 3
## $ M :Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
## $ algorithm: chr "LEM"
## $ ndim : num 2
str(objHLLE, 2)
## List of 3
## $ M :Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
## $ algorithm: chr "HLLE"
## $ ndim : num 2
Next, the embedding
function performs eigenvalue
decomposition and estimates the low-dimensional coordinates.
<- embedding(objVicus)
outVicus <- embedding(objLEM)
outLEM <- embedding(objHLLE) outHLLE
The low dimensional coordinates show that Vicus is better able to capture the local structure of the Swiss roll data.
layout(t(1:3))
plot(outVicus, col=colors, pch=16, main="Vicus", cex=2)
plot(outLEM, col=colors, pch=16, main="LEM", cex=2)
plot(outHLLE, col=colors, pch=16, main="HLLE", cex=2)
It can also be embedded to any dimension by simply changing the value
of ndim
as follows:
<- graphMatrix(X, algorithm="Vicus", ndim=3)
objVicus_3D <- graphMatrix(X, algorithm="LEM", ndim=3)
objLEM_3D <- graphMatrix(X, algorithm="HLLE", ndim=3) objHLLE_3D
The following step is the same as in 2D Embedding case above.
<- embedding(objVicus_3D)
outVicus_3D <- embedding(objLEM_3D)
outLEM_3D <- embedding(objHLLE_3D) outHLLE_3D
layout(cbind(1:2, 3:4))
scatterplot3d(X, color=colors, pch=16, main="Original Data", angle=40)
scatterplot3d(outVicus_3D, color=colors, pch=16, main="Vicus", angle=40)
scatterplot3d(outLEM_3D, color=colors, pch=16, main="LEM", angle=70)
scatterplot3d(outHLLE_3D, color=colors, pch=16, main="HLLE", angle=70)
par(cex = oldpar)
## R version 3.6.3 (2020-02-29)
## Platform: x86_64-conda-linux-gnu (64-bit)
## Running under: CentOS Linux 7 (Core)
##
## Matrix products: default
## BLAS/LAPACK: /home/koki/miniconda3/lib/libopenblasp-r0.3.17.so
##
## locale:
## [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
## [3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
## [5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
## [7] LC_PAPER=en_US.UTF-8 LC_NAME=C
## [9] LC_ADDRESS=C LC_TELEPHONE=C
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] Vicus_0.99.0 scatterplot3d_0.3-43
##
## loaded via a namespace (and not attached):
## [1] Rcpp_1.0.8 RANN_2.6.1 lattice_0.20-45 digest_0.6.29
## [5] RSpectra_0.16-0 grid_3.6.3 R6_2.5.1 jsonlite_1.8.0
## [9] magrittr_2.0.2 evaluate_0.15 highr_0.9 rlang_0.4.11
## [13] stringi_1.7.6 jquerylib_0.1.4 Matrix_1.4-0 bslib_0.3.1
## [17] rmarkdown_2.11 tools_3.6.3 stringr_1.4.0 xfun_0.29
## [21] yaml_2.3.5 fastmap_1.1.0 compiler_3.6.3 htmltools_0.5.2
## [25] knitr_1.37 sass_0.4.0
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.