#the rpart example:
fit <- itree(Price ~ Mileage + Type + Country, cu.summary)
plot(fit, compress=TRUE)
text(fit, use.n=TRUE)
### new to itree, plotting node risk:
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)
#plot using highlighting for one-sided methods:
purity.tree <- itree(medv~.,BostonHousing,minsplit=25,minbucket=25,cp=0,method="purity")
plot(purity.tree,highlight.color="blue")
text(purity.tree)
Run the code above in your browser using DataLab