matlab naivebayes,how to use the NaiveBayes.fit for classification in matlab?

for i=1 :100

load('datas3.mat');

data=datas3;

[n,m]=size(data);

rows=(1:n);

testcount=floor((0.2)*n);

acc1=0; SenAr=0; SpeAr=0; MCCAr=0;

kk=10;

for k=1: kk

test_rows=randsample(rows,testcount);

train_rows=setdiff(rows,test_rows);

test=data(test_rows,:);

train=data(train_rows,:);

xtest=test(:,1:m-1);

ytest=test(:,m);

xtrain=train(:,1:m-1);

ytrain=train(:,m);

NB=NaiveBayes.fit(xtrain,ytrain);

out=NB.predict(xtest);

these errors were shown:

Warning: NaiveBayes will be removed in a future release. Use fitcnb instead.

In NaiveBayes.fit (line 8)

In accu (line 30)

Error using NaiveBayes.fit>gaussianFit (line 373)

The within-class variance in each feature of TRAINING must be positive. The within-class variance

in feature 1 in class 0

are not positive.

Error in NaiveBayes.fit (line 337)

obj = gaussianFit(obj, training, gindex);

Error in accu (line 30)

NB=NaiveBayes.fit(xtrain,ytrain);

I'll be very grateful to have your opinions. Thanks.

More answer...

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值