예제 #1
0
 def test_adding_in_the_middle(self):
     features = np.array([[x + y for x in range(10)] for y in range(10)])
     self.assertEqual(features.shape, (10, 10))
     manager = ActiveLearningManager(features=features)
     manager.add_labels([(2, 1)])
     self.assertEqual(first_true(manager.labeled_mask), 2)
     self.assertEqual(first_true(manager.unlabeled_mask), 0)
예제 #2
0
 def test_test_that_when_the_first_add_is_at_0_it_updates_correctly(self):
     features = np.array([[x + y for x in range(10)] for y in range(10)])
     self.assertEqual(features.shape, (10, 10))
     manager = ActiveLearningManager(features=features)
     manager.add_labels([(0, 1)])
     self.assertEqual(first_true(manager.labeled_mask), 0)
     # the index of the first unlabeled example is one past the first labeled
     self.assertEqual(first_true(manager.unlabeled_mask), 1)
예제 #3
0
    def test_addto_first_continuously(self):
        features = np.array([[x + y for x in range(10)] for y in range(10)])
        self.assertEqual(features.shape, (10, 10))
        manager = ActiveLearningManager(features=features)
        manager.add_labels([(0, 1)])
        self.assertEqual(first_true(manager.labeled_mask), 0)
        self.assertEqual(first_true(manager.unlabeled_mask), 1)

        manager.add_labels([(0, 1)])
        self.assertEqual(first_true(manager.labeled_mask), 0)
        self.assertEqual(first_true(manager.unlabeled_mask), 2)

        manager.add_labels([(0, 1)])
        self.assertEqual(first_true(manager.labeled_mask), 0)
        self.assertEqual(first_true(manager.unlabeled_mask), 3)
예제 #4
0
    def test_adding_two_in_the_middle_and_then_at_0(self):
        features = np.array([[x + y for x in range(10)] for y in range(10)])
        self.assertEqual(features.shape, (10, 10))
        manager = ActiveLearningManager(features=features)
        manager.add_labels([(2, 1)])
        self.assertEqual(first_true(manager.labeled_mask), 2)
        self.assertEqual(first_true(manager.unlabeled_mask), 0)

        manager.add_labels([(1, 1)])
        self.assertEqual(first_true(manager.labeled_mask), 1)
        # We still didn't label the one at 0
        self.assertEqual(first_true(manager.unlabeled_mask), 0)

        manager.add_labels([(0, 1)])
        self.assertEqual(first_true(manager.labeled_mask), 0)
        # we labeled 0,1,2 the next one should be 3
        self.assertEqual(first_true(manager.unlabeled_mask), 3)
def prepare_manager(vectors_train, docs_train):
    manager = ActiveLearningManager(vectors_train, sources=docs_train)
    return manager
예제 #6
0
def prepare_manager(X_train):
    manager = ActiveLearningManager(X_train)
    return manager