get_tree_preds: Get predictions from the individual trees in a random forest

View source: R/get_tree_preds.R

get_tree_predsR Documentation

Get predictions from the individual trees in a random forest

Description

Get predictions from the individual trees in a random forest

Usage

get_tree_preds(data, rf)

Arguments

data

data frame with feature values for observations to obtain predictions

rf

random forest model fit using randomForest

Examples


# 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)

goodekat/TreeTracer documentation built on April 19, 2023, 7:44 p.m.