quantization
Quantization functions for VSUP.
This module provides functions for quantizing value and uncertainty pairs into discrete levels for visualization. Quantization is an important step in VSUP that helps reduce the complexity of the visualization while maintaining the essential patterns in the data.
The module provides two quantization strategies:
- Linear quantization: Independently bins values and uncertainties into equal-width intervals. This is simpler but may not capture the relationship between value and uncertainty.
- Tree quantization: Uses a hierarchical approach where the number of value bins depends on the uncertainty level. Higher uncertainty means fewer value bins, reflecting the reduced confidence in precise value distinctions.
linear_quantization(n_levels)
Create a linear quantization function that bins both value and uncertainty into n_levels discrete levels.
This function creates a quantizer that independently divides both the value and uncertainty ranges into n_levels equal-width bins. This is the simplest form of quantization and treats value and uncertainty as independent variables.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n_levels
|
int
|
Number of quantization levels for both value and uncertainty. Must be >= 2. |
required |
Returns:
Type | Description |
---|---|
function
|
A function that takes (value, uncertainty) arrays and returns quantized versions with values in [0, 1] range. |
Notes
The returned function performs the following steps: 1. Creates equal-width bins for both value and uncertainty 2. Assigns each input to its corresponding bin 3. Normalizes the bin indices to [0, 1] range
Source code in vsup/quantization.py
tree_quantization(branching, layers)
Create a tree quantization function that bins value and uncertainty into branching^layers discrete levels.
This function creates a quantizer that uses a hierarchical approach where the number of value bins depends on the uncertainty level. Higher uncertainty means fewer value bins, reflecting the reduced confidence in precise value distinctions. This approach better captures the relationship between value and uncertainty.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
branching
|
int
|
Number of branches at each node. This determines how many value bins are created for each uncertainty level. |
required |
layers
|
int
|
Number of layers in the tree. This determines the number of uncertainty levels and the maximum number of value bins (branching^(layers-1)). |
required |
Returns:
Type | Description |
---|---|
function
|
A function that takes (value, uncertainty) arrays and returns quantized versions with values in [0, 1] range. |
Notes
The returned function performs the following steps: 1. Divides uncertainty range into 'layers' levels 2. For each uncertainty level, creates branching^(layers-1-level) value bins 3. Assigns values to bins based on their uncertainty level 4. Normalizes the results to [0, 1] range
Source code in vsup/quantization.py
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 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
|
handler: python options: show_root_heading: false show_source: false