data(iris)
iris2 <- cbind(iris, New = sample(letters[1:3], 150, TRUE))
# Fit the model with custom prior probabilities
nb <- naive_bayes(Species ~ ., data = iris2, prior = c(0.1, 0.3, 0.6))
# Visualize marginal distributions of two predictors
plot(nb, which = c("Sepal.Width", "Sepal.Length"), ask = TRUE)
# Visualize class conditional distributions corresponding to the first predictor
# with customized settings
plot(nb, which = 1, ask = FALSE, prob = "conditional",
arg.num = list(col = 1:3, lty = 1,
main = "Naive Bayes Plot", legend.position = "topright",
legend.cex = 0.55))
# Visualize class marginal distributions corresponding to the first predictor
# with customized settings
plot(nb, which = 1, ask = FALSE, prob = "marginal",
arg.num = list(col = 1:3, lty = 1,
main = "Naive Bayes Plot", legend.position = "topright",
legend.cex = 0.55))
# Visualize class marginal distribution corresponding to the predictor "new"
# with custom colours
plot(nb, which = "New", arg.cat = list(color = gray.colors(3)))
Run the code above in your browser using DataLab