如何在具有离散属性的 Matlab 中使用 fitcnb(朴素贝叶斯)?

How to use fitcnb (Naive Bayes) in Matlab with discrete attributes?

我有一个数据集如下图:

第一和第二个属性(退款、婚姻状况)是离散属性
第三个属性(应税收入)是 continues 属性

我想在 matlab 中建立一个模型并在此 table 上训练它。

这是我的尝试:

我收到了这条错误信息:

A normal distribution cannot be fit for the combination of class Yes and predictor x1. The data has zero variance.

任何人都可以帮助或指导我如何在 matlab 中正确使用 fitcnb

我们需要为 fitcnb 指定分类或离散属性

Mdl = fitcnb(Data,Classes,'CategoricalPredictors',[1 2]);