Learn R Programming

naivebayes (version 1.0.0)

coef: Extract Model Coefficients

Description

coef is a generic function which extracts model coefficients from specialized Naive Bayes objects.

Usage

# S3 method for bernoulli_naive_bayes
coef(object, ...)

# S3 method for multinomial_naive_bayes coef(object, ...)

# S3 method for poisson_naive_bayes coef(object, ...)

# S3 method for gaussian_naive_bayes coef(object, ...)

Value

Coefficients extracted from the specialised Naive Bayes objects in form of a data frame.

Arguments

object

object of class inheriting from "*_naive_bayes".

...

not used.

Author

Michal Majka, michalmajka@hotmail.com

See Also

bernoulli_naive_bayes, multinomial_naive_bayes, poisson_naive_bayes, gaussian_naive_bayes

Examples

Run this code
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

Run the code above in your browser using DataLab