mixle.reason.transport_edge module

Per-edge premise checks for cross-modal transport.

Every real modality edge should prove that a plain conditional transport is usable and calibrated on that edge’s own data before the edge is trusted in a belief graph. Calibration is checked against held-out truth for the edge rather than transferred from unrelated examples.

This module exposes a reusable per-edge check with two decisions:

  • premise fails: the edge should not be used for cross-modal purposes;

  • premise passes: the plain conditional transport may be composed as-is.

The check focuses on calibration because a genuine edge usually does not have a closed-form reference posterior. Coverage of the transport’s credible intervals against held-out truth is the available metric for a real edge.

class EdgeTransportVerdict(edge_name, usable, coverage_rates=<factory>, p_values=<factory>, reason='')[source]

Bases: object

Premise decision for one real modality edge, computed on that edge.

Parameters:
coverage_consistent_with_nominal(covered_flags)[source]

(observed_rate, p_value) for a two-sided binomial test of coverage against 1 - ALPHA.

Return type:

tuple[float, float]

fit_conditional_transport(data, *, x_dim, y_dim, k=3, max_its=30, m_steps=80, lr=3e-3, seed=0, delta=1.0e-9, reuse_estep_ll=True)[source]

Fit p(cond | target) and return a sampler with sample_given.

Uses mixle.models.mixture_density.build_mdn() and NeuralConditionalDensity, fit through optimize(). Pass delta=None, reuse_estep_ll=False for an edge whose relationship needs the full iteration budget rather than early stopping.

Parameters:
marginal_coverage(sampler, x_test, y_test, *, n_draws=200)[source]

Return per-dimension credible-interval coverage flags.

Parameters:

n_draws (int)

verify_edge_transport(edge_name, sampler, x_test, y_test, *, n_draws=200)[source]

Check one fitted edge sampler against held-out calibration data.

Parameters:
  • edge_name (str)

  • n_draws (int)

Return type:

EdgeTransportVerdict