Last active
April 6, 2024 01:11
-
-
Save mikelove/74bbf5c41010ae1dc94281cface90d32 to your computer and use it in GitHub Desktop.
Exploring behavior of t-SNE on linear data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n <- 200 | |
m <- 40 | |
set.seed(1) | |
x <- runif(n, -1, 1) | |
library(rafalib) | |
bigpar(2,2,mar=c(3,3,3,1)) | |
library(RColorBrewer) | |
cols <- brewer.pal(11, "Spectral")[as.integer(cut(x, 11))] | |
plot(x, rep(0,n), ylim=c(-1,1), yaxt="n", xlab="", ylab="", | |
col=cols, pch=20, main="underlying data") | |
library(pracma) | |
ortho <- rortho(m) | |
X <- cbind(x, matrix(0,ncol=m-1,nrow=n)) %*% ortho | |
plot(X[,1:2], asp=1, col=cols, pch=20, xlab="", ylab="", main="embed in higher dim") | |
pc <- prcomp(X) | |
plot(pc$x[,1:2], asp=1, col=cols, pch=20, xlab="", ylab="", main="PC1 & PC2") | |
library(tsne) | |
res <- tsne(X) | |
plot(res, col=cols, pch=20, xlab="", ylab="", main="t-SNE") | |
bigpar(2,2,mar=c(3,3,1,1)) | |
for (i in 2:5) { | |
set.seed(i) | |
x <- runif(n, -1, 1) | |
cols <- brewer.pal(11, "Spectral")[as.integer(cut(x, 11))] | |
ortho <- rortho(m) | |
X <- cbind(x, matrix(0,ncol=m-1,nrow=n)) %*% ortho | |
res <- tsne(X) | |
plot(res, col=cols, pch=20, xlab="", ylab="") | |
} |
@JerryDing Im sorry but I fail to see any different in your change. What's different?
The change you proposed where change in github but, at least for me, the change is just a copy of what was already there.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The fix proposed by @JerryDing has been incorporated into
tsne
package v0.1.3 by @jdonaldson here:https://github.com/jdonaldson/rtsne
and has been sent to CRAN.