贝叶斯判别法做了,中途报了以下错误:
>> ObjBayes=NaiveBayes.fit(training,group);
??? 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 18 25 29 43 49 58 68 69 72 76 77 79 83 85 86 93 99 in class 科技 are not positive.
Error in ==> NaiveBayes.fit at 498
obj = gaussianFit(obj, training, gindex);
>> ObjBayes=NaiveBayes.fit(training,group);
??? 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 25 26 27 32 42 44 58 65 66 67 82 in class 新闻 are not positive.
>> ObjBayes=NaiveBayes.fit(training,group);
??? 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 18 25 29 43 49 58 68 69 72 76 77 79 83 85 86 93 99 in class 科技 are not positive.
Error in ==> NaiveBayes.fit at 498
obj = gaussianFit(obj, training, gindex);
>> ObjBayes=NaiveBayes.fit(training,group);
??? 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 25 26 27 32 42 44 58 65 66 67 82 in class 新闻 are not positive.
然后我把涉及到的列全删除了,就可以用贝叶斯判别法做了。
原因:列(变量)太多了,导致协方差矩阵非正定,请删除无意义的列。