Naive Bayes classifier template
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.
If you specify 'DistributionNames','mn'
when training
Mdl
using fitcnb
, then the software fits a multinomial distribution using the
bag-of-tokens
model. The software stores the probability that token
j
appears in class k
in
the property
DistributionParameters{
.
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 you specify 'DistributionNames','mvmn'
when training
Mdl
using fitcnb
, then:
For each predictor, 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 predictor j
in class
k, the software counts instances of each
categorical level using the list stored in
CategoricalLevels{
.j
}
The software stores the probability that predictor
j
, in class k
,
has level L in the property
DistributionParameters{
,
for all levels in
k
,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.
[1] Hastie, T., R. Tibshirani, and J. Friedman. The Elements of Statistical Learning, Second Edition. NY: Springer, 2008.
[2] Manning, C. D., P. Raghavan, and M. Schütze. Introduction to Information Retrieval, NY: Cambridge University Press, 2008.
ClassificationECOC
| ClassificationNaiveBayes
| fitcecoc
| fitcnb