sightmachine / SimpleCV

The Open Source Framework for Machine Vision
http://simplecv.org
BSD 3-Clause "New" or "Revised" License
2.69k stars 799 forks source link

Naive Bayes Verbose #678

Closed onaclov2000 closed 9 years ago

onaclov2000 commented 9 years ago

When setting the naive bayes classifier verbosity to true, I get the following failure

 ERROR: 
 Traceback (most recent call last):
   File "classify.py", line 96, in <module>
     main()
   File "classify.py", line 79, in main
     trainer.train()
   File "classify.py", line 56, in train
     classifier.train(self.trainPaths,self.classes,verbose=True, savedata="train_results_" + str(count) + ".txt")
    File "/usr/local/lib/python2.7/dist-packages/SimpleCV/MachineLearning/NaiveBayesClassifier.py", line 240, in train
     for className, classConfusions in zip(classes, confusion):

I suspect that a simple check in that section to ensure confusion is in fact a number may make sense. However the "bug" may be higher up the food chain.

Update: Additional Details, I copied the implementation locally, and checked whether the item was a number, and it was, however it was 0, so when it tried to zip I can only assume (haven't verified yet is why assumed) that it's because you can't iterate through numbers when the number is 0.... so I'm testing out if confusion > 0: to see if it works.

Update again: if confusion > 0: did work, not sure if that's the right fix, but I figure it's more information :) Have a great day.

onaclov2000 commented 9 years ago

I put a pull request in, if this repo is still accepting them. If not I have fixed it at https://github.com/onaclovtech/SImpleCV