nx_conformal.nx
buildroot/runtime/nx_conformal.nx
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
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
structs
| 75 | struct NxConformalInterval |
| 91 | struct NxConformalModel |
| 233 | struct NxConformalCoverage |
consts
| 52 | const NX_CONF_Q10: nx_int = 1024 |
| 56 | const NX_CONF_MAX_CAL: nx_int = 1048576 |
| 57 | const NX_CONF_MIN_CAL: nx_int = 5 |
| 61 | const NX_CONF_MODE_SPLIT: nx_int = 0 |
| 62 | const NX_CONF_MODE_ADAPTIVE: nx_int = 1 |
| 68 | const NX_CONF_VERDICT_TIGHT: nx_int = 0 // width < tight_thr |
| 69 | const NX_CONF_VERDICT_USABLE: nx_int = 1 // width < usable_thr |
| 70 | const NX_CONF_VERDICT_WIDE: nx_int = 2 // width < wide_thr |
| 71 | const NX_CONF_VERDICT_BROKEN: nx_int = 3 // width >= wide_thr |
| 85 | const NX_CONF_INTERVAL_BYTES: nx_size = 56 |
| 97 | const NX_CONF_MODEL_BYTES: nx_size = 24 |
| 242 | const NX_CONF_COVERAGE_BYTES: nx_size = 48 |
| 245 | const NX_CONF_COVERAGE_TOLERANCE_Q10: nx_int = 102 |
functions
| 104 | func _conf_sort_ascending(arr: *nx_int, n: nx_int) -> nx_int called by 1: nx_conformal_calibrate |
| 131 | func nx_conformal_calibrate( |
| 172 | func _conf_quantile_q_alpha(model: *NxConformalModel, alpha_q10: nx_int) -> nx_int |
| 192 | func nx_conformal_predict( |
| 247 | func nx_conformal_check_coverage( |
| 287 | func main() -> nx_int |