我收到此错误:
Warning: TRAINING can only contain
non-negative integers when
'Distribution' is set to 'mn'. Rows of
TRAINING with invalid values will be
removed.
> In NaiveBayes.fit at 317
??? Error using ==>
??? Error using ==>
NaiveBayes.fit>mnfit at 647
At least one valid observation in each
class is required.
Error in ==> NaiveBayes.fit at 496
obj = mnfit(obj,training,
gindex);
这就是我所拥有的:
training_data = Testdata;
target_class = TestDataLabels;
%# train model
nb = NaiveBayes.fit(training_data, target_class, 'Distribution', 'mn');
%# prediction
class1 = nb.predict(UnseenTestdata);
%# performance
cmat1 = confusionmat(UnseenTestDataLabels, class1);
acc1 = 100*sum(diag(cmat1))./sum(cmat1(:));
fprintf('Classifier1:\naccuracy = %.2f%%\n', acc1);
fprintf('Confusion Matrix:\n'), disp(cmat1)
如果有人想知道,数据集是4940201x42。
答案 0 :(得分:1)
你有两个问题。
首先,对于多项分布,MATLAB希望您的数据具有非负整数值。第二,似乎至少对你的一些课程来说,你没有任何有效的观察。这可能是因为NAN,INF,或者只是Testdata行中的非正值。
实际上,正如错误所说 - “将删除无效行”...所以我打赌删除了无效行...