Skip to content

Instantly share code, notes, and snippets.

@GeorgeSeif
Created January 30, 2021 18:00
Show Gist options
  • Save GeorgeSeif/f8bcc579cb2eddd5abac75f48f89b469 to your computer and use it in GitHub Desktop.
Save GeorgeSeif/f8bcc579cb2eddd5abac75f48f89b469 to your computer and use it in GitHub Desktop.
s = time.time()
k = 10
n_init = 10
max_iter = 300
kmeans = faiss.Kmeans(d=x_train.shape[1], k=k, niter=max_iter, nredo=n_init)
kmeans.train(x_train.astype(np.float32))
e = time.time()
print("Training time = {}".format(e - s))
s = time.time()
kmeans.index.search(x_train.astype(np.float32), 1)[1]
e = time.time()
print("Prediction time = {}".format((e - s) / len(y_test)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment