infix_class_prob: Predict Method for Family of Naive Bayes Objects

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

Description

The infix operators %class% and %prob% are shorthands for performing classification and obtaining posterior probabilities, respectively.

Usage

1
2
lhs %class% rhs
lhs %prob% rhs

Arguments

lhs

object of class inheriting from "naive_bayes" and "*_naive_bayes" family.

rhs

dataframe or matrix for "naive_bayes" objects OR matrix for all "*_naive_bayes" objects.

Details

If lhs is of class inheriting from the family of the Naive Bayes objects and rhs is either dataframe or matrix then the infix operators %class% and %prob% are equivalent to:

Compared to predict(), both operators do not allow changing values of fine tuning parameters threshold and eps.

Value

Author(s)

Michal Majka, michalmajka@hotmail.com

See Also

predict.naive_bayes, predict.bernoulli_naive_bayes, predict.multinomial_naive_bayes, predict.poisson_naive_bayes, predict.gaussian_naive_bayes, predict.nonparametric_naive_bayes

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
### Fit the model
nb <- naive_bayes(Species ~ ., iris)

newdata <- iris[1:5,-5] # Let's pretend

### Classification
nb %class% newdata
predict(nb, newdata, type = "class")

### Posterior probabilities
nb %prob% newdata
predict(nb, newdata, type = "prob")

naivebayes documentation built on March 13, 2020, 1:31 a.m.