Skip to main content

iSCAN

The iscan-dag library is a Python 3 package designed for detecting which variables, if any, have undergo a casual mechanism shift given multiple datasets.

iSCAN operates through a systematic process:

  1. For each dataset, iSCAN initially evaluates at each sample the Hessian of the data distribution. This step is helpful in identifying the leaf variables (nodes) for all the datasets.
  2. Subsequently, for the identified leaf variable, iSCAN evaluates at each sample the Hessian of the data distribution for the pooled data (resembling a mixture distribution). Then, based on the variance of the Hessian values, iSCAN determines if the given leaf node has undergone a mechanism shift (termed shifted node).

The steps above are applied iteratively, eliminating the identified leaf variable across all datasets at each iteration. See iscan.est_node_shifts for more details.

As an optional step, the library also includes a function to detect structural changes (termed shifted edges). As a by-product of detecting shifted nodes, iSCAN also estimates a topological ordering of the causal variables. Thus, allowing for the use of recent methods on variable (parents) selection. The current implementation of iSCAN employs FOCI to identify the parent set of shifted nodes in each dataset. See iscan.est_struct_shifts for more details.

Citation

This is an implementation of the following paper:

[1] Chen T., Bello K., Aragam B., Ravikumar P. (2023). "iSCAN: Identifying Causal Mechanism Shifts among Nonlinear Additive Noise Models". Neural Information Processing Systems (NeurIPS).

If you find this code useful, please consider citing:

BibTeX

@article{chen2023iscan,
    author = {Chen, Tianyu and Bello, Kevin and Aragam, Bryon and Ravikumar, Pradeep},
    title = {{iSCAN: Identifying Causal Mechanism Shifts among Nonlinear Additive Noise Models}},
    journal = {arXiv preprint arXiv:2306.17361},
    year = {2023}
}

Features

  • Shifted nodes are detected without the need to estimate the DAG structure for each dataset.
  • iSCAN is agnostic to the type of score's Jacobian estimator. The current implementation is based on a kernelized Stein's estimator. See stein_hess for details.
  • iSCAN's time complexity is not influenced by the underlying graph density, and will run faster than methods such as DCI or UT-IGSP for large number of variables due to its omission of (non)parametric conditional independence tests.

Getting Started

Install the package

We recommend using a virtual environment via virtualenv or conda, and use pip to install the iscan-dag package.

$ pip install -U iscan-dag

Using iSCAN

See an example on how to use iSCAN in this iPython notebook.

An Overview of iSCAN

We propose a new method for directly identifying changes (shifts) of causal mechanisms from multiple heterogeneous datasets, which are assumed to be originated by related structural causal models (SCMs) over the same set of variables.

iSCAN considers that each SCM belongs to the general class of nonlinear additive noise models (ANMs), thus, generalizing prior work that assumed linear models. We assume that each dataset is generated from an interventional (observational if no variables are intervened) distribution of an underlying graph $G^*$. See the figure below.

In [1], we prove that the Hessian of the log-density function of the mixture distribution reveals information about changes (shifts) in general non-parametric functional mechanisms for the leaf variables. Thus, allowing for the detection of shifted nodes. Our method leads to significant improvements in identifying shifted nodes.

Theorem 1 (see [1]). Let $h$ be the index of the environment (dataset), and $p^h(x)$ denote the pdf of the $h$-th environment. Let $q(x)$ be the pdf of the mixture distribution of the all $H$ environments such that $q(x) = \sum_h w_h p^h(x)$. Also, let $s(x) = \nabla \log q(x)$ be the associated score function. Then, under mild assumptions, if $j$ is a leaf variable in all environments, we have:

$$ j \text{ is a shifted node } \iff \text{Var}_{q}\left[ \frac{\partial s_j(X)}{\partial x_j} \right] > 0. $$

Requirements

  • Python 3.6+
  • numpy
  • igraph
  • torch
  • scikit-learn
  • rpy2 (R interface to use the FOCI library).
  • GPy (Library to sample from Gaussian processes)
  • kneed (Used for the elbow heuristic)
  • pandas

Contents

  • score_estimator.py: Estimates the diagonal of the Hessian of $\log p(x)$ at the provided samples points.
  • utils.py: Utility functions for generating synthetic data, and evaluate the results
  • shifted_nodes.py: Implements iSCAN, providing detected shifted nodes.
  • shifted_edges.py: Implements the discovery of structural changes (shifted edges).
  • my_foci.R: R implementation that uses FOCI for finding parents based on given nodes and topological order.

Acknowledgements

We thank the authors of the SCORE for making their code available. Part of our code is based on their implementation, specially the score_estimator.py file.

Metadata

Release files for iscan-dag 0.0.5

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

Source distribution (sdist)

Source distribution for iscan-dag 0.0.5
File Size Uploaded Provenance Actions
iscan-dag-0.0.5.tar.gz 18.5 kB Without provenance Details for iscan-dag-0.0.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for iscan-dag 0.0.5
File Interpreter ABI Platform Actions
iscan_dag-0.0.5-py3-none-any.whl Python 3 none any Details for iscan_dag-0.0.5-py3-none-any.whl

Total release size: 35.6 kB

Release files / iscan-dag-0.0.5.tar.gz

Download URL iscan-dag-0.0.5.tar.gz
Size 18.5 kB
Tags Source
SHA-256 checksum
How to use checksums
6234e723ecfa961179478ed36cab1814f5a85efd262702223c4012a0a7da384b
BLAKE2b-256 checksum
How to use checksums
a3dd4410c7cd07dd3d7306236f838ff0eadb6837c1b4d5628ff1474841a20d84
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.16

Release files / iscan_dag-0.0.5-py3-none-any.whl

Download URL iscan_dag-0.0.5-py3-none-any.whl
Size 17.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
54bf4ee69558224b3b93bd86b82561adbb2b1c26c66ecf692850ae25a9e0dbde
BLAKE2b-256 checksum
How to use checksums
7e69d706d2ad3e3d4dba889273374d7cbe7a980e3fa5291f6697a13f2186e19b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.16

Security for iscan-dag 0.0.5

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