2012-11-21 32 views
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如果你想知道。

回答

1

你有两个问题。

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

其实,错误说 - “无效的行会被删除” ...所以我敢打赌无效行被拆除......

+0

这是否意味着有小数什么,因为我看不到任何负数,如果他们被删除为什么抛出第二个错误? –

+0

“整数”通常表示没有小数,是的:)。第二个错误是(可能),因为你不再有一个类的实例(target_class的唯一值),所以分类器没有任何事情可做。 – Pete

+0

啊,好的,你认为我的选择是什么,上下翻转或删除? –

相关问题