Created
December 3, 2014 19:55
-
-
Save mikelove/ee98799eaa0e6b15e55d to your computer and use it in GitHub Desktop.
som
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 <- 20^2 | |
p <- 4 | |
col <- rep(1:2,each=n/2) | |
x <- matrix(rnorm(n*p),ncol=p) | |
x[,1] <- c(rnorm(n/2,0,1),rnorm(n/2,4,.1)) | |
x[,2] <- c(rnorm(n/2,0,1),rnorm(n/2,4,.1)) | |
par(mfrow=c(2,2)) | |
plot(x[,1:2],col=col) | |
plot(prcomp(x)$x[,1:2],col=col,asp=1) | |
library(kohonen) | |
s <- som(data = x, grid = somgrid(sqrt(n), sqrt(n), "hexagonal")) | |
plot(s,type="counts") | |
plot(s,type="codes") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment