-
-
Save mikelove/74bbf5c41010ae1dc94281cface90d32 to your computer and use it in GitHub Desktop.
| 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="") | |
| } |
Well, there is a bug in the tsne package:
gains = (gains + .2) * abs(sign(grads) != sign(incs))
+ gains * .8 * abs(sign(grads) == sign(incs))
change it to
gains = (gains + .2) * abs(sign(grads) != sign(incs)) + gains * .8 * abs(sign(grads) == sign(incs))
Also, for the MOG case, you need to set the parameter whiten=FALSE. Then you can get the correct results:
Have these changes been committed?
Could any help me interpreting the pattern behind the tsne plots?I have done on a small dataset I have clusters .Which I have hard time interpreting...
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.
@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.



How about this mixture of Gaussians example.