zen_mapper.cover module¶
- class Data_Balanced_Cover(n_elements, percent_overlap)¶
Bases:
objectA cover of 1D data with roughly equal data points per interval.
The cover is constructed by partitioning the sorted indices \([0, \dots, N-1]\) into intervals of approximately equal size, then mapping those index-regions back to the original data positions.
Each bin has a base size and step calculated as:
\[base\_size = \frac{N}{k - (k - 1) \times \text{overlap}} \]\[step = base\_size \times (1 - \text{overlap}) \]where \(k\) is n_elements.
- Parameters:
- Raises:
ValueError – If n_elements < 1 or percent_overlap is not in the range (0, 1).
- Parameters:
Notes
A percent_overlap of 0.5 means each interval shares approximately 50% of its points with the subsequent interval.
- class Width_Balanced_Cover(n_elements, percent_overlap)¶
Bases:
objectA cover comprised of equally sized rectangular elements
- Parameters:
- Raises:
Value Error – if n_elements < 1
Value Error – if percent_overlap is not in (0,1)
- precomputed_cover(cover)¶
A precomputed cover
- Parameters:
cover (
Cover) – the precomputed cover to use- Return type:
- rectangular_cover(centers, widths, data, tol=1e-09)¶
Partition data points into multi-dimensional rectangular cover elements.
Note
This is a low-level structural function that requires pre-computed bounding box geometries. For most use cases, you should use
width_balanced_coverordata_balanced_coverinstead, which handle the geometry generation automatically.- Parameters:
centers (
ndarray) – The coordinates of the centers for each hyper-rectangle. Shape should be (n_centers, n_features) or (n_centers,).widths (
ndarray) – The width of the covering elements. Must be broadcastable against the feature dimensions (e.g., a scalar or a 1D array of shape (n_features,)).data (
ndarray) – The dataset to be partitioned into the cover elements. Shape should be (n_samples, n_features) or (n_samples,).tol (
float, default:1e-09) – A small numerical tolerance added to the boundary calculations to prevent floating-point precision issues for points resting exactly on an edge. Defaults to 1e-9.
- Returns:
list[ndarray] – A list of length n_centers. Each entry is a 1D array of integers containing the row indices of data that fall inside that specific rectangular cover element.- Return type:
See also
width_balanced_cover: compute a cover comprised of equally sized rectangular elements.data_balanced_covercompute a cover where each element has the same number of data points.