code wiki / (root) / nx_conformal.nx

nx_conformal.nx

buildroot/runtime/nx_conformal.nx

13917 B400 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_conformal.nx -- distribution-free prediction intervals. Vovk/Gammerman/Shafer 2005 ("Algorithmic Learning in a Random World"): for any black-box predictor f, conformal prediction builds a prediction SET around f(x_new) with EMPIRICAL COVERAGE guarantee. No distributional assumption. No model retraining. Given calibration set {(x_i, y_i)} of size n and a non- conformity score s_i = |y_i - f(x_i)|: q_alpha = ceil((n+1)(1-alpha)) / n quantile of {s_i} Predicted set for x_new: [f(x_new) - q_alpha, f(x_new) + q_alpha] Guarantee (Vovk Theorem 2.1): P(y_new in predicted_set) >= 1 - alpha for exchangeable data. The structural answer to "i want to predicitably make an 18 year old human whether male or female or have you not hallucinate into c, i cant get that in the current setup." Without conformal, model says "age 22" but true age is some random thing. WITH conformal: "age 22; with 90% coverage, true age in [19, 27]" (distribution-free, model-agnostic). Two modes: SPLIT -- standard split-conformal (Papadopoulos 2002): calibration set held out; gives a single q_alpha. ADAPTIVE -- locally-weighted conformal (Lei/Wasserman 2014): nonconformity scores weighted by feature density; narrower intervals where data is dense. (Stub -- returns SPLIT result with weights=1 for v1.) genealogy_id: vovk_2005_papadopoulos_2002 lineage_id: substrate_conformal_v1 5W+H+GLP linkage: per-prediction emit VERDICT record with what=VERDICT, how=conformal, performance=interval_width_q10.

dependencies 3 imports · 0 importers

nx_syscalls.nx nx_runtime.nx nx_tier.nx nx_conformal.nx

imports: nx_syscalls.nxnx_runtime.nxnx_tier.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sys_mmap nx_conformal_calibrate sys_mmap ↻ _conf_sort_ascending _conf_quantile_q_alpha nx_conformal_predict _conf_quantile_q_alpha ↻ sys_mmap ↻ nx_conformal_check_coverag _conf_quantile_q_alpha ↻ sys_mmap ↻

structs

75struct NxConformalInterval
91struct NxConformalModel
233struct NxConformalCoverage

consts

52const NX_CONF_Q10: nx_int = 1024
56const NX_CONF_MAX_CAL: nx_int = 1048576
57const NX_CONF_MIN_CAL: nx_int = 5
61const NX_CONF_MODE_SPLIT: nx_int = 0
62const NX_CONF_MODE_ADAPTIVE: nx_int = 1
68const NX_CONF_VERDICT_TIGHT: nx_int = 0 // width < tight_thr
69const NX_CONF_VERDICT_USABLE: nx_int = 1 // width < usable_thr
70const NX_CONF_VERDICT_WIDE: nx_int = 2 // width < wide_thr
71const NX_CONF_VERDICT_BROKEN: nx_int = 3 // width >= wide_thr
85const NX_CONF_INTERVAL_BYTES: nx_size = 56
97const NX_CONF_MODEL_BYTES: nx_size = 24
242const NX_CONF_COVERAGE_BYTES: nx_size = 48
245const NX_CONF_COVERAGE_TOLERANCE_Q10: nx_int = 102

functions

104func _conf_sort_ascending(arr: *nx_int, n: nx_int) -> nx_int
131func nx_conformal_calibrate(
called by 1: main calls 2: sys_mmap_conf_sort_ascending
172func _conf_quantile_q_alpha(model: *NxConformalModel, alpha_q10: nx_int) -> nx_int
192func nx_conformal_predict(
called by 1: main calls 2: _conf_quantile_q_alphasys_mmap
247func nx_conformal_check_coverage(
called by 1: main calls 2: _conf_quantile_q_alphasys_mmap
287func main() -> nx_int