antecedent.counterfactual
GCM counterfactual helpers.
class
FittedGcm:
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.
def
sample_do(self, /, interventions, n, *, seed=0, threads=1):
Interventional ancestral sample under hard do values.
def
counterfactual_ite(self, /, treatment, outcome, active, control, *, seed=0, threads=1):
Unit-level ITE under hard interventions on treatment.
def
attribute_path_specific( self, /, treatment, outcome, *, path_nodes=None, max_paths=64, max_len=16, seed=0, threads=1):
def
attribute_distribution_change( self, /, outcome, baseline_start, baseline_end, comparison_start, comparison_end, *, n_samples=500, seed=0, threads=1):
def
attribute_distribution_change_robust( self, /, outcome, baseline_start, baseline_end, comparison_start, comparison_end, *, n_samples=500, seed=0, threads=1):
def
attribute_structure_change( self, /, comparison_edges, outcome, baseline_start, baseline_end, comparison_start, comparison_end, *, n_samples=500, seed=0, threads=1):
class
GcmIteResult:
Result of a GCM counterfactual ITE (single boundary crossing).
def
counterfactual_ite( names, columns, edges, treatment, outcome, active, control, *, seed=0, threads=1):
Fit a linear-Gaussian GCM and return mean ITE under hard interventions.
Crosses the Python boundary once: NumPy columns + edges in, arrays out.
def
fit_gcm(names, columns, edges, *, threads=1):
Fit a linear-Gaussian GCM; return a reusable [FittedGcm].