gt22 icon

Untitled

gt22 | PRO | 10/09/18 09:04:54 PM UTC | 0 ⭐ | 545 👁️ | Never ⏰ | []
Python |

420 B

|

None

|

0 👍

/

0 👎

from collections import defaultdict
 
def _count_words(self, d):
    ret = defaultdict(lambda: 0)
    for line in d:
        for word in line:
            ret[word] += 1
    return ret
 
def fit(self, x, y):
    spam = x[y == 1]
    ham = x[y == 0]
    spam_words = self._count_words(spam)
    ham_words = self._count_words(ham)
    spam_sum = sum(spam_words.values())
    ham_sum = sum(ham_words.values())
    #........

Comments