Example #1
0
def test_basic():
    nb = BinaryNaiveBayes(prior_yes=0.5)
    nb.likelihood('', lambda x: True, p_ifyes=0.3, p_ifno=0.1)
    # 0.3 * 0.5 / 0.3 * 0.5 + 0.1 * 0.5 = 0.75
    assert 0.749 < nb.test(0) < 0.751
Example #2
0
def test_medical():
    nb = BinaryNaiveBayes(prior_yes=0.0001)
    nb.likelihood('', lambda x: True, p_ifyes=0.99, p_ifno=0.01)
    assert 0.0097 < nb.test(0) < 0.0099