Registry / data / phik
library0.12.5pypypi✓ verified 29d ago

Phi_K is a practical correlation constant that works consistently between categorical, ordinal, and interval variables. It extends Pearson's hypothesis test of independence, capturing non-linear dependencies and reverting to Pearson's correlation for bi-variate normal distributions. The current version, 0.12.5, was released in July 2025. The library aims for a regular release cadence, with updates occurring every few months to a year, incorporating Python version support and bug fixes.

pip install phik
INSTALL
IMPORT
SIG · PHIK
P
phik
datapythonv0.12.5
Install
15.6s avg
Import
3442ms
Disk
391MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v0.12.5 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.95 runs
build_error
glibc
py 3.10–3.95 runs
installs and imports cleanly · install 15.6s · import 3.442s · 381MB
391MB installed
● package 391MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

phik_matrix
✓ from phik import phik_matrix
✗ import phik
phik_from_array
✓ from phik import phik_from_array
✗ import phik
significance_matrix
✓ from phik import significance_matrix
✗ import phik

This quickstart demonstrates how to load a sample dataset, calculate the Phi_K correlation matrix, and the corresponding significance matrix. It also shows how to generate a comprehensive correlation report (commented out as it requires a local PDF save and matplotlib).

import pandas as pd import phik from phik import resources, report # Load example data df = pd.read_csv(resources.fixture('fake_insurance_data.csv.gz')) # Calculate the phi_k correlation matrix phik_corr = df.phik_matrix() print(phik_corr.head()) # Calculate the significance matrix significance_matrix = df.significance_matrix() print(significance_matrix.head()) # Generate and save a correlation report (requires matplotlib) # report.correlation_report(df, pdf_file_name='phik_report.pdf')
Debug
Known issues
breakingPython 3.7 and 3.8 support has been dropped. Version 0.12.4 dropped 3.7, and 0.12.5 dropped 3.8. Ensure your Python environment is 3.9 or newer.
fix
Upgrade Python to version 3.9 or later.
affects: >=0.12.4
breakingThe `scipy.stats.mvn` function was migrated to `scipy.stats.qmvn` in version 0.12.5 due to deprecation in newer SciPy versions. Using older `phik` versions with a newer `scipy` or vice-versa might lead to compatibility issues.
fix
Ensure `phik` and `scipy` versions are compatible. Upgrade `phik` to 0.12.5 or newer if using a recent `scipy`.
affects: 0.12.5
gotchaThe optional C++ extension for computing the significance matrix (hypergeometric/Patefield method) might not build during a manual `pip install` on some systems. If it fails, `phik` will install without it, and attempting to use this method will raise a `NotImplementedError`.
fix
Ensure your system has the necessary C++ compilers (e.g., GCC, Clang, MSVC) and `pybind11` development headers if you intend to use the hypergeometric method. Pre-built wheels for common OS are usually available.
affects: All versions
gotchaThe calculated Phi_K correlation value for interval (continuous) variables is dependent on the chosen binning. The default is 10 uniform bins, but custom binning can significantly alter results.
fix
Carefully consider and test different binning strategies for interval variables relevant to your analysis. Use the `bins` parameter in methods like `phik_matrix()`.
affects: All versions
gotchaPhi_K correlation is computationally expensive, especially for large datasets, due to the underlying integral calculations. This can lead to longer processing times.
fix
Utilize the `njobs` parameter in `phik_matrix()` and `significance_matrix()` to enable parallel processing and speed up computations, or process data in chunks if memory is also a concern.
affects: All versions
gotchaPhi_K values range from 0 to 1 and do not indicate the direction of a relationship (e.g., positive or negative correlation), only its strength.
fix
Supplement Phi_K analysis with other methods or visualizations (e.g., scatter plots, contingency tables) to understand the nature and direction of dependencies between variables.
affects: All versions
Upgrade
Version history
0.12.5latest on PyPI · released Jul 17, 2025
Audit
Dependencies
pandasrequiredEssential for DataFrame operations and integrating phik methods.
numpyrequiredCore numerical computing library, foundational for statistical calculations.
scipyrequiredUsed for statistical functions, including the underlying correlation calculations.
joblibrequiredEnables parallel processing for certain phik calculations (e.g., using `njobs`).
matplotliboptionalUsed for plotting correlation matrices and reports.
Agent activity
19 hits · last 30 days
node
17
Resources
phik — pip install phik · libregistry