def classify_nb_one(self, frag): ## the prior is weird, but it works better this way, consistently probs = sbd_util.Counter([(label, self.feats[label, '<prior>']**4) for label in [0,1]]) for label in probs: for feat, val in frag.features.items(): key = (label, feat + '_' + val) if not key in self.feats: continue probs[label] *= self.feats[key] probs = sbd_util.normalize(probs) return probs[1]