bernoulli.nb: Naive Bayes classifier for binary Bernoulli data

View source: R/naive.bayes.classifiers.R

Naive Bayes classifier for binary (Bernoulli) dataR 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.

See Also

bernoullinb.pred, nb.cv

Examples

x <- matrix( rbinom(50 * 4, 1, 0.5), ncol = 4 )
ina <- rbinom(50, 1, 0.5) + 1
a <- bernoulli.nb(x, x, ina)

Rfast2 documentation built on Aug. 8, 2023, 1:11 a.m.