예제 #1
0
 def fit(self, X):
     X = X.astype(numpy.float32)
     d = len(X[0])
     self.m = findmean(X, d, 10)
     X = isotropize(X, d, self.m)
     hypercube_dim = int(numpy.log2(len(X))) - 2
     self._index = Dolphinn(X, d, hypercube_dim)
예제 #2
0
    def fit(self, X):
        X = X.astype(numpy.float32)
	d = len(X[0])
	self.m = findmean(X, d, 10)
	X = isotropize(X, d, self.m)
	hypercube_dim = int(numpy.log2(len(X))) - 2
        self._index = Dolphinn(X, d, hypercube_dim) 
예제 #3
0
 def fit(self, X):
     if X.dtype != numpy.float32:
         X = numpy.array(X, dtype=numpy.float32)
     d = X.shape[1]
     self.m = findmean(X, d, 10)
     X = isotropize(X, d, self.m)
     hypercube_dim = int(numpy.log2(len(X))) - 2
     self._index = Dolphinn(X, d, hypercube_dim)
예제 #4
0
 def fit(self, X):
     if X.dtype != numpy.float32:
         X = numpy.array(X, dtype=numpy.float32)
     d = X.shape[1]
     self.m = findmean(X, d, 10)
     X = isotropize(X, d, self.m)
     hypercube_dim = int(numpy.log2(len(X))) - 2
     self._index = Dolphinn(X, d, hypercube_dim) 
예제 #5
0
 def query(self, v, n):
     q = numpy.array([v])
     q = isotropize(q, len(v), self.m)
     res = self._index.queries(q, n, self.num_probes)
     return res[0]
예제 #6
0
파일: main.py 프로젝트: ipsarros/DolphinnPy
M = 1  ##########################

#READ FILES
#D1: data dimension, P: dataset
#D2: query dimension, Q: queryset
(D1, P) = fr.fvecs_read("siftsmall/siftsmall_base.fvecs")
(D2, Q) = fr.fvecs_read("siftsmall/siftsmall_query.fvecs")
if D1 != D2:
    raise IOError("Data points and query points are of different dimension")
D = D1

#CHANGE OF ORIGIN
#find the mean of randomly sampled points
m = fr.findmean(P, D, 10)
#then consider this mean as the origin
P = fr.isotropize(P, D, m)
Q = fr.isotropize(Q, D, m)
K = int(np.log2(len(P))) - 2  ##########################
print "New dimension K=", K

#PREPROCESSING
tic = time.clock()
dol = Dolphinn(P, D, K)
toc = time.clock()
print "Preprocessing time: ", toc - tic

#QUERIES
tic = time.clock()
#assign keys to queries
solQ = dol.queries(Q, M, num_of_probes)
toc = time.clock()
예제 #7
0
 def query(self, v, n):
     q = numpy.array([v])
     q = isotropize(q, len(v), self.m)                
     res = self._index.queries(q, n, self.num_probes)
     return res[0]