Hyppo: Independence Testing
Hyppo is a comprehensive independence testing package in Python, currently at version 0.5.2. It provides a wide array of statistical tests for evaluating independence, k-sample, and goodness-of-fit problems. The library has an active development cycle, with major releases bringing significant new features and bug fixes, typically every 12-16 months, complemented by more frequent patch releases.
Common errors
-
ModuleNotFoundError: No module named 'autograd'
cause The `autograd` library, a mandatory dependency for Hyppo, is not installed or not accessible in your Python environment.fixInstall `autograd` explicitly: `pip install autograd`. -
RuntimeError: Python version must be >= 3.8.0 to use hyppo>=0.5.0
cause You are attempting to use Hyppo version 0.5.0 or newer with a Python version older than 3.8.fixUpgrade your Python interpreter to version 3.8 or newer, or downgrade Hyppo to version 0.4.x or older: `pip install 'hyppo<0.5.0'`. -
AttributeError: 'MyCustomKernel' object has no attribute 'gradient'
cause If `MyCustomKernel` inherits from `DifferentiableKernel` and you are using `hyppo` v0.5.2 or newer, the `autograd` fallback for gradients was removed. You must now provide your own `gradient` method.fixImplement the `gradient` method within your `MyCustomKernel` class to define how its gradients are computed.
Warnings
- breaking Hyppo versions 0.5.0 and newer require Python 3.8 or higher. Users on older Python versions (3.6 or 3.7) will encounter errors if they upgrade past 0.4.x.
- breaking Starting from v0.5.2, the `DifferentiableKernel` class no longer provides an automatic `autograd` fallback for gradients. If you are implementing custom differentiable kernels, you must now manually define the `gradient` method.
- gotcha The `autograd` library is a core dependency for `hyppo`. While `pip install hyppo` typically handles this, if you encounter `ModuleNotFoundError` related to `autograd`, it might be missing or conflict with your environment.
Install
-
pip install hyppo
Imports
- Hsic
from hyppo.independence import Hsic
- Dcorr
from hyppo.independence import Dcorr
- Energy
from hyppo.ksample import Energy
Quickstart
import numpy as np
from hyppo.independence import Hsic
# Generate some data
x = np.random.normal(0, 1, size=(100, 1))
y = x + np.random.normal(0, 1, size=(100, 1))
# Initialize and run the Hsic test
test = Hsic()
stat, pvalue = test.test(x, y)
print(f"Test Statistic: {stat:.4f}, P-value: {pvalue:.4f}")