multidim.covertree.CoverLevel

class multidim.covertree.CoverLevel(covertree, exponent)[source]

A thin class to represent one level of the filtration in a CoverTree. A CoverLevel is essentially a collection of dictionaries of adults, friends, children, and other attributes of a particular level.

The various attributes have different orderings, optimized for typical usage and minimal algorithmic complexity.

Notes

The user should never create a CoverLevel directly. Instead, create a CoverTree and access its \(i^{\text{th}}\) level with covertree[i].

Attributes:
covertree : CoverTree

The CoverTree to which this CoverLevel belongs.

pointcloud : multidim.PointCloud

The PointCloud used to make the CoverTree

exponent : int

The exponent (that is, index or depth or level) of this CoverLevel in the CoverTree.

radius : numpy.float64

The ball radius

T1 : numpy.float64

The type-1 friends radius

T2 : numpy.float64

The type-2 friends radius

T3 : numpy.float64

The type-3 friends radius

adults : list

List of adult indices, in order they were born

friends1 : collections.OrderedDict

An ordered dictionary to keep track of type-1 friends. Keyed by the adults, in birth order. The values are lists, in index order.

friends2 : collections.OrderedDict

An ordered dictionary to keep track of type-2 friends. Keyed by the adults, in birth order. The values are lists, in index order.

friends3 : collections.OrderedDict

An ordered dictionary to keep track of type-3 friends. Keyed by the adults, in birth order. The values are lists, in index order.

guardians : numpy.ndarray

An array of numpy.int64, which keeps track of the guardians of each point in the underlying PointCloud. Adults are their own guardians.

predecessor : collections.OrderedDict

An ordered dictionary to keep track of predecessors of the adults. Keyed by the adults, in birth order. The values are the indices of adults at the previous CoverLevel.

successors : collections.OrderedDict

An ordered dictionary to keep track of predecessors of the adults. Keyed by the adults, in birth order. The values are NumPy arrays of indices of adults in the next CoverLevel. This is computed only at the next level!

children : collections.OrderedDict

An ordered dictionary to keep track of children1 friends, keyed by the adults, in birth order. The values are NumPy boolean arrays, which allows for easy extraction of subsets of children.

weights : collections.OrderedDict

An ordered dictionary to keep track of total weight of children, keyed by the adults, in birth order. The values are NumPy arrays, with one entry per label. This is computed as part of cleanup()

entropy : collections.OrderedDict

An ordered dictionary to keep track of overall entropy of children, keyed by the adults, in birth order. The values are numpy.float64 numbers, of overall entropy of weights across labels. This is computed and stored via multidim.models.CDER, but it otherwise unused.

CoverLevel.check() Perform basic sanity checks on children, friends, etc.
CoverLevel.cleanup() Internal method – remove duplicate friends, and compute weights and entropy.
CoverLevel.find_entropy(adult) Compute the entropy of the labelled children on an adult.
CoverLevel.find_label_weights(adult) Compute the weights of labelled children of an adult.
CoverLevel.plot(canvas[, show_balls, …]) Plot a single level of a CoverTree
CoverLevel.plot_data_title([show_balls, …]) Internal method – Make source data for plot.