<jupyter_start><jupyter_text>from math import expfor d in testSet:    scoreYes = log(priorYes)    scoreNo  = log(priorNo)        for t in d[1].lower().split():        scoreYes += cpYes[t]        scoreNo  += cpNo[t]        if scoreYes > scoreNo:        print("Yes")    else:        print("No")    print(exp(scoreYes), exp(scoreNo))<jupyter_code>testSet = [
    (5, "Chinese Tokyo Japan")
]
from math import exp

for d in testSet:
    scoreYes = log(priorYes)
    scoreNo  = log(priorNo)
    
    for t in d[1].lower().split():
        scoreYes += cpYes[t]
        scoreNo  += cpNo[t]
    
    if scoreYes > scoreNo:
        print("Yes")
    else:
        print("No")
    print(exp(scoreYes), exp(scoreNo))<jupyter_output>No
0.0016399416909620987 0.0027434842249657062<jupyter_text>Smoothing을 바꿈<jupyter_code>cpYes = defaultdict(float)
cpNo  = defaultdict(float)
K = 0.5
B = len(vocaburary)
sumYes = sum(tokensYes.values())
sumNo  = sum(tokensNo.values())

for t in vocaburary:
    cpYes[t] += log((tokensYes[t] + K) / (sumYes + K*2))
    cpNo[t]  += log((tokensNo[t] + K) / (sumNo + K*2))
    print(t)
    print("YES | log({0}+1/{1}+{2})={3:.4F}".format(tokensYes[t], sumYes, B, cpYes[t] ))
    print(" NO | log({0}+1/{1}+{2})={3:.4F}".format(tokensNo[t],  sumNo,  B, cpNo[t] ))
testSet = [
    (5, "Chinese Chinese Chinese Tokyo Japan")
]
for d in testSet:
    scoreYes = log(priorYes)
    scoreNo  = log(priorNo)
    
    for t in d[1].lower().split():
        scoreYes += cpYes[t]
        scoreNo  += cpNo[t]
    
    if scoreYes > scoreNo:
        print("Yes")
    else:
        print("No")
    print(exp(scoreYes), exp(scoreNo))<jupyter_output>No
0.0005282953563989228 0.0018539428710937502
{'fraction_non_alphanumeric': 0.1652892561983471, 'fraction_numerical': 0.05962219598583235, 'mean_word_length': 3.045346062052506, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '73825', 'license': 'MIT', 'n_tokens_mistral': 727, 'n_tokens_neox': 667, 'n_words': 132, 'path': '_pages/Language/Python/src/KOIPA-NLP/Naive.ipynb', 'repo_name': 'shpimit/shpimit.github.io', 'size': '1694'}