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

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

Returns predictions from a fitted oblique.tree object.

Usage

1
2
3
4
5
6
7
8
## S3 method for class 'oblique.tree'
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.

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.

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.

Author(s)

A. Truong

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

 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
#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")

oblique.tree documentation built on April 15, 2017, 4:38 a.m.