Last active
April 6, 2024 01:11
-
-
Save mikelove/74bbf5c41010ae1dc94281cface90d32 to your computer and use it in GitHub Desktop.
Revisions
-
mikelove revised this gist
Jun 1, 2016 . 1 changed file with 7 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -3,21 +3,22 @@ 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) -
mikelove created this gist
Jun 1, 2016 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ n <- 200 m <- 40 set.seed(1) x <- runif(n, -1, 1) library(rafalib) bigpar(2,2) library(RColorBrewer) cols <- brewer.pal(11, "Spectral")[as.integer(cut(x, 11))] plot(x, rep(0,n), ylim=c(-1,1), yaxt="n", ylab="", col=cols, pch=20) 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="dim1", ylab="dim2") pc <- prcomp(X) plot(pc$x[,1:2], asp=1, col=cols, pch=20) library(tsne) res <- tsne(X) plot(res, col=cols, pch=20, xlab="", ylab="") bigpar(2,2) 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="") }