parttree
parttree copied to clipboard
Voronoi tiling as a plotting option for random forests and boosted trees?
set.seed(42)
library(ranger) ## Random forests
library(ggforce) ## Voronoi tiling
#> Loading required package: ggplot2
dat = na.omit(palmerpenguins::penguins)
train_ids = sample.int(nrow(dat), 100)
rf_mod = ranger(species ~ flipper_length_mm + bill_length_mm, data=dat[train_ids,])
dat = cbind(dat, pred = predict(rf_mod, dat)$predictions)
ggplot(dat, aes(flipper_length_mm, bill_length_mm, group = -1L)) +
geom_voronoi_tile(aes(fill = pred), alpha = .3) +
geom_point(aes(col = species)) +
theme_minimal()
#> Warning: stat_voronoi_tile: dropping duplicated points

Created on 2022-05-31 by the reprex package (v2.0.1)