cols <- 10 ; rows <- 100
M <- matrix(rpois(rows * cols, lambda = 3), nrow = rows, ncol = cols)
# is.integer(M) # [1] TRUE
y <- factor(sample(paste0("class", LETTERS[1:2]), rows, TRUE))
colnames(M) <- paste0("V", seq_len(ncol(M)))
laplace <- 0
### Train the Poisson Naive Bayes
pnb <- poisson_naive_bayes(x = M, y = y, laplace = laplace)
### Classification
head(predict(pnb, newdata = M, type = "class"))
head(pnb %class% M)
### Posterior probabilities
head(predict(pnb, newdata = M, type = "prob"))
head(pnb %prob% M)
Run the code above in your browser using DataLab