Reallocating arrays to expand the tree would be hard without significant changes to the current code. The node indices are stored in a fixed-length binary heap, and reference data are in a single numpy array. It would be much easier to re-implement the Ball Tree using dynamically allocated nodes. You'd gain the flexibility of being able to add points in-line, but you'd lose out on memory efficiency.
I think it would be fairly straighforward to implement in cython if it's something you need. You could follow the pseudo-code under "implementation notes" at the top of ball_tree.pyx, using c-structures for each node with pointers to children. Jake Andreas Mueller wrote: > Am 13.05.2012 17:28, schrieb Jacob VanderPlas: > >> It can't be done with the current functionality. When I rewrote the >> code last year, we decided picklability of the object and avoiding >> dynamic memory management was more important than being able to use it >> online. Currently, all data is stored in pre-allocated arrays. >> To use the Ball Tree inline, you'd have to re-write it to store the data >> in dynamically allocated nodes. This also brings up a lot of >> complicated tree balancing issues when points are added one-by-one. >> Jake >> > Thanks for the quick and informative answer Jake. > I was afraid this was the case. Well, back to brute force then. :-/ > > About the memory issue: > Do you think it would be feasible to reallocate the tree every > time an item is added? I would expect this to be cheaper > than building from scratch. > > Cheers, > Andy > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > Scikit-learn-general mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/scikit-learn-general > ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Scikit-learn-general mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/scikit-learn-general
