Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Algorithmic logic problem #4

Open
JohnnyLin12 opened this issue Jan 19, 2024 · 0 comments
Open

Algorithmic logic problem #4

JohnnyLin12 opened this issue Jan 19, 2024 · 0 comments

Comments

@JohnnyLin12
Copy link

nan_search(self) function in nan.py
while(flag == 0):
for i in range(len(self.data)):
knn = self.findKNN(self.data[i], r, tree)
n = knn[-1]
self.knn[i].add(n)
if(i in self.knn[n] and (i, n) not in self.nan_edges):
self.nan_edges.add((i, n))
self.nan_edges.add((n, i))
self.nan_num[i] += 1
self.nan_num[n] += 1

The judge branch "if i in self.knn[n] and (i, n) not in self.nan_edges" determines whether instance i and instance n are nearest neighbors of each other may be problematic, because "self.findKNN(self.data[i], r, tree)" obtains the rth nearest neighbor of instance i; at this point, the nearest neighbor of the instances with instance n may not have been calculated yet. Neighbors may not have been computed yet, the rth nearest neighbor of all instances should be computed at once first; e.g. knn_idxs = self.kdtree.query(self.data, [r + 1])[1] # Get the kth nearest neighbor index of the rth round;
Looking foward to your reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant