train.bayes: train.bayes

Description Usage Arguments Value Note See Also Examples

View source: R/train.R

Description

Provides a wrapping function for the naiveBayes.

Usage

1
2

Arguments

formula

A formula of the form class ~ x1 + x2 + .... Interactions are not allowed.

data

Either a data frame of predictors (categorical and/or numeric) or a contingency table.

laplace

positive double controlling Laplace smoothing. The default (0) disables Laplace smoothing.

...

Currently not used.

subset

For data given in a data frame, an index vector specifying the cases to be used in the training sample. (NOTE: If given, this argument must be named.)

na.action

A function to specify the action to be taken if NAs are found. The default action is not to count them for the computation of the probability factors. An alternative is na.omit, which leads to rejection of cases with missing values on any required variable. (NOTE: If given, this argument must be named.)

Value

A object bayes.prmdt with additional information to the model that allows to homogenize the results.

Note

the parameter information was taken from the original function naiveBayes.

See Also

The internal function is from package naiveBayes.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
data("iris")

n <- seq_len(nrow(iris))
.sample <- sample(n, length(n) * 0.75)
data.train <- iris[.sample,]
data.test <- iris[-.sample,]

modelo.bayes <- train.bayes(Species ~., data.train)
modelo.bayes
prob <- predict(modelo.bayes, data.test, type = "prob")
prob
prediccion <- predict(modelo.bayes, data.test, type = "class")
prediccion
confusion.matrix(data.test, prediccion)

PROMiDAT/trainR documentation built on Oct. 27, 2020, 8:33 p.m.