geno_lewm.surprise.calibration¶
calibration
¶
Calibration-table builder and Parquet IO for RFC-0009.
CALIBRATION_SCHEMA_VERSION
module-attribute
¶
On-disk calibration table schema version.
DEFAULT_CDF_POINTS
module-attribute
¶
Number of points in each empirical CDF grid.
DEFAULT_REFERENCE_PER_BUCKET
module-attribute
¶
Default maximum number of reference variants sampled per bucket.
LOW_CONFIDENCE_BUCKET_SIZE
module-attribute
¶
Buckets below this size are marked low-confidence by RFC-0009.
CalibrationExample
dataclass
¶
One pre-scored reference variant used to build calibration CDFs.
CalibrationWarning
dataclass
¶
CalibrationWarning(bucket_id: str, resolved_bucket_id: str, n_calibration: int, min_bucket_size: int, low_confidence: bool)
Sparse-bucket warning emitted while building a calibration table.
CalibrationBucket
dataclass
¶
CalibrationTable
dataclass
¶
CalibrationTable(buckets: tuple[CalibrationBucket, ...], warnings: tuple[CalibrationWarning, ...] = (), schema_version: str = CALIBRATION_SCHEMA_VERSION)
In-memory representation of calibration.parquet.
get
¶
Return a bucket by ID, or None if absent.
require
¶
Return a bucket by ID, raising InputError when absent.
Source code in geno_lewm/surprise/calibration.py
resolve
¶
resolve(label_or_bucket: str, *, min_bucket_size: int = DEFAULT_MIN_BUCKET_SIZE) -> CalibrationBucket
Resolve a sparse bucket through the table's fixed backoff chain.
Source code in geno_lewm/surprise/calibration.py
build_calibration_table
¶
build_calibration_table(examples: Iterable[CalibrationExample], *, seed: int = 0, per_bucket_sample: int = DEFAULT_REFERENCE_PER_BUCKET, grid_size: int = DEFAULT_CDF_POINTS, min_bucket_size: int = DEFAULT_MIN_BUCKET_SIZE, low_confidence_size: int = LOW_CONFIDENCE_BUCKET_SIZE, warn_sparse: bool = True) -> CalibrationTable
Build deterministic empirical CDF buckets from pre-scored examples.
Source code in geno_lewm/surprise/calibration.py
191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | |
write_calibration_table
¶
Write a calibration table to calibration.parquet.
Source code in geno_lewm/surprise/calibration.py
read_calibration_table
¶
Read and validate a calibration Parquet file.