Skip to content

meaning of 'leaf_size', 'n_leaves' and 'n_calls'? #19599

Answered by i-aki-y
pixar0407 asked this question in Q&A
Discussion options

You must be logged in to vote

Although I am not familiar with kdtree, I will try to answer your question from the source code.

In the 'https://github.com/scikit-learn/scikit-learn/blob/main/sklearn/neighbors/_binary_tree.pxi', there is '_query_single_depthfirst'. This says that if the tree hits the leaf node, it does 'n_leaves += 1' and does the 'self.rdist'. And whenever the tree does the 'self.rdist', it does 'n_calls += 1'.

This self.rdist() is located inside a for-loop.

for i in range(node_info.idx_start, node_info.idx_end):
    dist_pt = self.rdist(pt,
                            &self.data[self.idx_array[i], 0],
                            self.data.shape[1])

In this case, each leaf node has two points (idx_en…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by lesteve
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants