Skip to main content
.. image:: https://img.shields.io/badge/License-MIT-yellow.svg
:target: https://opensource.org/licenses/MIT
:alt: License

*A Fast Conditional Independence Test (FCIT).*

Introduction
-----------
Let *x, y, z* be random variables. Then deciding whether *P(y | x, z) = P(y | z)*
can be difficult, especially if the variables are continuous. This package
implements a simple yet efficient and effective conditional independence test,
described in [link to arXiv when we write it up!]. Important features that differentiate
this test from competition:

* It is fast. Worst-case speed scales as O(n_data * log(n_data) * dim), where dim is max(x_dim + z_dim, y_dim). However, amortized speed is O(n_data * log(n_data) * log(dim)).

* It applies to cases where some of x, y, z are continuous and some are discrete, or categorical (one-hot-encoded).

* It is very simple to understand and modify.

* It can be used for unconditional independence testing with almost no changes to the procedure.

We have applied this test to tens of thousands of samples of thousand-dimensional datapoints in seconds. For smaller dimensionalities and sample sizes, it takes a fraction of a second. The algorithm is described in [arXiv link coming], where we also provide detailed experimental results and comparison with other methods. However for now, you should be able to just look through the code to understand what's going on -- it's only 90 lines of Python, including detailed comments!

Usage
-----
Basic usage is simple, and the default settings should work in most cases. To perform an *unconditional test*, use dtit.test(x, y):

.. code:: python

import numpy as np
from fcit import fcit

x = np.random.rand(1000, 1)
y = np.random.randn(1000, 1)

pval_i = fcit.test(x, y) # p-value should be uniform on [0, 1].
pval_d = fcit.test(x, x + y) # p-value should be very small.

To perform a conditional test, just add the third variable z to the inputs:

.. code:: python

import numpy as np
from fcit import fcit

# Generate some data such that x is indpendent of y given z.
n_samples = 1000
z = np.random.dirichlet(alpha=np.ones(2), size=n_samples)
x = np.vstack([np.random.multinomial(20, p) for p in z]).astype(float)
y = np.vstack([np.random.multinomial(20, p) for p in z]).astype(float)

# Check that x and y are dependent (p-value should be uniform on [0, 1]).
pval_d = fcit.test(x, y)
# Check that z d-separates x and y (the p-value should be small).
pval_i = fcit.test(x, y, z)

Installation
-----------
pip install fcit


Requirements
------------
Tested with Python 3.6 and

* joblib >= 0.11
* numpy >= 1.12
* scikit-learn >= 0.18.1
* scipy >= 0.16.1

.. _pip: http://www.pip-installer.org/en/latest/


Metadata

Release files for fcit 1.2.0

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

Source distribution (sdist)

Source distribution for fcit 1.2.0
File Size Uploaded
fcit-1.2.0.tar.gz 5.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fcit 1.2.0
File Interpreter ABI Platform
fcit-1.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 13.4 kB

Release files / fcit-1.2.0.tar.gz

Download URL fcit-1.2.0.tar.gz
Size 5.8 kB
Tags Source
SHA-256 checksum
How to use checksums
076b0e752fb5f017544cbd888c447efeaab6db0622aa93a8afe9cee6c73c1a25
BLAKE2b-256 checksum
How to use checksums
87fd78c4fe9636b474143c3126e502c550712809f6df8f81e40289cd44956b93
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / fcit-1.2.0-py3-none-any.whl

Download URL fcit-1.2.0-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9d6d172e92a770d86060e49c3c4f2c063dcf098b202edbd1e5dbdaeadd672f52
BLAKE2b-256 checksum
How to use checksums
0f9e49b831916a2c6fe1804ce1df7c47885c631704883e4b805af25e21f0a599
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 release files

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