尝试拟合朴素贝叶斯时:
training_data = sample; %
target_class = K8;
# train model
nb = NaiveBayes.fit(training_data, target_class);
# prediction
y = nb.predict(cluster3);
我收到一个错误:
??? Error using ==> NaiveBayes.fit>gaussianFit at 535
The within-class variance in each feature of TRAINING
must be positive. The within-class variance in feature
2 5 6 in class normal. are not positive.
Error in ==> NaiveBayes.fit at 498
obj = gaussianFit(obj, training, gindex);
任何人都可以阐明这一点以及如何解决它?请注意,我在这里阅读了类似的帖子,但我不确定该怎么做?似乎它试图基于列而不是行来拟合,类方差应该基于每一行属于特定类的概率。如果我删除这些列,那么它可以工作,但显然这不是我想要做的。