Description Usage Arguments Details Value Side Effects See Also Examples
Plots an itree
object on the current graphics device. This is
based on the plotting function from rpart but modifies/extends
it in various ways to deal with some of itree
's capabilities.
1 2 3 |
x |
a fitted object of class |
uniform |
if |
branch |
controls the shape of the branches from parent to child node. Any number from 0 to 1 is allowed. A value of 1 gives square shouldered branches, a value of 0 give V shaped branches, with other values being intermediate. |
compress |
if |
nspace |
the amount of extra space between a node with children and
a leaf, as compared to the minimal space between leaves.
Applies to compressed trees only. The default is the value of
|
margin |
an extra fraction of white space to leave around the borders of the tree. (Long labels sometimes get cut off by the default computation). |
minbranch |
set the minimum length for a branch to |
highlight.color |
If the |
do_node_re |
Set to |
... |
arguments to be passed to or from other methods. |
This function is a method for the generic function plot
, for objects
of class itree
. The y-coordinate of the top node of the tree will always be 1.
The coordinates of the nodes are returned as a list, with
components x
and y
.
An unlabeled plot is produced on the current graphics device.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | #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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.