1

我收到此错误:

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。

4

1 回答 1

1

你有两个问题。

首先,对于多项分布,MATLAB 希望您的数据具有非负整数值。其次,似乎至少对于您的某些课程,您没有任何有效的观察结果。这可能是因为 NAN、INF 或只是 Testdata 行中的非正值。

实际上,正如错误所说 - “无效行将被删除”......所以我打赌无效行被删除......

于 2012-11-21T16:16:08.177 回答