library(knitr)
library(scatterplot3d)
library(Rtsne)
library(coRanking)
<- 1000
npoints
<- runif(npoints, 0, 2 * pi)
theta <- runif(npoints, -1, 0.8)
u
<- list()
data $x <- sqrt(1 - u ^ 2) * cos(theta)
data$y <- sqrt(1 - u ^ 2) * sin(theta)
data$z <- u
data$col <-
datargb(colorRamp(colors = c("red", "yellow", "green"))( (data$z + 1) / 2),
maxColorValue = 255)
<- as.data.frame(data, stringsAsFactors = F) data
The co-ranking matrix is a tool to assess the quality of a dimensionality reduciton.
The fishbowl data set consists of a sphere with a hole on top:
scatterplot3d(data$x, data$y, data$z,
xlab = "x", ylab = "y", zlab = "z",
color = data$col)
Dimensionality reductions:
<- list()
dim.red ## dim.red$isomap <- isomap(dist(data[c("x","y","z")]), k = 20)
## dim.red$kpca <- kpca(~x + y + z, data)
$tsne <- Rtsne(data[c("x", "y", "z")])
dim.red$pca <- princomp(data[c("x", "y", "z")])
dim.red## plot(dim.red$isomap$points, col = data$col)
## plot(rotated(dim.red$kpca), col = data$col)
plot(dim.red$tsne$Y, col = data$col,
xlab = "tsne I", ylab = "tsne II",
main = "t-SNE")
plot(dim.red$pca$scores, col = data$col,
xlab = "PCA I", ylab = "PCA II",
main = "PCA")
the corresponding co-ranking matrices are:
<- coranking(data[c("x", "y", "z")], dim.red$tsne$Y)
Q.tsne <- coranking(data[c("x", "y", "z")], dim.red$pca$scores[, 1:2])
Q.pca imageplot(Q.tsne, main = "t-SNE")
imageplot(Q.pca, main = "PCA")