Skip to main content

Measurement-Mechanistic RCA

Python package for measurement-mechanistic root cause analysis from the NeurIPS paper Root Cause Analysis of Measurement and Mechanistic Anomalies.

This package exposes the method for practical use without requiring the full paper replication package. By default it uses a pure-Python spline expectile backend and has no R dependency.

Repository, executable notebook examples, and the full replication package are available at github.com/hsuhr99/measurement_mechanistic_rca.

Installation

Install the method package:

pip install measurement-mechanistic-rca

Install the optional NoGAM causal-discovery helper:

pip install "measurement-mechanistic-rca[causal-discovery]"

Install the optional R/qgam comparison backend only if R, qgam, mgcv, and rpy2 are available:

pip install "measurement-mechanistic-rca[qgam]"

Quick Start

The graph must be a networkx.DiGraph, and data must be an n x d NumPy array whose columns match the graph node indices.

import networkx as nx
import numpy as np

from measurement_mechanistic_rca import MeasurementMechanisticRCA

dag = nx.DiGraph([(0, 1), (1, 2)])
data = np.random.normal(size=(100, 3))

model = MeasurementMechanisticRCA()
result = model.fit_explain(data, dag)

print(result.assignment)
print(result.top_features(sample_idx=0, k=3))

result.feature_scores[i, j] scores feature j as a root cause for sample i. result.classifications[i, j] is 1 for measurement-origin explanations and 0 for generative-origin explanations.

Provided Priors

If you have prior probabilities for measurement and generative anomalies, pass them directly. Priors can be global vectors of shape (d,) or sample-specific arrays of shape (n, d).

measurement_priors = np.array([0.01, 0.10, 0.01])
generative_priors = np.array([0.02, 0.02, 0.05])

result = model.fit_explain(
    data,
    dag,
    measurement_priors=measurement_priors,
    generative_priors=generative_priors,
)

Clean Training Data

When mechanisms are learned from uncontaminated data, priors must be provided for inference on new samples.

model = MeasurementMechanisticRCA()
model.fit(clean_data, dag)
result = model.explain(
    new_samples,
    measurement_priors=measurement_priors,
    generative_priors=generative_priors,
)

Causal Discovery

If the causal graph is unknown, the optional NoGAM helper can learn a DAG before RCA:

from measurement_mechanistic_rca import MeasurementMechanisticRCA, discover_dag_nogam

learned_dag = discover_dag_nogam(clean_data, n_crossval=3)
result = MeasurementMechanisticRCA().fit_explain(data, learned_dag)

NoGAM is bundled through the optional causal-discovery extra and has no R dependency.

Replication Package

This PyPI package is intentionally lightweight. It includes the high-level RCA API, the minimal cali method implementation, and optional NoGAM support. It does not include the full NeurIPS replication package, experiment runners, plots, results, TOPIC, M2OE, or other external baselines.

For exact paper experiments, use the git repository and the replication instructions there.

Citation

@inproceedings{suhr:2026:rca,
  title={Root Cause Analysis of Measurement and Mechanistic Anomalies},
  author={Hendrik Suhr and David Kaltenpoth and Jilles Vreeken},
  booktitle={Advances in Neural Information Processing Systems},
  volume={39},
  year={2026},
  url={https://openreview.net/forum?id=2sxylzR1R2}
}

License

Original code developed for this package is released under CC BY 4.0. Bundled or adapted external code remains under the licenses of the respective upstream projects; see the source distribution's third-party notices.

Metadata

Release files for measurement-mechanistic-rca 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for measurement-mechanistic-rca 0.1.1
File Size Uploaded Provenance
measurement_mechanistic_rca-0.1.1.tar.gz 142.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for measurement-mechanistic-rca 0.1.1
File Interpreter ABI Platform
measurement_mechanistic_rca-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 315.1 kB

Release files / measurement_mechanistic_rca-0.1.1.tar.gz

Download URL measurement_mechanistic_rca-0.1.1.tar.gz
Size 142.5 kB
Tags Source
SHA-256 checksum
How to use checksums
7dd72ac47a5d6e0ab9bbf131b5846e8e5d8417ca2648ef613053f11028420a26
BLAKE2b-256 checksum
How to use checksums
93339d18c759aa1394aa5e7777d496f5c96562cd5051d5e53e88b78cdc98ec84
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Release files / measurement_mechanistic_rca-0.1.1-py3-none-any.whl

Download URL measurement_mechanistic_rca-0.1.1-py3-none-any.whl
Size 172.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a297c9ad574803a585427d8418fe1853880d7241706b8ad44032f8c2ea925b4b
BLAKE2b-256 checksum
How to use checksums
8be2aae59a6d22be4e2c8586e190c1f14d3dc2fc1a1965a65771f43f55c3fa9b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.10

Security for measurement-mechanistic-rca 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page