Description Usage Arguments Details Value Author(s) References See Also Examples
Plots an image representing the supplied MNIST digit
1 | show.digit(digit, col=gray(12:1/12), ...)
|
digit |
a digit from the |
col |
a vector of colors to represent the digit. See |
... |
further arguments passed to |
This function uses the image
graphics function to represent a digit in a plot window.
None
Xavier Robin
Freely inspired from https://gist.github.com/brendano/39760
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | data(mnist)
show.digit(mnist$test$x[1,])
show.digit(mnist$train$x[1,])
good.digits <- c(11, 3, 2, 91, 20, 188, 92, 1, 111, 13)
rainbow <- c("#FF0000FF", "#0000FFFF", "#964B00FF", "#FF00FFFF", "#00AAAAFF", "#00EE00FF", "#FFFFFFFF", "#000000FF", "#AAAAAAFF", "#FF9900FF")
alphas.gen <- expand.grid(c(0:9, LETTERS[1:6]), c(0:9, LETTERS[1:6]))
alphas <- paste(alphas.gen[,2], alphas.gen[,1], sep="")
circle.borders <- rep("black", 10)
circle.borders[c(2, 8)] <- "white"
layout(matrix(1:16, 4, 4))
par(cex=1.5)
sapply(1:10, function(i) {show.digit(mnist$test$x[good.digits[i],], col=paste(substring(rainbow[ifelse(i == 7, 8, i)], 1, 7), if (i ==7) rev(alphas) else alphas, sep=""))})
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.