oblique.tree (version 1.1.1)

predict.oblique.tree: Predictions from Fitted Oblique Tree Object

Description

Returns predictions from a fitted oblique.tree object.

Usage

"predict"( object, newdata, type = c("vector", "tree", "class", "where"), eps = 1e-3, update.tree.predictions = FALSE, ...)

Arguments

object
Fitted model object of class oblique.tree. This is assumed to be the result of some function that produces an object with the same named components as that returned by oblique.tree.
newdata
Data frame containing the values at which predictions are required. The predictors referred to in the right side of formula(object) must be present by name in newdata. If missing, fitted values are returned.
type
Character string denoting how predictions are to be returned, i.e. class probabilities (default), a tree object, class predictions or predictions to leaf nodes.
eps
A lower bound for the probabilities, used if events of predicted probability zero occur in newdata when predicting a tree.
update.tree.predictions
Logical vector denoting whether tree predictions (frame$yval, frame$yprob, $where, $y etc) are updated when newdata is provided.
...
Further arguments passed to or from other methods.

Value

If type = "vector": a matrix of predicted class probabilities is returned. This object is obtained by dropping observations down object.If type = "tree": an object of class c("oblique.tree","tree") is returned with new values for frame$n and frame$dev.If type = "class": a factor of the predicted classes (that with highest posterior probability, with ties split randomly).If type = "where": the nodes the cases reach.

Details

This function is a method for the generic function predict() for objects of class c("oblique.tree","tree"). It can be invoked by calling predict(x) for an object x of the appropriate class or directly by calling predict.oblique.tree(x) regardless of the class of the object.

References

Truong. A (2009) Fast Growing and Interpretable Oblique Trees via Probabilistic Models

Ripley, B. D. (1996). Pattern Recognition and Neural Networks. Cambridge University Press, Cambridge. Chapter 7.

See Also

predict, oblique.tree.

Examples

Run this code
#grow an oblique tree to the Pima Indian dataset
data(Pima.tr, package = "MASS")
ob.tree <- oblique.tree(formula		= type~.,
			data		= Pima.tr,
			oblique.splits	= "on")
plot(ob.tree);text(ob.tree);title(main="Oblique Tree")

#predictions to in-sample data
#class probabilities for each observation
predict(ob.tree,type="vector")
#the tree itself
predict(ob.tree,type="tree")
#class predictions for each observation
predict(ob.tree,type="class")
#the leaf where each observation falls
predict(ob.tree,type="where")

#predictions to out-of-sample data
data(Pima.te, package = "MASS")
#class probabilities for each observation
predict(ob.tree,newdata=Pima.te,type="vector")
#the tree itself
predict(ob.tree,newdata=Pima.te,type="tree")
#class predictions for each observation
predict(ob.tree,newdata=Pima.te,type="class")
#the leaf where each observation falls
predict(ob.tree,newdata=Pima.te,type="where")

Run the code above in your browser using DataLab