def filter_evidence(self, _): """ Stage 2.2 of pipeline. Build evidence for training the classifiers, from user answers (self.answers) and unanswered evidence (self.evidence) with last classification score certainty over self.evidence_threshold. """ logger.debug(u'running filter_evidence') evidence = Knowledge(self.answers) n = len(evidence) evidence.update((e, score > 0.5 and 1 or 0) for e, score in self.evidence.items() if certainty(score) > self.evidence_threshold and e not in self.answers) logger.info(u'Filtering returns {} human-built evidences and {} ' u'over-threshold evidences'.format(n, len(evidence) - n)) return evidence
def test_certainty_unknown(self): self.assertEqual(certainty(None), 0.5)
def test_certainty_certain_yes(self): self.assertEqual(certainty(1), 1)
def test_certainty_uncertain(self): self.assertEqual(certainty(0.5), 0.5)
def test_certainty_certain_no(self): self.assertEqual(certainty(0), 1)