# bernoulli.nb: Naive Bayes classifier for binary Bernoulli data In Rfast2: A Collection of Efficient and Extremely Fast R Functions II

 Naive Bayes classifier for binary (Bernoulli) data R Documentation

## Naive Bayes classifier for binary Bernoulli data

### Description

Naive Bayes classifier for binary (Bernoulli) data.

### Usage

``````bernoulli.nb(xnew = NULL, x, ina)
``````

### Arguments

 `xnew` A numerical matrix with new predictor variables whose group is to be predicted. Each column contains binary (0 or 1) data. `x` A numerical matrix with observed predictor variables. Each column contains binary (0 or 1) data. `ina` A numerical vector with strictly positive numbers, i.e. 1,2,3 indicating the groups of the dataset. Alternatively this can be a factor variable.

### Details

Each column is supposed to contain binary data. Thus, for each column a Berboulli distributions is fitted. The product of the densities is the joint multivariate distribution.

### Value

A list including:

 `pi` A matrix with the estimated probabilities of each group and variable. `ni` The sample size of each group in the dataset. `est` The estimated group of the xnew observations. It returns a numerical value back regardless of the target variable being numerical as well or factor. Hence, it is suggested that you do \"as.numeric(ina)\" in order to see what is the predicted class of the new data.

### Author(s)

Michail Tsagris.

R implementation and documentation: Michail Tsagris mtsagris@uoc.gr.

` bernoullinb.pred, nb.cv `
``````x <- matrix( rbinom(50 * 4, 1, 0.5), ncol = 4 )