Expand description
Causal feature attribution via Asymmetric Shapley Values (ASV) over DAGs, for explainable AI (XAI) / SHAP-style feature importance with Rust + Python bindings.
§Quick Start
use causasv::{AsvExplainer, CausasvError, Dag};
fn main() -> Result<(), CausasvError> {
let mut dag = Dag::new();
let x = dag.add_node("X");
let y = dag.add_node("Y");
dag.add_edge(x, y)?;
let explainer = AsvExplainer::new(dag);
let result = explainer.exact(|coalition| Ok(coalition.len() as f64))?;
for (id, val) in &result.values {
println!("{id:?} = {val:.4}");
}
Ok(())
}For large graphs use AsvExplainer::approximate or AsvExplainer::auto.
See the README for Python usage and benchmarks.
Re-exports§
pub use asv::AsvExplainer;pub use asv::AsvResult;pub use asv::ExactTreeConfig;
Modules§
Structs§
- Adaptive
Sampling Config - Configuration for adaptive approximate ASV sampling.
- Cpdag
- Partially directed graph: some edges are compelled (directed), others are
unresolved (undirected). Node indexing mirrors
Dag: stableNodeIds assigned in insertion order. - Dag
- Directed acyclic graph with stable node indexing.
- Exact
DagConfig - Configuration for sparse order-ideal exact DAG DP.
- NodeId
- Stable handle to a node in a
Dag, assigned in insertion order starting at 0. Valid only for theDagthat created it — passing aNodeIdfrom a different (or stale)DagreturnsCausasvError::InvalidNodeId. - Sampling
Config - Configuration for approximate ASV sampling.
Enums§
- Causasv
Error - All ways a causasv operation can fail.
Functions§
- enumerate_
topos - Enumerates ALL valid topological orderings. Output is deterministic (frontier sorted by NodeId at each step). Only practical for small graphs (n ≤ ~8).
- topo_
sort - Returns a valid topological ordering (smallest NodeId first among ties).
Type Aliases§
- ValueFn
- Type alias for a value function over node coalitions. The library guarantees the coalition slice is sorted in ascending NodeId order before calling, so callers may use it as a stable cache key.