Skip to content

Instantly share code, notes, and snippets.

@dengemann
Created December 25, 2020 21:56
Show Gist options
  • Save dengemann/47599a4b8176b8f761acaca3ed3ceb96 to your computer and use it in GitHub Desktop.
Save dengemann/47599a4b8176b8f761acaca3ed3ceb96 to your computer and use it in GitHub Desktop.
# License: BSD (3-clause)
# Author: Denis A. Engemann <[email protected]>
library(ggplot2)
library(tidymodels)
library(readr)
library(wesanderson)
hotels <-
read_csv('https://tidymodels.org/start/case-study/hotels.csv') %>%
mutate_if(is.character, as.factor)
dat <- list.files(pattern = "*.csv") %>%
map_df(read_csv)
dat$n_cores <- dat$expr %>%
substr(7, 7) %>%
as.numeric()
dat$machine <- case_when(
dat$os == "macOS Catalina 10.15.6" ~ "MBP-15 2017 i7",
dat$os == "macOS 11.1" ~ "MBA 2020 M1",
dat$os == "macOS Big Sur 10.16" ~ "MBA 2020 M1",
)
dat$label <- paste(dat$machine, dat$arch)
n_samp <- nrow(hotels) * 0.8
title <-
sprintf("Hotels, n=%d, RF (ranger) mtry=8, min_n=7, trees=100",
n_samp)
dat %>%
mutate_if(is.character, as.factor) %>%
ggplot(aes(x = n_cores, y = time / 1e9, color = label)) +
geom_jitter() +
geom_smooth(show.legend = F) +
theme_classic() +
theme(legend.position = c(0.8, 0.8),
text = element_text(size = 14, family = "Helvetica")) +
scale_y_continuous(breaks = 1:12) +
labs(x = "Number of CPUs", y = "Time [sec.]",
title = title) +
scale_color_manual(
values = wes_palette(n = 5, name = "Zissou1")[c(1, 3, 5)])
ggsave("ranger_bench.png", dpi = 300)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment