Cluster

class chess.cluster.Cluster(data: Union[numpy.memmap, numpy.ndarray], metric: str, points: List[int] = None, name: str = '', center: int = None, radius: numpy.float64 = None)

Defines the cluster class.

Adds methods relevant to building and searching through a cluster-tree. Adds a compress method that should only be used for appropriate datasets.

compress()

Compresses a leaf cluster. # TODO: Migrate away from pickle. Perhaps we can build a new memmap?

local_fractal_dimension() → numpy.float64

Calculates the local fractal dimension of the cluster. This is the log2 ratio of the number of points in the cluster to the number of points within half the radius.

Returns

local fractal dimension of the cluster.

make_tree(stopping_criteria: Callable[[any], bool] = None)

Build cluster sub-tree starting at this cluster.

partition()

Partition this cluster into left and right children.

Steps:
  • Check if the cluster has already been popped or if it can be popped.

  • Find the two potential centers that are the farthest apart.

  • Treat those two as the left and right poles.

  • Partition the points in this cluster by the pole that the points are closer to.

  • Assign the partitioned points to the left and right child clusters appropriately.

partitionable() → bool

Returns weather or not this cluster can be partitioned.

radius() → numpy.float64

Calculates the radius of the cluster.

This is the maximum of the distances of any point in the cluster to the cluster center.

Returns

radius of cluster.