compute_optimal_k (adaptive_sizer.rs)

headroom · analytics

Adaptive compression sizing via information saturation detection. ! ! Direct port of `headroom/transforms/adaptive_sizer.py`. Used by ! `smart_crusher`'s array crushers to decide *how many* items to keep — ! statistically, by detecting the "knee point" of an information ! satur

//! Adaptive compression sizing via information saturation detection.
//!
//! Direct port of `headroom/transforms/adaptive_sizer.py`. Used by
//! `smart_crusher`'s array crushers to decide *how many* items to keep —
//! statistically, by detecting the "knee point" of an information
//! saturation curve.
//!
//! # Algorithm overview
//!
//! Three-tier decision:
//! 1. **Fast path**: trivial cases (`n <= 8` → keep all) and near-total
//!    redundancy (≤3 unique-by-simhash → keep that count).
//! 2. **Standard**: Kneedle on cumulative unique-bigram coverage curve.
//!    Coverage stops growing → that's the knee → return that count.
//! 3. **Validation**: zlib-ratio sanity check. If keeping `k` items
//!    produces a much-more-redundant subset than the full set, bump
//!    `k` by 20%.
//!
/

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search 40K more like it.

Get a free API key