- Notifications
You must be signed in to change notification settings - Fork2
A Python 3 package for identifying distribution shifts (a.k.a feature-shifts) between datasets. Official implementation of the paper: "iSCAN: Identifying Causal Mechanism Shifts among Nonlinear Additive Noise Models".
License
kevinsbello/iscan
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Theiscan-dag
library is a Python 3 package designed for detecting which variables, if any, have undergone a causal mechanism shiftgiven multiple datasets.
iSCAN operates through a systematic process:
- For each dataset, iSCAN initially evaluates the Hessian of the data distribution at each sample. This step helps identify the leaf variables (nodes) for all the datasets.
- 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 (termedshifted node).
The steps above are applied iteratively, eliminating the identified leaf variable across all datasets at each iteration. Seeiscan.est_node_shifts
for more details.
As an optional step, the library also includes a function to detect structural changes (termedshifted 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 employsFOCI
to identify the parent set of shifted nodes in each dataset. Seeiscan.est_struct_shifts
for more details.
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".Advances in Neural Information Processing Systems.
If you find this code useful, please consider citing:
@article{chen2023iscan,title={iSCAN: identifying causal mechanism shifts among nonlinear additive noise models},author={Chen, Tianyu and Bello, Kevin and Aragam, Bryon and Ravikumar, Pradeep},journal={Advances in Neural Information Processing Systems},volume={36},year={2023}}
- 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 a large number of variables due to its omission of (non)parametric conditional independence tests.
We recommend using a virtual environment viavirtualenv
orconda
, and usepip
to install theiscan-dag
package.
$ pip install -U iscan-dag
See an example of how to use iSCAN in thisiPython notebook.
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 eachSCM 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

In[1], we prove that the Hessian of the log-density function of themixture 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
- Python 3.6+
numpy
igraph
torch
scikit-learn
rpy2
(R interface to use theFOCI
library).GPy
(Library to sample from Gaussian processes)kneed
(Used for the elbow heuristic)pandas
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 evaluating the resultsshifted_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 usesFOCI
for finding parents based on given nodes and topological order.
We thank the authors of theSCORE for making their code available. Part of our code is based on their implementation, especially thescore_estimator.py
file.
About
A Python 3 package for identifying distribution shifts (a.k.a feature-shifts) between datasets. Official implementation of the paper: "iSCAN: Identifying Causal Mechanism Shifts among Nonlinear Additive Noise Models".