Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Voronoi tiling as a plotting option for random forests and boosted trees? #13

Open
grantmcdermott opened this issue May 31, 2022 · 0 comments

Comments

@grantmcdermott
Copy link
Owner

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant