Grid classes
DenseHypergrid
hypergrid.base.dense_tensor_hypergrid.DenseTensorHypergrid
Bases: BaseTensorHypergrid
Hypergrid backed by a dense numpy array.
Best for low-dimensional grids where most bins receive data. Memory footprint is O(prod(n_bins_per_dim)), independent of sparsity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edges
|
list of array-like
|
Bin edges per dimension (length n_bins_d + 1 each). |
required |
Source code in hypergrid\base\dense_tensor_hypergrid.py
SparseHypergrid
hypergrid.base.sparse_tensor_hypergrid.SparseTensorHypergrid
Bases: BaseTensorHypergrid
Hypergrid backed by a sparse dict with explicit bounds checking.
Best for high-dimensional grids or data that occupies only a small fraction of the bin space. Memory scales with non-zero bin count.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edges
|
list of array-like
|
Bin edges per dimension (length n_bins_d + 1 each). |
required |
Source code in hypergrid\base\sparse_tensor_hypergrid.py
StaticHypergrid
hypergrid.base.static_hypergrid.StaticHypergrid
Bases: BaseTensorHypergrid
Hypergrid with user-specified edges and a pluggable storage backend.
The default storage is DictStorage (sparse, no bounds checking). Pass any object that implements add / items / clear / scale to swap backends.
This is the most flexible variant — useful when you want to combine custom storage with the full mixin stack (rebin, compare, visualize).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edges
|
list of array-like
|
Bin edges per dimension. |
required |
storage
|
storage backend
|
Defaults to DictStorage. |
None
|
Source code in hypergrid\base\static_hypergrid.py
AdaptiveHypergrid
hypergrid.base.adaptive_hypergrid.AdaptiveHypergrid
Bases: BaseTensorHypergrid
Hypergrid that automatically rebins when the overflow fraction exceeds a threshold, adapting the grid to concept drift.
A rolling buffer of recent points is kept so that rebinning uses the most recent data distribution rather than the full history.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
edges
|
list of array-like
|
Initial bin edges. If None, computed from the first batch passed to fit. |
None
|
drift_threshold
|
float
|
Fraction of out-of-bounds points that triggers a rebin (default 0.05). |
0.05
|
buffer_size
|
int
|
Maximum number of recent points kept for rebinning. |
5000
|
binning_method
|
(fd, sturges, sqrt)
|
Edge computation method used during rebinning. |
"fd"
|
max_bins
|
int
|
Per-dimension bin cap used during rebinning. |
50
|
Source code in hypergrid\base\adaptive_hypergrid.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | |
TemporalHypergrid
hypergrid.base.temporal_hypergrid.TemporalHypergrid
Wrapper that adds temporal tracking to any hypergrid.
Applies optional exponential decay to old counts before each update and saves periodic snapshots of the distribution so drift can be measured.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grid
|
BaseTensorHypergrid instance
|
The underlying hypergrid (DenseTensorHypergrid, SparseHypergrid, etc.) |
required |
decay
|
float
|
Multiplicative factor applied to all counts before each update batch (e.g. 0.99 for slow forgetting). None means no decay. |
None
|
snapshot_interval
|
int
|
Save a snapshot every N data points processed. |
1000
|
Source code in hypergrid\base\temporal_hypergrid.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |
describe(percentiles=None)
evolution(method='js')
Compute divergence between consecutive snapshots.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
method
|
(js, kl, l1, wasserstein)
|
|
"js"
|
Returns:
| Type | Description |
|---|---|
list of float
|
|
Source code in hypergrid\base\temporal_hypergrid.py
plot_evolution(method='js')
Plot divergence between consecutive snapshots over time.
Source code in hypergrid\base\temporal_hypergrid.py
plot_temporal_umap(n_per_snapshot=500, **umap_kwargs)
UMAP projection of all snapshots coloured by snapshot index. Each snapshot contributes n_per_snapshot sampled points.