Assured Prediction: Examples
Each example is a verified run of a guided tour script from the shipped python/examples/
bundle (see PROGRESSION.md for the full 01→11 sequence). Run the guided tour
first: it narrates the scenario, explains each metric, and shows when to trust the result. Use
the production one-liner when wiring the same API call into your pipeline.
Beta release. Products in this catalog other than the SolvSRK family and SolvScout / SolvTune are beta — suitable for trials and evaluation; APIs and packaging may change before GA. Do not deploy beta builds in production programs without a signed agreement with Resonix. Activate a trial license before running examples — see Install and Licensing.
Journeys
Example 1: Journey 01 — First contact
Version, license, simplest gate_logits(). Every support ticket starts with the package version. The C engine is machine-locked (Ed25519).
Walkthrough:
-
What you are doing — Assured Prediction is a post-hoc selective prediction filter. Any classifier that emits softmax (or logits) can say "I don't know" on uncertain samples and keep only the confident slice. No retraining.
-
Version — Every support ticket starts with the package version.
version: 0.1.0native: 0.1.0
-
License — The C engine is machine-locked (Ed25519).
license_valid: True
-
Simplest call: gate_logits() — A peaked 4-class logit vector has low Shannon entropy, so the filter accepts the argmax prediction at a moderate epsilon.
accepted: Truepredicted_class: 0entropy: 0.40528max_prob: 0.906178
Guided tour output (from a verified run):
Version, license, simplest gate_logits()
-- Act 1 - What you are doing --
-> Assured Prediction is a post-hoc selective prediction filter. Any classifier that emits softmax (or logits) can say "I don't know" on uncertain samples and keep only the confident slice. No retraining.
-- Act 2 - Version --
-> Every support ticket starts with the package version.
version: 0.1.0
native: 0.1.0
-- Act 3 - License --
-> The C engine is machine-locked (Ed25519).
license_valid: True
-- Act 4 - Simplest call: gate_logits() --
-> A peaked 4-class logit vector has low Shannon entropy, so the filter accepts the argmax prediction at a moderate epsilon.
accepted: True
predicted_class: 0
entropy: 0.40528
max_prob: 0.906178
-- Run complete --
version: 0.1.0
accepted: True
next_journey: 02_core_path.pycd python
# Guided tour — narrated scenario walkthrough (recommended first run):
python examples/journeys/01_first_contact.py
# Production one-liner — same API call you ship:
python -c "import assured_prediction as ap; print(ap.__version__, ap.license_valid())"Example 2: Journey 02 — Core path (calibrate + filter)
Calibrate epsilon to a coverage target, then filter. AssuredFilter.from_coverage builds the epsilon once. Same epsilon filters the batch; accepted rows are keepers.
Walkthrough:
-
The dial — Coverage is the fraction of samples you keep. Request 50% and Assured Prediction sets epsilon to the entropy percentile that retains the most confident half.
-
Calibrate — AssuredFilter.from_coverage builds the epsilon once.
epsilon: 1.039879target_coverage: 0.5
-
Apply — Same epsilon filters the batch; accepted rows are keepers.
n_samples: 8n_accepted: 4coverage: 0.5predictions: [0, 0, 0, 0, 0, 0, 0, 0]accepted: [True, True, True, True, False, False, False, False]
Guided tour output (from a verified run):
Calibrate epsilon to a coverage target, then filter
-- Act 1 - The dial --
-> Coverage is the fraction of samples you keep. Request 50% and Assured Prediction sets epsilon to the entropy percentile that retains the most confident half.
-- Act 2 - Calibrate --
-> AssuredFilter.from_coverage builds the epsilon once.
epsilon: 1.039879
target_coverage: 0.5
-- Act 3 - Apply --
-> Same epsilon filters the batch; accepted rows are keepers.
n_samples: 8
n_accepted: 4
coverage: 0.5
predictions: [0, 0, 0, 0, 0, 0, 0, 0]
accepted: [True, True, True, True, False, False, False, False]
-- Run complete --
epsilon: 1.039879
coverage: 0.5
next_journey: 03_configuration.pycd python
# Guided tour — narrated scenario walkthrough (recommended first run):
python examples/journeys/02_core_path.py
# Production one-liner — same API call you ship:
python -c "from assured_prediction import AssuredFilter; ..."Example 3: Journey 03 — Configuration (coverage dial)
Coverage targets move epsilon and keep-rate together. As target coverage rises, epsilon should rise (more permissive) and more samples should be accepted.
Walkthrough:
-
Sweep the dial — Tighter coverage (keep fewer samples) lowers epsilon and raises accuracy on the retained set. Looser coverage does the opposite.
target: 0.25epsilon: 0.500858realized_coverage: 0.25n_accepted: 2target: 0.5epsilon: 0.641938realized_coverage: 0.5n_accepted: 4target: 0.75epsilon: 0.676793realized_coverage: 0.75n_accepted: 6
-
Monotonicity check — As target coverage rises, epsilon should rise (more permissive) and more samples should be accepted.
epsilons: [0.5009, 0.6419, 0.6768]accepted_counts: [2, 4, 6]
Guided tour output (from a verified run):
Coverage targets move epsilon and keep-rate together
-- Act 1 - Sweep the dial --
-> Tighter coverage (keep fewer samples) lowers epsilon and raises accuracy on the retained set. Looser coverage does the opposite.
target: 0.25
epsilon: 0.500858
realized_coverage: 0.25
n_accepted: 2
target: 0.5
epsilon: 0.641938
realized_coverage: 0.5
n_accepted: 4
target: 0.75
epsilon: 0.676793
realized_coverage: 0.75
n_accepted: 6
-- Act 2 - Monotonicity check --
-> As target coverage rises, epsilon should rise (more permissive) and more samples should be accepted.
epsilons: [0.5009, 0.6419, 0.6768]
accepted_counts: [2, 4, 6]
-- Run complete --
targets: [0.25, 0.5, 0.75]
next_journey: 04_diagnostics.pycd python
# Guided tour — narrated scenario walkthrough (recommended first run):
python examples/journeys/03_configuration.py
# Production one-liner — same API call you ship:
python -c "from assured_prediction import calibrate_epsilon, gate_batch_probs; ..."Example 4: Journey 04 — Diagnostics (entropy audit)
Entropy, max_prob, and accepted-set composition. Inspect every sample the filter sees. Operators review only abstained chips; auto-clear the accepted ones.
Walkthrough:
-
Shannon entropy — H(p) = -Σ p_i log(p_i + 1e-10). Peaked softmax → low H → accept. Flat softmax → high H → abstain.
peaked_entropy: 0.26183flat_entropy: 1.386294
-
Batch audit — Inspect every sample the filter sees.
i: 0accepted: Truecls: 0entropy: 0.1773max_prob: 0.9647i: 1accepted: Falsecls: 1entropy: 1.0978max_prob: 0.3501i: 2accepted: Truecls: 0entropy: 0.5604max_prob: 0.8316i: 3accepted: Falsecls: 2entropy: 1.0978max_prob: 0.3501i: 4accepted: Truecls: 0entropy: 0.3102max_prob: 0.9273i: 5accepted: Falsecls: 1entropy: 1.0984max_prob: 0.3423
-
Accepted set — Operators review only abstained chips; auto-clear the accepted ones.
epsilon: 0.829096coverage: 0.5kept_classes: [0, 0, 0]
Guided tour output (from a verified run):
Entropy, max_prob, and accepted-set composition
-- Act 1 - Shannon entropy --
-> H(p) = -Σ p_i log(p_i + 1e-10). Peaked softmax → low H → accept. Flat softmax → high H → abstain.
peaked_entropy: 0.26183
flat_entropy: 1.386294
-- Act 2 - Batch audit --
-> Inspect every sample the filter sees.
i: 0
accepted: True
cls: 0
entropy: 0.1773
max_prob: 0.9647
i: 1
accepted: False
cls: 1
entropy: 1.0978
max_prob: 0.3501
i: 2
accepted: True
cls: 0
entropy: 0.5604
max_prob: 0.8316
i: 3
accepted: False
cls: 2
entropy: 1.0978
max_prob: 0.3501
i: 4
accepted: True
cls: 0
entropy: 0.3102
max_prob: 0.9273
i: 5
accepted: False
cls: 1
entropy: 1.0984
max_prob: 0.3423
-- Act 3 - Accepted set --
-> Operators review only abstained chips; auto-clear the accepted ones.
epsilon: 0.829096
coverage: 0.5
kept_classes: [0, 0, 0]
-- Run complete --
coverage: 0.5
next_journey: 05_atr_scenario.pycd python
# Guided tour — narrated scenario walkthrough (recommended first run):
python examples/journeys/04_diagnostics.py
# Production one-liner — same API call you ship:
python -c "from assured_prediction import entropy, softmax; ..."Example 5: Journey 05 — Defense ATR scenario
A J2 cell gets thousands of SAR chips per day. Assured Prediction at 50% coverage auto-classifies the confident half and sends the rest to human review — same architecture validated on AFRL MSTAR (RADAR_S1). Use the batch itself as the entropy reference. Accepted chips auto-clear; abstained chips go to review.
Walkthrough:
-
Mission context — A J2 cell gets thousands of SAR chips per day. Assured Prediction at 50% coverage auto-classifies the confident half and sends the rest to human review — same architecture validated on AFRL MSTAR (RADAR_S1).
-
Calibrate on the window — Use the batch itself as the entropy reference.
epsilon: 0.751754target_coverage: 0.5n_chips: 8
-
Filter — Accepted chips auto-clear; abstained chips go to review.
auto_clear: ['orbit-A/chip-01->BMP2', 'orbit-A/chip-03->BMP2', 'orbit-B/chip-05->BTR70', 'orbit-B/chip-07->T72']review_queue: ['orbit-A/chip-02 (H=1.098)', 'orbit-A/chip-04 (H=1.098)', 'orbit-B/chip-06 (H=1.097)', 'orbit-B/chip-08 (H=1.099)']coverage: 0.5
-
Ensemble option — For production reliability, average softmax across N≥5 seeds before gating. Here two disagreeing models raise ensemble entropy.
ensemble_accepted: Falseensemble_entropy: 0.7697
Guided tour output (from a verified run):
Auto-clear confident SAR chips; route uncertain ones to analysts
-- Act 1 - Mission context --
-> A J2 cell gets thousands of SAR chips per day. Assured Prediction at 50% coverage auto-classifies the confident half and sends the rest to human review — same architecture validated on AFRL MSTAR (RADAR_S1).
-- Act 2 - Calibrate on the window --
-> Use the batch itself as the entropy reference.
epsilon: 0.751754
target_coverage: 0.5
n_chips: 8
-- Act 3 - Filter --
-> Accepted chips auto-clear; abstained chips go to review.
auto_clear: ['orbit-A/chip-01->BMP2', 'orbit-A/chip-03->BMP2', 'orbit-B/chip-05->BTR70', 'orbit-B/chip-07->T72']
review_queue: ['orbit-A/chip-02 (H=1.098)', 'orbit-A/chip-04 (H=1.098)', 'orbit-B/chip-06 (H=1.097)', 'orbit-B/chip-08 (H=1.099)']
coverage: 0.5
-- Act 4 - Ensemble option --
-> For production reliability, average softmax across N≥5 seeds before gating. Here two disagreeing models raise ensemble entropy.
ensemble_accepted: False
ensemble_entropy: 0.7697
-- Run complete --
coverage: 0.5
n_review: 4
next_journey: 06_limits.pycd python
# Guided tour — narrated scenario walkthrough (recommended first run):
python examples/journeys/05_atr_scenario.py
# Production one-liner — same API call you ship:
python -c "from assured_prediction import AssuredFilter; ..."Example 6: Journey 06 — Limits
Honest scope: what Assured Prediction is NOT. When every sample is already high-confidence, a very low coverage target can still accept samples — or look empty if epsilon collapses. Tune the floor to your base-model accuracy. Coverage must be in (0, 1].
Walkthrough:
-
Post-hoc filter only — Assured Prediction does not retrain the model, does not improve weak models below ~20% baseline, and does not replace model quality. It trades coverage for accuracy on the retained slice.
-
Aggressive coverage on peaked models — When every sample is already high-confidence, a very low coverage target can still accept samples — or look empty if epsilon collapses. Tune the floor to your base-model accuracy.
epsilon: 0.111902coverage: 0.0n_accepted: 0
-
Bad arguments raise — Coverage must be in (0, 1].
error: calibrate_epsilon: value out of rangevalue_error_raised: True
-
Sibling products — Need bit-identical decision receipts? Use DeterministicML. Need tracking consistency? SolvFilter. Need dynamics integration? SolvSRK. Assured Prediction is the selective gate in front of any softmax head.
Guided tour output (from a verified run):
Honest scope: what Assured Prediction is NOT
-- Act 1 - Post-hoc filter only --
-> Assured Prediction does not retrain the model, does not improve weak models below ~20% baseline, and does not replace model quality. It trades coverage for accuracy on the retained slice.
-- Act 2 - Aggressive coverage on peaked models --
-> When every sample is already high-confidence, a very low coverage target can still accept samples — or look empty if epsilon collapses. Tune the floor to your base-model accuracy.
epsilon: 0.111902
coverage: 0.0
n_accepted: 0
-- Act 3 - Bad arguments raise --
-> Coverage must be in (0, 1].
error: calibrate_epsilon: value out of range
value_error_raised: True
-- Act 4 - Sibling products --
-> Need bit-identical decision receipts? Use DeterministicML. Need tracking consistency? SolvFilter. Need dynamics integration? SolvSRK. Assured Prediction is the selective gate in front of any softmax head.
-- Run complete --
value_error_raised: Truecd python
# Guided tour — narrated scenario walkthrough (recommended first run):
python examples/journeys/06_limits.py
# Production one-liner — same API call you ship:
python -c "from assured_prediction import calibrate_epsilon; calibrate_epsilon([[0.5,0.5]], 0.0)"Example 7: Journey 07 — Calibrated production path
Scalar T minimizes NLL on labeled calibration rows before ε calibration.", ) temp = ap.fit_temperature(cal_probs, cal_labels) con.kv(temperature=round(temp, 3)) act( con, 2, "Build CalibratedAssuredFilter", "Same temperature at inference; ε calibrated on scaled cal probs.", ) filt = ap.CalibratedAssuredFilter.from_coverage( cal_probs, cal_labels, target_coverage=0.75 ) out = filt.apply_probs(test_probs) con.kv( epsilon=round(filt.epsilon, 6), coverage=round(out.coverage, 3), accepted=out.accepted, ) act( con, 3, "Stratified cal split (optional)", "Use stratified_cal_test_split so rare classes contribute to ε.", ) rows = [{"probs": p, "gt_label": y} for p, y in zip(cal_probs, cal_labels)] cal_rows, test_rows = ap.stratified_cal_test_split(rows, cal_fraction=0.25, seed=42) con.kv(n_cal=len(cal_rows), n_test=len(test_rows)) con.finish( coverage=round(out.coverage, 3), next_journey="08_group_routing.py.
Walkthrough:
- Fit temperature on cal set — Scalar T minimizes NLL on labeled calibration rows before ε calibration.", ) temp = ap.fit_temperature(cal_probs, cal_labels) con.kv(temperature=round(temp, 3)) act( con, 2, "Build CalibratedAssuredFilter", "Same temperature at inference; ε calibrated on scaled cal probs.", ) filt = ap.CalibratedAssuredFilter.from_coverage( cal_probs, cal_labels, target_coverage=0.75 ) out = filt.apply_probs(test_probs) con.kv( epsilon=round(filt.epsilon, 6), coverage=round(out.coverage, 3), accepted=out.accepted, ) act( con, 3, "Stratified cal split (optional)", "Use stratified_cal_test_split so rare classes contribute to ε.", ) rows = [{"probs": p, "gt_label": y} for p, y in zip(cal_probs, cal_labels)] cal_rows, test_rows = ap.stratified_cal_test_split(rows, cal_fraction=0.25, seed=42) con.kv(n_cal=len(cal_rows), n_test=len(test_rows)) con.finish( coverage=round(out.coverage, 3), next_journey="08_group_routing.py
cd python
# Guided tour — narrated scenario walkthrough (recommended first run):
python examples/journeys/07_calibrated_production.py
# Production one-liner — same API call you ship:
CalibratedAssuredFilter.from_coverage(probs, labels, 0.95)Example 8: Journey 08 — Group routing
Single ε for all classes — uniform abstention profile.", ) global_filt = ap.AssuredFilter.from_coverage(cal_probs, target_coverage=0.75) global_out = global_filt.apply_probs(test_probs) global_diag = ap.abstention_by_predicted_class(test_probs, global_filt.epsilon) con.kv( epsilon=round(global_filt.epsilon, 6), coverage=round(global_out.coverage, 3), abstention_by_class=global_diag, ) act( con, 2, "GroupAssuredFilter", "Calibrate ε per group on cal rows assigned by argmax class.", ) group_filt = ap.GroupAssuredFilter.from_coverage( cal_probs, GROUPS, target_coverage=0.75, coverage_by_group={"confusable": 0.60, "easy": 0.85}, min_cal_per_group=3, ) group_out = group_filt.apply_probs(test_probs) con.kv( epsilon_by_group={k: round(v, 6) for k, v in group_filt.epsilon_by_group.items()}, coverage=round(group_out.coverage, 3), accepted=group_out.accepted, ) act( con, 3, "vs confidence baseline", "At matched keep-rate, entropy routing can differ from max-prob cutoff.
Walkthrough:
- Global filter baseline — Single ε for all classes — uniform abstention profile.", ) global_filt = ap.AssuredFilter.from_coverage(cal_probs, target_coverage=0.75) global_out = global_filt.apply_probs(test_probs) global_diag = ap.abstention_by_predicted_class(test_probs, global_filt.epsilon) con.kv( epsilon=round(global_filt.epsilon, 6), coverage=round(global_out.coverage, 3), abstention_by_class=global_diag, ) act( con, 2, "GroupAssuredFilter", "Calibrate ε per group on cal rows assigned by argmax class.", ) group_filt = ap.GroupAssuredFilter.from_coverage( cal_probs, GROUPS, target_coverage=0.75, coverage_by_group={"confusable": 0.60, "easy": 0.85}, min_cal_per_group=3, ) group_out = group_filt.apply_probs(test_probs) con.kv( epsilon_by_group={k: round(v, 6) for k, v in group_filt.epsilon_by_group.items()}, coverage=round(group_out.coverage, 3), accepted=group_out.accepted, ) act( con, 3, "vs confidence baseline", "At matched keep-rate, entropy routing can differ from max-prob cutoff.
cd python
# Guided tour — narrated scenario walkthrough (recommended first run):
python examples/journeys/08_group_routing.py
# Production one-liner — same API call you ship:
GroupAssuredFilter.from_coverage(probs, groups, 0.95)Example 9: Journey 09 — 09 Production Pipeline
Calibrated filter when labels are present.") filt, cal, test = ap.split_and_build(rows, target_coverage=0.75, cal_fraction=0.25, seed=42) out = filt.apply_probs([r["probs"] for r in test]) con.kv(n_cal=len(cal), n_test=len(test), coverage=round(out.coverage, 3)) act(con, 2, "Group routing", "Optional asymmetric keep-rates per class family.") groups = {"easy": [0], "hard": [1, 2]} filt2 = ap.build_production_filter( [r["probs"] for r in cal], [r["gt_label"] for r in cal], target_coverage=0.75, groups=groups, coverage_by_group={"easy": 0.85, "hard": 0.55}, min_cal_per_group=1, ) out2 = filt2.apply_probs([r["probs"] for r in test]) con.kv(group_coverage=round(out2.coverage, 3), type=type(filt2).name) act(con, 3, "Baseline check", "Holdout compare vs max-prob threshold.
Walkthrough:
- Default path — Calibrated filter when labels are present.") filt, cal, test = ap.split_and_build(rows, target_coverage=0.75, cal_fraction=0.25, seed=42) out = filt.apply_probs([r["probs"] for r in test]) con.kv(n_cal=len(cal), n_test=len(test), coverage=round(out.coverage, 3)) act(con, 2, "Group routing", "Optional asymmetric keep-rates per class family.") groups = {"easy": [0], "hard": [1, 2]} filt2 = ap.build_production_filter( [r["probs"] for r in cal], [r["gt_label"] for r in cal], target_coverage=0.75, groups=groups, coverage_by_group={"easy": 0.85, "hard": 0.55}, min_cal_per_group=1, ) out2 = filt2.apply_probs([r["probs"] for r in test]) con.kv(group_coverage=round(out2.coverage, 3), type=type(filt2).name) act(con, 3, "Baseline check", "Holdout compare vs max-prob threshold.
cd python
# Guided tour — narrated scenario walkthrough (recommended first run):
python examples/journeys/09_production_pipeline.py
# Production one-liner — same API call you ship:
python examples/journeys/09_production_pipeline.pyExample 10: Journey 10 — 10 Compliance Receipts
Guided domain scenario with narrated console walkthrough.
cd python
# Guided tour — narrated scenario walkthrough (recommended first run):
python examples/journeys/10_compliance_receipts.py
# Production one-liner — same API call you ship:
python examples/journeys/10_compliance_receipts.pyExample 11: Journey 11 — 11 Experimental Conformal
Guided domain scenario with narrated console walkthrough.
cd python
# Guided tour — narrated scenario walkthrough (recommended first run):
python examples/journeys/11_experimental_conformal.py
# Production one-liner — same API call you ship:
python examples/journeys/11_experimental_conformal.pyExample bundle
Every journey is a domain scenario with narrated acts — run the guided tour first to see what each number means, then copy the production one-liner into your pipeline.
| Resource | Purpose |
|---|---|
PROGRESSION.md | Core runbook — journeys 01→06 with dual commands |
SKU_PROGRESSION.md | Vertical SKU runbook — Grid, Pricing, Control, Climate, Thermal, Specialty |
COVERAGE.md | Capability matrix — which APIs each journey exercises |
APPLICATIONS.md | Where the product applies in real programs |
run_examples.py | Interactive menu for core journeys |
run_sku_examples.py | Interactive menu for vertical SKU walkthroughs |
Guided journeys
| # | Script | Scenario |
|---|---|---|
| 01 | 01_first_contact.py | Version, license, simplest gate_logits() |
| 02 | 02_core_path.py | Calibrate epsilon to a coverage target, then filter |
| 03 | 03_configuration.py | Coverage targets move epsilon and keep-rate together |
| 04 | 04_diagnostics.py | Entropy, max_prob, and accepted-set composition |
| 05 | 05_atr_scenario.py | A J2 cell gets thousands of SAR chips per day. Assured Prediction at 50% coverage auto-cla… |
| 06 | 06_limits.py | Honest scope: what Assured Prediction is NOT |
| 07 | 07_calibrated_production.py | Calibrated production path |
| 08 | 08_group_routing.py | Group routing |
| 09 | 09_production_pipeline.py | 09 production pipeline |
| 10 | 10_compliance_receipts.py | 10 compliance receipts |
| 11 | 11_experimental_conformal.py | 11 experimental conformal |
Run from the python/ directory after install and license activation.
Set ASSURED_PREDICTION_QUIET=1 only when you want silent CLI runs (no narration).