View source: R/get_tree_preds.R
get_tree_preds | R Documentation |
Get predictions from the individual trees in a random forest
get_tree_preds(data, rf)
data |
data frame with feature values for observations to obtain predictions |
rf |
random forest model fit using randomForest |
# Load the Palmer penguins data
library(palmerpenguins)
penguins <- na.omit(penguins)
# Fit a random forest
set.seed(71)
penguin_rf <-
randomForest::randomForest(
species ~ bill_length_mm + bill_depth_mm + flipper_length_mm + body_mass_g,
data = penguins,
ntree = 10
)
# Extract tree data corresponding to the first five
# observations in the data
get_tree_preds(penguins[1,], penguin_rf)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.