Description Usage Arguments Value Examples
View source: R/holdoutNodePerformance.R
Uses bootstrap sampling to get average loss for each observation. We do this
by averaging out-of-bag loss over a number of runs for each data point. Each in-sample
tree is fit using the same settings as model_tree.obj
.
1 2 3 |
model_tree.obj |
An |
data |
A data frame – we construct risk estimates for each row of in this frame by looking at average out-of-bag loss. |
nboot |
Number of bootrap/cross-validation runs. |
sampleFcn |
Any function that takes a vector of indices (1,...,N) where
|
minsplit |
Specifies the |
minbucket |
Same as |
lossfcn |
A function that takes two vectors, |
A list with elements:
bagpred
= Average predictions for all N observations over all nboot
runs. For
classification it is the most common class.
holdout.predictions
= An N x nboot
matrix with holdout predictions
for each run along the columns. If observation i
is in the learning sample for run j, then
holdout.predicitions[i,j]
is NA
.
avgOOBloss
= N x 1
vector of average OOB loss.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | 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:
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.