coef {naivebayes} | R Documentation |
Extract Model Coefficients
Description
coef
is a generic function which extracts model coefficients from specialized Naive Bayes objects.
Usage
## S3 method for class 'bernoulli_naive_bayes'
coef(object, ...)
## S3 method for class 'multinomial_naive_bayes'
coef(object, ...)
## S3 method for class 'poisson_naive_bayes'
coef(object, ...)
## S3 method for class 'gaussian_naive_bayes'
coef(object, ...)
Arguments
object |
object of class inheriting from |
... |
not used. |
Value
Coefficients extracted from the specialised Naive Bayes objects in form of a data frame.
Author(s)
Michal Majka, michalmajka@hotmail.com
See Also
bernoulli_naive_bayes
, multinomial_naive_bayes
, poisson_naive_bayes
, gaussian_naive_bayes
Examples
data(iris)
y <- iris[[5]]
M <- as.matrix(iris[-5])
### Train the Gaussian Naive Bayes
gnb <- gaussian_naive_bayes(x = M, y = y)
### Extract coefficients
coef(gnb)
coef(gnb)[c(TRUE,FALSE)] # only means
coef(gnb)[c(FALSE,TRUE)] # only standard deviations
[Package naivebayes version 1.0.0 Index]