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 phikVerified import paths — ran on the pinned version, not inferred.
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).
Upgrade Python to version 3.9 or later.
Ensure `phik` and `scipy` versions are compatible. Upgrade `phik` to 0.12.5 or newer if using a recent `scipy`.
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.
Carefully consider and test different binning strategies for interval variables relevant to your analysis. Use the `bins` parameter in methods like `phik_matrix()`.
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.
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.