← Back to all articles
Reddit r/MachineLearningSeptember 13, 2026

Got scipy's KD-tree to handle inserts and deletes without rebuilding. Three things I learned [P]

Excerpt

I built a small library called whitetree for exact Mahalanobis nearest-neighbour search on low-dimensional sensor data that keeps arriving. The idea is old. Whiten with the Cholesky factor of the covariance so Mahalanobis becomes Euclidean, then keep several scipy cKDTrees instead of one so inserts and deletes never force a full rebuild. Three measurements came out of it that I haven't seen stated plainly anywhere, so I'm posting those rather than a pitch. The short version first. On the static