Programming-from-A-to-Z / bayes-classifier-js

A JavaScript library for Bayesisan classification

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

how to handle tokens with 0 or 100% probability

shiffman opened this issue · 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;

A basic constraint:

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

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?