gaussiannb.pred: Prediction with some naive Bayes classifiers

Description Usage Arguments Value Author(s) See Also Examples

View source: R/naive_bayes.R

Description

Prediction with some naive Bayes classifiers.

Usage

1
2
3
4
5
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

1
2
3
4
5
6
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)

Example output

Loading required package: Rcpp
Loading required package: RcppZiggurat

Rfast documentation built on Dec. 11, 2021, 9:59 a.m.