BinaryTree Class {party} | R Documentation |
A class for representing binary trees.
Objects can be created by calls of the form new("BinaryTree", ...)
.
The most important slot is tree
, a (recursive) list with elements
1
in the root node.variableID
(the
number of the input variable splitted), ordered
(a
logical whether the input variable is ordered),
splitpoint
(the cutpoint or set of levels to the left),
splitstatistics
saves the process of standardized
two-sample statistics the split point estimation is based on.
The logical toleft
determines if observations
go left or right down the tree. For nominal splits, the slot
table
is a vector being greater zero if the
corresponding level is available in the corresponding node.psplit
.Please note that this data structure may be subject to change in future releases of the package.
data
:ModelEnv
.responses
:"VariableFrame"
storing the values of the response variable(s). cond_distr_response
:predict_response
:tree
:where
:prediction_weights
:get_where
:
Class "BinaryTreePartition"
, directly.
response(object, ...)
:treeresponse(object, newdata = NULL, ...)
:Predict(object, newdata = NULL, ...)
:weights(object, newdata = NULL, ...)
:newdata = NULL
) and for new observations,
respectively.where(object, newdata = NULL, ...)
:newdata = NULL
) and for new observations,
respectively.nodes(object, where, ...)
:where
).plot(x, ...)
:BinaryTree
objects, see plot.BinaryTree
.print(x, ...)
:BinaryTree
objects.airq <- subset(airquality, !is.na(Ozone)) airct <- ctree(Ozone ~ ., data = airq, controls = ctree_control(maxsurrogate = 3)) ### distribution of responses in the terminal nodes plot(airq$Ozone ~ as.factor(where(airct))) ### get all terminal nodes from the tree nodes(airct, unique(where(airct))) ### extract weights and compute predictions pmean <- sapply(weights(airct), function(w) weighted.mean(airq$Ozone, w)) ### the same as drop(Predict(airct)) ### or unlist(treeresponse(airct)) ### don't use the mean but the median as prediction in each terminal node pmedian <- sapply(weights(airct), function(w) median(airq$Ozone[rep(1:nrow(airq), w)])) plot(airq$Ozone, pmean, col = "red") points(airq$Ozone, pmedian, col = "blue")