machineJS icon indicating copy to clipboard operation
machineJS copied to clipboard

MultinomialNB fails when features have negative values

Open sunnmy opened this issue 9 years ago • 2 comments

On my dataset machineJS failed because it was trying to use negative X values with multinomial Naive Bayes classifier.

Suggested solutions:

  • Skip MultinomialNB when some of the features have negative values.
  • Use GaussianNB instead.
  • Normalize features to [0, 1] range.

sunnmy avatar Mar 30 '16 19:03 sunnmy

Sweet, thanks for pointing that out! Out of curiosity, did the entire process break at that point, or did the rest of it continue to run with only MultinomialNB failing?

Your suggested solutions are solid. We're already doing feature normalization in data-formatter, so it shouldn't be too hard to expand that here. The other two look very straightforward as well. If you wanted to take a crack at any of those solutions, that'd be an easy PR to merge!

Thanks for reporting this! Keep the issues coming :)

ClimbsRocks avatar Mar 30 '16 19:03 ClimbsRocks

multinomial don't take neg values, so while preprocessing numerical data best use is minmaxscaler()

muffin-head avatar May 10 '21 21:05 muffin-head