predict.nb2: Prediction for Extended Naive Bayes (nb2)

Description Usage Arguments Author(s) See Also Examples

Description

Modified and extended copy of predict.naiveBayes from e1071.

Usage

1
2
3
## S3 method for class 'nb2'
predict(object, newdata, type = c("class", "raw"),
  threshold = 0.001, eps = 0, ...)

Arguments

object

An object of class "nb2".

newdata

A dataframe with new predictors (with possibly fewer columns than the training data). Note that the column names of newdata are matched against the training data ones.

type

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

threshold

Value replacing cells with probabilities within eps range.

eps

double for specifying an epsilon-range to apply laplace smoothing (to replace zero or close-zero probabilities by theshold.)

...

Currently ignored.

Author(s)

See Also

nb2, update.nb2, plot.nb2, print.nb2

Examples

1
2
3
4
5
6
7
8
9
mod <- nb2(iris[, 1:4], iris[, 5])
predict(mod, iris)

discParam <- list(Sepal.L = c(5, 6, 7), Sepal.W = c(2.5, 3.5))
mod2 <- nb2(iris[, 1:4], iris[, 5], discretize = "fixed", discParam = discParam)
predict(mod2, iris)

c(mean(predict(mod, iris) == iris$Species),
  mean(predict(mod2, iris) == iris$Species))

aschersleben/NBCD documentation built on May 12, 2019, 4:32 a.m.