predict.tree(object, newdata, type="vector", split=F, nwts, eps=1e-3)
"tree"
.
This is assumed to be the result of some function that produces
an object with the same named
components as that returned by the
tree
function.
formula(object)
must be present by name in
newdata
.
If missing, fitted values are returned.
FALSE
, cases with missing
values are dropped down the tree until a leaf is reached or a node for which
the attribute is missing, and that node is used for prediction. If
split = T
, cases with missing attributes are split into fractional
cases and dropped down each side of the split. The predicted values
are averaged over the fractions to give the prediction.
newdata
cases, used when predicting a tree.
type="vector"
:
newdata
down
object
.
For factor predictors, if an observation
contains a level not used to grow the tree, it is left at the deepest
possible node and
frame$yval
at that node is the prediction.
type="tree"
:
"tree"
is returned with new values
for
frame$n
and
frame$yval
.
If
newdata
does not contain a column for the response in the formula
the value of
frame$dev
will be
NA
, and if some values in the
response are missing, the some of the deviances will be
NA
.
type="class"
:
type="where"
:
This function is a method for the generic function for class tree. It can be invoked by calling for an object x of the appropriate class, or directly by calling regardless of the class of the object.
Ripley, B. D. (1996). Pattern Recognition and Neural Networks. Cambridge University Press, Cambridge.
ztree <- tree(kyphosis) zpreds <- predict(ztree)