1
$\begingroup$

The kd-tree implementation proposed by the scipy python libray asks for the value of the leafsize parameter that is to say the maximum number of points a node can hold. It is by default set to 10.

Are there methods or ways to estimate the value of the leafsize parameter to better distribute the data and avoid having leaves nodes with a single point?

https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.spatial.KDTree.html

scipy.spatial.KDTree(data, leafsize=10)
#The number of points at which the algorithm switches over to brute-force. Has to be positive.
$\endgroup$
0
$\begingroup$

With this setting of 10, you should never have a leaf with a single point, unless your data set consists of exactly one point.

Because the splits are balanced in size, the previous level must have at more than 10 points. So the minimum size is 5, if you set the maximum to 10 (except if there are less than 5 data points total).

$\endgroup$
  • $\begingroup$ I experienced the scipy kd-tree with leafsize set to 10 but it contains leaves with one point. The dataset contains 10000 points generated with make_blobs (function implemenetd in sklearn.datasets.samples_generator) $\endgroup$ – nabiltos Feb 10 at 14:29
  • $\begingroup$ Then it wasn't split at a midpoint? $\endgroup$ – Anony-Mousse Feb 11 at 1:56

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.