KMeansTree
KMeansTree(points; builder=KMeansTreeBuilder(...)) builds a BoundingBallTree by recursively partitioning points with k-means.
Construction outline:
- A root cluster is fitted and the root center/radius are initialized.
- Each node is split with k-means into
numberofclusterschild clusters whilelength(values(node)) >= max(minvalues, numberofclusters). - Children store point indices and their local center/radius.
- Internal-node point lists are emptied after splitting, and node ordering is adjusted.
- Node radii are finalized via
updateradii!(default:boundingsphere).
Pass a KMeansTreeBuilder, which stores all construction settings explicitly:
tree = KMeansTree(
points;
builder=KMeansTreeBuilder(;
numberofclusters=numberofclusters,
minvalues=60,
),
)If you use updateradii=H2Trees.unsafemaxradiusboundingsphere or updateradii=H2Trees.noboundingsphereupdate, the radii are not reliably updated. This can lead to incorrect results when using iterators in H2Trees. Proceed at your own risk.
using CompScienceMeshes, BEAST
using H2Trees
using PlotlyJS
using ParallelKMeans
m = meshsphere(1.0, 0.1)
tree = KMeansTree(
lagrangecxd0(m); builder=KMeansTreeBuilder(; numberofclusters=4, minvalues=60)
)using CompScienceMeshes, BEAST
using H2Trees
using PlotlyJS
using ParallelKMeans
m = meshsphere(1.0, 0.1)
tree = KMeansTree(
lagrangecxd0(m);
builder=KMeansTreeBuilder(;
numberofclusters=4, minvalues=60, updateradii=H2Trees.noboundingsphereupdate
),
)using CompScienceMeshes, BEAST
using H2Trees
using PlotlyJS
using ParallelKMeans
m = meshsphere(1.0, 0.1)
tree = KMeansTree(
lagrangecxd0(m);
builder=KMeansTreeBuilder(;
numberofclusters=4, minvalues=60, updateradii=H2Trees.unsafemaxradiusboundingsphere
),
)