antecedent.attribution

Attribution helpers.

 1"""Attribution helpers."""
 2
 3from __future__ import annotations
 4
 5from ._native import (
 6    AnomalyScores,
 7    ChangeAttributionResult,
 8    Contribution,
 9    FeatureRelevance,
10    MechanismChangeDetection,
11    anomaly_attribution,
12    attribute_distribution_change,
13    attribute_distribution_change_robust,
14    attribute_feature_relevance,
15    attribute_path_specific,
16    attribute_paths,
17    attribute_structure_change,
18    attribute_unit_change,
19    mechanism_change_detection,
20    rank_root_causes,
21)
22
23__all__ = [
24    "AnomalyScores",
25    "ChangeAttributionResult",
26    "Contribution",
27    "FeatureRelevance",
28    "MechanismChangeDetection",
29    "anomaly_attribution",
30    "attribute_distribution_change",
31    "attribute_distribution_change_robust",
32    "attribute_feature_relevance",
33    "attribute_path_specific",
34    "attribute_paths",
35    "attribute_structure_change",
36    "attribute_unit_change",
37    "mechanism_change_detection",
38    "rank_root_causes",
39]
class AnomalyScores:

Anomaly scores for one outcome.

n_units
outcome
mean_score
class ChangeAttributionResult:

Change-attribution summary (components and optional path breakdown).

path_breakdown
total_change
contributions
class Contribution:

Named contribution (node or path label).

score
name
class FeatureRelevance:

Feature relevance under interventions.

score
feature
class MechanismChangeDetection:

Mechanism-change detection for one node.

changed
statistic
p_value
node
def anomaly_attribution(names, columns, edges, outcomes, *, max_units=0):

Anomaly scores for listed outcomes.

def attribute_distribution_change( names, columns, edges, outcome, baseline_start, baseline_end, comparison_start, comparison_end, *, n_samples=500, seed=0, threads=1):

Fit GCM and attribute distribution change between two row ranges via Shapley.

def attribute_distribution_change_robust( names, columns, edges, outcome, baseline_start, baseline_end, comparison_start, comparison_end, *, n_samples=500, seed=0, threads=1):

Robust distribution-change attribution between two row ranges.

def attribute_feature_relevance( names, columns, edges, outcome, *, delta=1.0, n_samples=200, seed=0, threads=1):

Feature relevance scores for parents of outcome.

def attribute_path_specific( names, columns, edges, treatment, outcome, *, path_nodes=None, max_paths=64, max_len=16, seed=0, threads=1):

Path-specific contribution via [PathSpecificEffectQuery] / path_decompose.

def attribute_paths( names, columns, edges, sources, outcome, *, max_paths=64, max_len=16, seed=0, threads=1):

Path decomposition (all paths from sources to outcome).

def attribute_structure_change( names, columns, baseline_edges, comparison_edges, outcome, baseline_start, baseline_end, comparison_start, comparison_end, *, n_samples=500, seed=0, threads=1):

Structure-change attribution between two edge lists (parent-set Shapley).

def attribute_unit_change(names, columns, edges, outcome, *, max_units=0, seed=0, threads=1):

Unit-level change attribution.

def mechanism_change_detection( names, columns, edges, baseline_start, baseline_end, comparison_start, comparison_end, *, seed=0, threads=1):

Detect mechanism changes across two row ranges.

def rank_root_causes(attribution, *, seed=0, threads=1):

Rank root causes from a [ChangeAttributionResult].