gaussiannb.pred: Prediction with some naive Bayes classifiers

View source: R/naive_bayes.R

Prediction with some naive Bayes classifiersR Documentation

Prediction with some naive Bayes classifiers

Description

Prediction with some naive Bayes classifiers.

Usage

gaussiannb.pred(xnew, m, s, ni)
poissonnb.pred(xnew, m)
multinomnb.pred(xnew, m)  
gammanb.pred(xnew, a, b)  
geomnb.pred(xnew, prob)  

Arguments

xnew

A numerical matrix with new predictor variables whose group is to be predicted. For the Gaussian case this contains any numbers, but for the multinomial and Poisson cases, the matrix must contain integer valued numbers only.

m

A matrix with the group means. Each row corresponds to a group.

s

A matrix with the group colum-wise variances. Each row corresponds to a group.

ni

A vector with the frequencies of each group.

a

A vector with the shape parameters of each group.

b

A vector with the scale parameters of each group.

prob

A vector with the sprobability parameters of each group.

Value

A numerical vector with 1, 2, ... denoting the predicted group.

Author(s)

Michail Tsagris

R implementation and documentation: Michail Tsagris <mtsagris@uoc.gr> and Manos Papadakis <papadakm95@gmail.com>.

See Also

gaussian.nb, colpoisson.mle colVars

Examples

ina <- sample(1:150, 100)
x <- as.matrix(iris[, 1:4])
id <- as.numeric(iris[, 5])
a <- gaussian.nb(xnew = NULL, x[ina, ], id[ina])
est <- gaussiannb.pred(x[-ina, ], a$mu, a$sigma, a$ni)
res<-table(id[-ina], est)

Rfast documentation built on Nov. 9, 2023, 5:06 p.m.