Prediction with some naive Bayes classifiers | R Documentation |
Prediction with some naive Bayes classifiers.
gaussiannb.pred(xnew, m, s, ni)
poissonnb.pred(xnew, m)
multinomnb.pred(xnew, m)
gammanb.pred(xnew, a, b)
geomnb.pred(xnew, prob)
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. |
A numerical vector with 1, 2, ... denoting the predicted group.
Michail Tsagris
R implementation and documentation: Michail Tsagris <mtsagris@uoc.gr> and Manos Papadakis <papadakm95@gmail.com>.
gaussian.nb, colpoisson.mle colVars
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.