Description Usage Arguments Value Examples
View source: R/holdoutNodePerformance.R
Takes point-wise estimates of loss at each observation used to fit a tree and aggregates them over the leaf nodes in the tree.
1 | estNodeRisk(tree.obj,est_observation_loss)
|
tree.obj |
An itree object whose nodes we wish to have risk estimates for. |
est_observation_loss |
A vector of estimated loss for each observation used to fit
|
List with elements:
est.risk
is a vector of length equal to number of leaf nodes in tree.obj
, each element is
an estimate of out-of-sample risk at a particular node in tree.obj
. This is computed
by averaging the OOB losses over observations in that node. The order of est.risk
is
such that its first element corresponds to the first row that is a leaf node in tree.obj$frame
.
est.risk[2] corresponds to the second row that is a leaf node in tree.obj$frame
, and so on.
sd.loss
= sd of the estimated losses for observations belonging to each node.
In the same order as est.risk
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | require(mlbench); data(BostonHousing)
#fit a tree:
cart <- itree(medv~.,BostonHousing,minsplit=25,minbucket=25,cp=0)
#generate theta-hat values by computing average out-of-bag loss:
## Not run:
#don't run because of time to do bootstrap sampling...
theta_hats <- getOOBLoss(model_tree.obj=cart.bh,data=bh,nboot=100)
# Then for each leaf we estimate local risk by the mean in-node theta-hat.
lre <- estNodeRisk(tree.obj=cart.bh,est_observation_loss=theta_hats$avgOOBloss)
# to add the lre to the plot:
plot(cart.bh, do_node_re= TRUE, uniform=TRUE)
text(cart.bh, est_node_risk = lre)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.