Skip to content

Camilormz/TSP-IT

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TSP-IT

License: MIT

An Independence Test based on Data-Driven Tree-Structured Representations.

Contents

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).

Usage

  • Python package TSP.py example 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()

Installation

From Binaries

...

Install From Source

Prerequisites

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

Install Dependencies

Ubuntu:
apt install cmake libeigen3-dev libboost-all-dev
Arch:
pacman -S cmake eigen boost

Compilation

mkdir -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.py it's now built! Now you can run the Jupyter notebooks from the folder experiments.

References

[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.

About

An Independence Test based on Data-Driven Tree-Structured Representations.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Jupyter Notebook 97.0%
  • C++ 2.2%
  • Other 0.8%