Beispiel #1
0
def p_of_word(word, aDict, word_count, smoothing=PWL):
    """c
    """
    try:
        count = aDict[word]
    except KeyError:
        return 0.0
    v = len(aDict)
    return ratio(
        count,
        word_count,
        smoothing,
        v
    )
Beispiel #2
0
 def p_of_class(
         self,
         aClass,
         smoothing=PCL):
     """c
     """
     class_count = aClass.count
     message_count = self.message_count
     if self.agent_type == "spam":
         v = len(CLASSMAPSPAM)
     else:
         v = len(CLASSMAP8)
     return ratio(
         class_count,
         message_count,
         smoothing,
         v
     )
Beispiel #3
0
def odds(word, class_1, class_2):
    """c
    """
    pwgc1 = p_of_word_given_class(word, class_1)
    pwgc2 = p_of_word_given_class(word, class_2)
    return log(ratio(pwgc1, pwgc2))