Main Content

Cross-validate naive Bayes classifier

returns a
cross-validated (partitioned) naive Bayes classifier (`CVMdl`

= crossval(`Mdl`

)`CVMdl`

)
from a trained naive Bayes classifier (`Mdl`

). By default,
`crossval`

uses 10-fold cross-validation on the training data
to create `CVMdl`

, a `ClassificationPartitionedModel`

classifier.

returns a partitioned naive Bayes classifier with additional options specified by
one or more name-value pair arguments. For example, you can specify the number of
folds or a holdout sample proportion.`CVMdl`

= crossval(`Mdl`

,`Name,Value`

)

Assess the predictive performance of

`Mdl`

on cross-validated data using the`'KFold'`

name-value pair argument and properties of`CVMdl`

, such as`kfoldLoss`

.Return a partitioned naive Bayes classifier with stratified partitioning using the name-value pair arguments

`'KFold'`

and`'Holdout'`

.Create a

`cvpartition`

object`cvp`

using`cvp =`

`cvpartition`

`(n,'KFold',k)`

. Return a partitioned naive Bayes classifier with nonstratified partitioning using the name-value pair`'CVPartition',cvp`

.

Instead of first creating a naive Bayes classifier and then creating a cross-validation
classifier, you can create a cross-validated classifier directly by using `fitcnb`

and specifying any of these name-value pair arguments:
`'CrossVal'`

, `'CVPartition'`

,
`'Holdout'`

, `'Leaveout'`

, or
`'KFold'`

.

`ClassificationNaiveBayes`

| `ClassificationPartitionedModel`

| `CompactClassificationNaiveBayes`

| `fitcnb`

| `kfoldLoss`