level_set_tree.LevelSetTree.prune

LevelSetTree.prune(threshold)

Prune the tree by recursively merging small leaf nodes into larger sibling nodes. The LevelSetTree is immutable, so pruning returns a new LevelSetTree whose nodes all contain more points than ‘threshold’.

Parameters:

threshold : int

Nodes smaller than this will be merged.

Returns:

out : LevelSetTree

A pruned level set tree. The original tree is unchanged.

Examples

>>> X = numpy.random.rand(100, 2)
>>> tree = debacl.construct_tree(X, k=8, prune_threshold=2)
>>> tree2 = tree.prune(threshold=12)