Trouble with NaiveBayes object in Statistics toolbox (R2010a)

2 views (last 30 days)
Hello,
I am having trouble using the NaiveBayes class and associated functions in my R2010a. Specifically, I am unable to run the NaiveBayes.fit demo on the demo dataset. When I say:
load fisheriris >> O1 = NaiveBayes.fit(meas,species);
I get ??? Error using ==> vertcat CAT arguments dimensions are not consistent.
Error in ==> NaiveBayes.fit>gaussianFit at 540 obj.Params(i,obj.GaussianFS) = mat2cell([mu;sigma],2,...
Error in ==> NaiveBayes.fit at 498 obj = gaussianFit(obj, training, gindex);
I tried t o look for an overload function for gaussianFit but did not find any.
I am however, able to run it with a 'mvmn' density model rather than a Gaussian density (default). Despite this, when I run
[post,cpre] = O1.posterior(meas);
I get all NaNs in the result. I checked that the values in O1.params are not NaNs.
What could be wrong? Any help is appreciated.

Accepted Answer

Tom Lane
Tom Lane on 25 Aug 2011
This is odd. it appears to be having trouble concatenating mu and sigma, which came out of these two earlier lines:
mu = nanmean(training(groupI,obj.GaussianFS));
sigma = nanstd(training(groupI,obj.GaussianFS));
Would you check to see if you have any of these on your path outside of their usual MATLAB locations: nanmean, nanstd, sum, nansum, nanvar?
  1 Comment
Pavan
Pavan on 25 Aug 2011
Thanks Tom. I checked and it seems like the financial time series toolbox 'fints' has overload methods for all the nan* functions you listed. Could that be an issue?

Sign in to comment.

More Answers (1)

Tom Lane
Tom Lane on 26 Aug 2011
I would not expect this to be a problem unless your path was set up in an unusual way. If I type "which nansum" I see the stats version. If I type "which -all nansum" I see the fints version after the stats version. If I type "type nansum" I see the contents of the stats version. What do those three commands do for you?
  1 Comment
Pavan
Pavan on 29 Aug 2011
I did have some third party toolboxes installed which had alternate version of nansum and nanstd. Removing them from the path was sufficient to get it running. Thanks again for your support!

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!