You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to change a data point in the index. How can i do that?
import hnswlib
import numpy as np
# Generating sample data
a = np.array([1.0, 0.0, 0.0])
b = np.array([0.0, 1.0, 0.0])
c = np.array([0.0, 0.0, 1.0])
d = np.array([1.0, 1.0, 0.0])
# Declaring index
p = hnswlib.Index(space='l2', dim = 3)
# Initing index - the maximum number of elements should be known beforehand
p.init_index(max_elements = 50, ef_construction = 200, M = 16)
# Element insertion (can be called several times):
p.add_items(a)
p.add_items(b)
p.add_items(c)
labels, distances = p.knn_query(c, k =1)
print labels, distances
#change data points
p.add_items(d, 2)
p.add_items(c, 0)
labels, distances = p.knn_query(d, k =1)
print labels, distances
labels, distances = p.knn_query(c, k =1)
print labels, distances
The query result is not changed after i rewrite the data point label index.
The text was updated successfully, but these errors were encountered:
@universewill Changing the element would require deleting the element from the index and adding a new one. Not supported currently, see #4.
Another possible solution (in case the update does not change the point significantly) is to rewire the links, which is not that much easier than support deletion.
What happens in your code is that you add 5 elements with two pairs of which share the same labels.
I want to change a data point in the index. How can i do that?
The query result is not changed after i rewrite the data point label index.
The text was updated successfully, but these errors were encountered: