def test_experiment_with_unibucket_1(self): dim = 50 vector_count = 100 vectors = numpy.random.randn(dim, vector_count) unibucket = UniBucket('testHash') nearest = NearestFilter(10) engine = Engine(dim, lshashes=[unibucket], vector_filters=[nearest]) exp = RecallPrecisionExperiment(10, vectors) result = exp.perform_experiment([engine]) # Both recall and precision must be one in this case self.assertEqual(result[0][0], 1.0) self.assertEqual(result[0][1], 1.0)
def test_experiment_with_unibucket_3(self): dim = 50 vector_count = 100 vectors = numpy.random.randn(dim, vector_count) unibucket = UniBucket('testHash') nearest = NearestFilter(5) engine = Engine(dim, lshashes=[unibucket], vector_filters=[nearest]) exp = RecallPrecisionExperiment(10, vectors) result = exp.perform_experiment([engine]) # In this case recall is only 0.5 # because the engine returns 5 nearest, but # the experiment looks for 10 nearest. self.assertEqual(result[0][0], 0.5) self.assertEqual(result[0][1], 1.0)
def test_experiment_with_list_2(self): dim = 50 vector_count = 100 vectors = [] for index in range(vector_count): vectors.append(numpy.random.randn(dim)) unibucket = UniBucket('testHash') nearest = NearestFilter(10) engine = Engine(dim, lshashes=[unibucket], vector_filters=[nearest]) exp = RecallPrecisionExperiment(5, vectors) result = exp.perform_experiment([engine]) # In this case precision is only 0.5 # because the engine returns 10 nearest, but # the experiment only looks for 5 nearest. self.assertEqual(result[0][0], 1.0) self.assertEqual(result[0][1], 0.5)
def test_delete_vector_with_provided_value(self): engine = Engine(self.dim, lshashes=[UniBucket('testHash')]) self.fill_engine(engine) engine.delete_vector(self.removed_value, self.removed_vector) self.check_delete(engine)
def test_delete_vector_multiple_hash(self): hashes = [UniBucket('name_hash_%d' % k) for k in range(10)] engine = Engine(self.dim, lshashes=hashes) self.fill_engine(engine) engine.delete_vector(self.removed_value) self.check_delete(engine)
def test_delete_vector_single_hash(self): engine = Engine(self.dim, lshashes=[UniBucket('testHash')]) self.fill_engine(engine) engine.delete_vector(self.removed_value) self.check_delete(engine)