# How to estimate the leafsize of the kd-tree?

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.