Database Reference
In-Depth Information
Next, use the predict function to generate predictions from a fitted rpart object.
The format of the predict function follows.
predict(object, newdata = list(),
type = c("vector", "prob", "class", "matrix"))
Parameter type is a character string denoting the type of the predicted value. Set
it to either prob or class to predict using a decision tree model and receive the
result as either the class probabilities or just the class. The output shows that one
instance is classified as Play = no , and zero instances are classified as Play = yes .
Therefore, in both cases, the decision tree predicts that the play decision of the
testing set is not to play.
predict(fit,newdata=newdata,type="prob")
no yes
1 1 0
predict(fit,newdata=newdata,type="class")
1
no
Levels: no yes
Search WWH ::




Custom Search