bayes-classifier-js icon indicating copy to clipboard operation
bayes-classifier-js copied to clipboard

how to handle tokens with 0 or 100% probability

Open shiffman opened this issue 8 years ago • 2 comments

This is what I'm doing now:

if (word[category].prob < 0.01) word[category].prob = 0.01;
if (word[category].prob > 0.99) word[category].prob = 0.99;

shiffman avatar Oct 14 '17 20:10 shiffman

A basic constraint:

word[category].prob = Math.max(0.01, Math.min(0.99, word[category].prob));

AlcaDesign avatar Oct 14 '17 20:10 AlcaDesign

Yes, this would be an improvement over my code! Feel free to implement that. I will leave this open, however, as I'm wondering if there is a different or more appropriate mathematical solution?

shiffman avatar Oct 14 '17 20:10 shiffman