def test_04_update_02(self): """Verify that the perceptron update is performed correctly.""" classifier = PerceptronClassifier({'highly': 1, 'boring': -1}) classifier.update(self.small_instance_list_do_update[1]) expected_weigths = {'highly': 1, 'boring': 0} self.assertEqual(classifier.weights, expected_weigths) classifier = PerceptronClassifier({'highly': 1, 'boring': -1}) do_update = classifier.update(self.small_instance_list_no_update[1]) self.assertEqual(False, do_update)
def test_04_update_01(self): """Verify that the perceptron update is performed correctly.""" classifier = PerceptronClassifier({'highly': 1, 'boring': -1}) # Test document: ("highly", "doc25", -1) classifier.update(self.small_instance_list_do_update[0]) expected_weigths = {'highly': 0, 'boring': -1} self.assertEqual(classifier.weights, expected_weigths) classifier = PerceptronClassifier({'highly': 1, 'boring': -1}) # Test document: ("boring", "doc26", 1), do_update = classifier.update(self.small_instance_list_no_update[0]) self.assertEqual(False, do_update)