knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(guessthecorrelation) library(tidyverse)
train <- guess_the_correlation_dataset(root = "~/datasets", token = "kaggle.json", download = TRUE, split = "train") submition <- guess_the_correlation_dataset(root = "~/datasets", token = "kaggle.json", download = TRUE, split = "submition")
transform <- function(x) { x } plot_one_img <- function(idx) { train[idx]$x %>% transform() %>% as.array() %>% as_tibble() %>% rowid_to_column(var = "Y") %>% gather(key = "X", value = "value", -Y) %>% mutate(X = as.numeric(gsub("V", "", X))) %>% ggplot(aes(X, rev(Y), fill = value)) + geom_raster() + theme_void() + theme(legend.position = "none") + theme(aspect.ratio = 1) + ggtitle(glue::glue("corr: {round(train[idx]$y, 3)}")) + scale_fill_gradient(high = "white", low = "black") } library(patchwork) map(1:10, plot_one_img) %>% reduce(`+`) + plot_layout(ncol = 5)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.