Import replaced LogisticRegression class


In [ ]:
from scikit_learn import LogisticRegression

Go to main mips directory


In [2]:
cd ../..


/home/aga/Pulpit/mips/mips

In [3]:
import mips
from misc.utils import to_ft, load_sift
import numpy as np

Import train data and groundtruth
Prepare groundtruth


In [19]:
import random
xq=load_sift('./data/LSHTC-FT/fvecs.hid.fvecs', dtype=np.float32)
G = []
for line in open('./data/LSHTC-FT/fvecs.labels.txt'):
    G.append({int(y) for y in line.split()})
random_G = []
for i in G:
    if(len(i)>0):
        random_G.append(random.sample(i, 1))
    else: 
        random_G.append([0])
random_G2 = [item[0] for item in random_G]


576246
576246

Assign data to X,Y
Initialize LogisticRegression
Train faiss index
Search index


In [ ]:
X = np.copy(np.ascontiguousarray(xq), order='C')
Y = random_G2

lr = LogisticRegression()
lr.fit(X, Y)
lr.train_internal_index()

D, I = lr.decision_function(X)

In [ ]:


In [ ]: