Describing the problem - Tree Example

PD profile for \(X^1\) for the regression tree.

tree_pdp <-
  same_group_df |>
  transform(tree_hat = predict(tree_model),
            x1c_tree = cut(x1, tree_x1_breaks)) |>
  aggregate(x = tree_hat ~ x1c_tree,
            FUN = \(x) mean(x) |> round(digits = 1))

names(tree_pdp)[2] <- "profile"

tree_pdp
##        x1c_tree profile
## 1     (0,0.177]     0.2
## 2 (0.177,0.597]     0.8
## 3     (0.597,1]     1.5