Note: This page has been translated by MathWorks. Please click here

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

(to be removed) Train naive Bayes classifier

`fitNaiveBayes`

will be removed in a future
release. Use `fitcnb`

instead.

`NBModel = fitNaiveBayes(X,Y)`

`NBModel = fitNaiveBayes(X,Y,Name,Value)`

returns
a naive Bayes classifier with additional options specified by one
or more `NBModel`

= fitNaiveBayes(`X`

,`Y`

,`Name,Value`

)`Name,Value`

pair arguments.

For example, you can specify a distribution to model the data, prior probabilities for the classes, or the kernel smoothing window bandwidth.

For classifying count-based data, such as the bag-of-tokens model, use the multinomial distribution (e.g., set

`'Distribution','mn'`

).This list defines the order of the classes. It is useful when you specify prior probabilities by setting

`'Prior',prior`

, where`prior`

is a numeric vector.If

`Y`

is a categorical array, then the order of the class levels matches the output of`categories(Y)`

.If

`Y`

is a numeric or logical vector, then the order of the class levels matches the output of`sort(unique(Y))`

.For cell arrays of character vectors and character arrays, the order of the class labels is the order which each label appears in

`Y`

.

If you specify

`'Distribution','mn'`

, then the software considers each observation as multiple trials of a multinomial distribution, and considers each occurrence of a token as one trial (see Bag-of-Tokens Model).If you specify

`'Distribution','mvmn'`

, then the software assumes each individual predicator follows a multinomial model within a class. The parameters for a predictor include the probabilities of all possible values that the corresponding feature can take.

`fitcnb`

| `NaiveBayes`

| `posterior`

| `predict`

Was this topic helpful?