An Independence Test based on Data-Driven Tree-Structured Representations.
This repository includes:
- A Python wrapper to C++ implementation of the mutual information estimator based on data-driven tree-structured partitions (TSP) presented by Silva et al. (2012).
- A Python implementation of the independence test based on the data-driven tree-structured partitions (TSP) presented by Gonzalez et al. (2021) (including all the experiments developed).
- Python package
TSP.pyexample of use.
import sys
import numpy as np
# Set the TSP.py package path
sys.path.insert(1, '../src/build')
# Then import the package
from TSP import TSP
# Initialize NumPy arrays of shape (n_samples, dim) with random
# variables samples in Fortran-contiguous memory order
X = np.array([...], order='F')
Y = np.array([...], order='F')
# Initialize the TSP with its parameters
l_bn = 0.167
w_bn = 5e-2
reg_factor = 2.5e-5
tsp = TSP(l_bn, w_bn, reg_factor)
# Set observations to the estimator
tsp.grow(X, Y)
# Get TSP size and estimated mutual information
size = tsp.size()
emi = tsp.emi()
# Regularize the TSP mutual information estimator
tsp.regularize()
# Get the regularized TSP size and estimated mutual information
reg_size = tsp.size()
reg_emi = tsp.emi()...
If you are installing from source, you will need:
- Python 3.7 or later (for Linux, Python 3.7.6+ or 3.8.1+ is needed)
- A C++14 compatible compiler, such as clang
- Clone this repo to your local machine using
https://github.com/mvidela31/TSP-IT
apt install cmake libeigen3-dev libboost-all-devpacman -S cmake eigen boostmkdir -p ./src/build
cd ./src/build
cmake .. -DNUMPY_INCLUDE_PATH=$(dirname $(python -c 'import numpy as np; print(np.__file__)'))/cor
e/include}
make- The python package
TSP.pyit's now built! Now you can run the Jupyter notebooks from the folderexperiments.
[1] Gonzalez, M. E., Silva, J. F., Videla, M., & Orchard, M. E. (2021). Data-Driven Representations for Testing Independence: Modeling, Analysis and Connection with Mutual Information Estimation. IEEE Transactions on Signal Processing, 70, 158-173.
[2] Silva, J. F., & Narayanan, S. (2012). Complexity-Regularized Tree-Structured Partition for Mutual Information Estimation. IEEE Transactions on Information Theory, 58(3), 1940-1952.