antecedent.model
Interventional sampling helpers.
1"""Interventional sampling helpers.""" 2 3from __future__ import annotations 4 5from ._native import ( 6 FittedGcm, 7 GcmSampleResult, 8 fit_gcm, 9 sample_do, 10 sample_interventional_distribution, 11) 12 13__all__ = [ 14 "FittedGcm", 15 "GcmSampleResult", 16 "fit_gcm", 17 "sample_do", 18 "sample_interventional_distribution", 19]
Fitted GCM retained across Python calls (fit once, sample / attribute many times).
Model, data, and names are [Arc]-shared so GIL-detached methods clone handles
instead of deep-copying the fitted session on every click.
Interventional ancestral sample under hard do values.
Unit-level ITE under hard interventions on treatment.
Interventional samples under hard do (means + full draws).
Fit a linear-Gaussian GCM; return a reusable [FittedGcm].
Fit GCM and return interventional column means + draws under hard do(treatment=value).
mechanism_wrappers maps variable name → object with sample_noise(n) / evaluate(parents, noise)
( slow path).
Sample an interventional distribution via [InterventionalDistributionQuery].
Same return shape as [gcm_sample_do]; builds the typed query then samples.