templateNaiveBayes
Naive Bayes classifier template
Description
returns
a naive Bayes template
suitable for training error-correcting output code (ECOC) multiclass
models. t
= templateNaiveBayes()
If you specify a default template, then the software uses default values for all input arguments during training.
Specify t
as a learner in fitcecoc
.
returns
a template with additional options specified by one or more name-value
pair arguments. All properties of t
= templateNaiveBayes(Name,Value
)t
are empty,
except those you specify using Name,Value
pair
arguments.
For example, you can specify distributions for the predictors.
If you display t
in the Command Window, then
all options appear empty ([]
), except those that
you specify using name-value pair arguments. During training, the
software uses default values for empty options.
Examples
Input Arguments
Output Arguments
More About
Algorithms
If predictor variable
j
has a conditional normal distribution (see theDistributionNames
name-value argument), the software fits the distribution to the data by computing the class-specific weighted mean and the unbiased estimate of the weighted standard deviation. For each class k:The weighted mean of predictor j is
where wi is the weight for observation i. The software normalizes weights within a class such that they sum to the prior probability for that class.
The unbiased estimator of the weighted standard deviation of predictor j is
where z1|k is the sum of the weights within class k and z2|k is the sum of the squared weights within class k.
If all predictor variables compose a conditional multinomial distribution (you specify
'DistributionNames','mn'
), the software fits the distribution using the bag-of-tokens model. The software stores the probability that tokenj
appears in classk
in the propertyDistributionParameters{
. Using additive smoothing [2], the estimated probability isk
,j
}where:
which is the weighted number of occurrences of token j in class k.
nk is the number of observations in class k.
is the weight for observation i. The software normalizes weights within a class such that they sum to the prior probability for that class.
which is the total weighted number of occurrences of all tokens in class k.
If predictor variable
j
has a conditional multivariate multinomial distribution:The software collects a list of the unique levels, stores the sorted list in
CategoricalLevels
, and considers each level a bin. Each predictor/class combination is a separate, independent multinomial random variable.For each class
k
, the software counts instances of each categorical level using the list stored inCategoricalLevels{
.j
}The software stores the probability that predictor
j
, in classk
, has level L in the propertyDistributionParameters{
, for all levels ink
,j
}CategoricalLevels{
. Using additive smoothing [2], the estimated probability isj
}where:
which is the weighted number of observations for which predictor j equals L in class k.
nk is the number of observations in class k.
if xij = L, 0 otherwise.
is the weight for observation i. The software normalizes weights within a class such that they sum to the prior probability for that class.
mj is the number of distinct levels in predictor j.
mk is the weighted number of observations in class k.
References
[1] Hastie, T., R. Tibshirani, and J. Friedman. The Elements of Statistical Learning, Second Edition. NY: Springer, 2008.
Version History
Introduced in R2014bSee Also
fitcecoc
| ClassificationECOC
| ClassificationNaiveBayes
| fitcnb