NaiveBayes

0th

Percentile

Naive Bayes Classifier

Computes the conditional a-posterior probabilities of a categorical class variable given independent predictor variables using the Bayes rule.

Keywords
classif, category
Usage
## S3 method for class 'formula':
NaiveBayes(formula, data, ..., subset, na.action = na.pass)
## S3 method for class 'default':
NaiveBayes(x, grouping, prior, usekernel = FALSE, fL = 0, ...)
Arguments
x
a numeric matrix, or a data frame of categorical and/or numeric variables.
grouping
class vector (a factor).
formula
a formula of the form class ~ x1 + x2 + .... Interactions are not allowed.
data
a data frame of predictors (caegorical and/or numeric).
prior
the prior probabilities of class membership. If unspecified, the class proportions for the training set are used. If present, the probabilities should be specified in the order of the factor levels.
usekernel
if TRUE a kernel density estimate (density) is used for denstity estimation. If FALSE a normal density is estimated.
fL
Factor for Laplace correction, default factor is 0, i.e. no correction.
...
arguments passed to density.
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 cas
Details

This implementation of Naive Bayes as well as this help is based on the code by David Meyer in the package e1071 but extended for kernel estimated densities and user specified prior probabilities. The standard naive Bayes classifier (at least this implementation) assumes independence of the predictor variables.

Value

  • An object of class "NaiveBayes" including components:
  • aprioriClass distribution for the dependent variable.
  • tablesA list of tables, one for each predictor variable. For each categorical variable a table giving, for each attribute level, the conditional probabilities given the target class. For each numeric variable, a table giving, for each target class, mean and standard deviation of the (sub-)variable or a object of class density.

concept

  • Naive Bayes Classification
  • Kernel estimated densities

See Also

predict.NaiveBayes,plot.NaiveBayes,naiveBayes,qda

Aliases
  • NaiveBayes
  • NaiveBayes.default
  • NaiveBayes.formula
Examples
data(iris)
m <- NaiveBayes(Species ~ ., data = iris)
Documentation reproduced from package klaR, version 0.6-11, License: GPL-2

Community examples

Looks like there are no examples yet.