predict.naiveBayes {e1071}R Documentation

Naive Bayes Classifier

Description

Computes the conditional a-posterior probabilities of a categorical class variable given independent categorical predictor variables using the Bayes rule.

Usage

predict.naiveBayes(object, newdata, type = c("class", "raw"), threshold = 0.001, ...)

Arguments

object An object of class "naiveBayes".
newdata A dataframe with new predictors.
type see value.
threshold Value replacing cells with 0 probabilities.
... Currently not used.

Details

For attributes with missing values, the corresponding conditional probabilities are omitted for prediction.

Value

If type = "raw", the conditional a-posterior probabilities for each class are returned, and the class with maximal probability else.

Author(s)

David Meyer david.meyer@ci.tuwien.ac.at

See Also

naiveBayes

Examples

data(HouseVotes84)
model <- naiveBayes(Class ~ ., data = HouseVotes84)
predict(model, HouseVotes84[1:10,-1])
predict(model, HouseVotes84[1:10,-1], type = "raw")

pred <- predict(model, HouseVotes84[,-1])
table(pred, HouseVotes84$Class)

data(Titanic)
m <- naiveBayes(Survived ~ ., data = Titanic)
m
predict(m, as.data.frame(Titanic)[,1:3])

[Package Contents]