Phi_K correlation analyzer library
Project description
Version: 0.12.4. Released: Jan 2024
Release notes: https://github.com/KaveIO/PhiK/blob/master/CHANGES.rst
Repository: https://github.com/kaveio/phik
Documentation: https://phik.readthedocs.io
Publication: [offical] [arxiv pre-print]
Phi_K is a practical correlation constant that works consistently between categorical, ordinal and interval variables. It is based on several refinements to Pearson’s hypothesis test of independence of two variables. Essentially, the contingency test statistic of two variables is interpreted as coming from a rotated bi-variate normal distribution, where the tilt is interpreted as Phi_K.
The combined features of Phi_K form an advantage over existing coefficients. First, it works consistently between categorical, ordinal and interval variables. Second, it captures non-linear dependency. Third, it reverts to the Pearson correlation coefficient in case of a bi-variate normal input distribution. These are useful features when studying the correlation matrix of variables with mixed types.
For details on the methodology behind the calculations, please see our publication. Emphasis is paid to the proper evaluation of statistical significance of correlations and to the interpretation of variable relationships in a contingency table, in particular in case of low statistics samples. The presented algorithms are easy to use and available through this public Python library.
Example notebooks
Static link |
Google Colab link |
---|---|
no spark available |
Documentation
The entire Phi_K documentation including tutorials can be found at read-the-docs. See the tutorials for detailed examples on how to run the code with pandas. We also have one example on how calculate the Phi_K correlation matrix for a spark dataframe.
Check it out
The Phi_K library requires Python >= 3.8 and is pip friendly. To get started, simply do:
$ pip install phik
or check out the code from out GitHub repository:
$ git clone https://github.com/KaveIO/PhiK.git
$ pip install -e PhiK/
where in this example the code is installed in edit mode (option -e).
You can now use the package in Python with:
import phik
Congratulations, you are now ready to use the PhiK correlation analyzer library!
Quick run
As a quick example, you can do:
import pandas as pd
import phik
from phik import resources, report
# open fake car insurance data
df = pd.read_csv( resources.fixture('fake_insurance_data.csv.gz') )
df.head()
# Pearson's correlation matrix between numeric variables (pandas functionality)
df.corr()
# get the phi_k correlation matrix between all variables
df.phik_matrix()
# get global correlations based on phi_k correlation matrix
df.global_phik()
# get the significance matrix (expressed as one-sided Z)
# of the hypothesis test of each variable-pair dependency
df.significance_matrix()
# contingency table of two columns
cols = ['mileage','car_size']
df[cols].hist2d()
# normalized residuals of contingency test applied to cols
df[cols].outlier_significance_matrix()
# show the normalized residuals of each variable-pair
df.outlier_significance_matrices()
# generate a phik correlation report and save as test.pdf
report.correlation_report(df, pdf_file_name='test.pdf')
For all available examples, please see the tutorials at read-the-docs.
Contact and support
Issues and Ideas: https://github.com/kaveio/phik/issues
Please note that support is (only) provided on a best-effort basis.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file phik-0.12.4.tar.gz
.
File metadata
- Download URL: phik-0.12.4.tar.gz
- Upload date:
- Size: 621.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d4d53274685e56fb08088505b4eec70be07f2f8044e7961ca02b399e42c37025 |
|
MD5 | e884ef10a176396e58029037b78a37ee |
|
BLAKE2b-256 | cb8c1bf452e93dd23523f18660ffdc24092038a5781964085d766bd792e0495b |
File details
Details for the file phik-0.12.4-cp312-cp312-win_amd64.whl
.
File metadata
- Download URL: phik-0.12.4-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 666.4 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 247ea90b2d067bb360e798e5645dbcea7753b3bf78436287d92247285c4aa58a |
|
MD5 | 9b3fb255cfe13c946cd26e94071ddbef |
|
BLAKE2b-256 | eb12720f5c721df98c718b22bc15da93efb32b1ed5371da75874827a3bb8af7d |
File details
Details for the file phik-0.12.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: phik-0.12.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 687.2 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3868a8f9277ab338eacb634bb06dd83278344dc19154f77e06c9cb8712959404 |
|
MD5 | 69667e0dfa6aa8269ad4839632d8d963 |
|
BLAKE2b-256 | 9c50bb6a9f9cff78f88c10608bd0b7dd77b335c2388746132c3b2abb910f2021 |
File details
Details for the file phik-0.12.4-cp312-cp312-macosx_11_0_arm64.whl
.
File metadata
- Download URL: phik-0.12.4-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 655.7 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6ba2fa65c4b2a3c36aded0f47333c3069c0520bb426c3f937656a58a5041957 |
|
MD5 | b0fc9d9f456778ff3b32ee346e903eee |
|
BLAKE2b-256 | f8c2c89371bb805f9801929ceb70730604fc35a4f4a26f0a4a55f85af7075d12 |
File details
Details for the file phik-0.12.4-cp312-cp312-macosx_10_13_x86_64.whl
.
File metadata
- Download URL: phik-0.12.4-cp312-cp312-macosx_10_13_x86_64.whl
- Upload date:
- Size: 659.0 kB
- Tags: CPython 3.12, macOS 10.13+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 951b06ed32fa0fe6ee73f98407e4d435f90a1750ecb0f250df46eb75741a33bf |
|
MD5 | 296b9c9ceafbc54a53e5f165a26434ce |
|
BLAKE2b-256 | a672a2cbf1b19becffb4f675de4be9a939b904a014844de15cf1fb18f80db1f2 |
File details
Details for the file phik-0.12.4-cp311-cp311-win_amd64.whl
.
File metadata
- Download URL: phik-0.12.4-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 667.1 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f315699c695e5646b29911b577d584ae76d0fcc1dee539634e512518fcd4108d |
|
MD5 | 38812163c4a210b96ca527dea72534c7 |
|
BLAKE2b-256 | 95e3250ce99ed761389028543fcb876176ba619f6bf387d6cce3bab736bd92cc |
File details
Details for the file phik-0.12.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: phik-0.12.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 687.8 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ea158b31d51e34153241bd3cac24c9a9a463af575c063abb8ca8d30352b4b12 |
|
MD5 | 18c9c76654df9077b16c0db64dd67a2d |
|
BLAKE2b-256 | 3d66799d5cebe086c9f1f02cbdf8a72128aaf4c5b413f3a618a023f91a5e6cfc |
File details
Details for the file phik-0.12.4-cp311-cp311-macosx_11_0_arm64.whl
.
File metadata
- Download URL: phik-0.12.4-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 657.3 kB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4f7a6614184eac1b55100c4a7c9899f370ae97599b41b2982f59f7e1da9511cd |
|
MD5 | 02096636dc1d3ffb076cc373b98a4cf2 |
|
BLAKE2b-256 | b969a42d9320b68b0d43d78db46787669b2287cba5e8db2e83fe0d63c1fd6945 |
File details
Details for the file phik-0.12.4-cp311-cp311-macosx_10_13_x86_64.whl
.
File metadata
- Download URL: phik-0.12.4-cp311-cp311-macosx_10_13_x86_64.whl
- Upload date:
- Size: 660.6 kB
- Tags: CPython 3.11, macOS 10.13+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b2f518310c6f3144a5e3d1bc3489c8be17ebe4da6b8520f4e01fa3e544b0fed |
|
MD5 | 254fb83bb46711a0808dec1517468fbe |
|
BLAKE2b-256 | c1c01c18b27b8fd73c72a7a9b4d883afc61c6a3ecf347fe2ec34fece300d89b1 |
File details
Details for the file phik-0.12.4-cp310-cp310-win_amd64.whl
.
File metadata
- Download URL: phik-0.12.4-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 666.2 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea5030640fda8380d7db9ea28fbde37a1565c0b1699bcb7152d6772a6ad278af |
|
MD5 | 1bbd9575c9a4d7861cda051421c0d98e |
|
BLAKE2b-256 | 49e6b78302b9efb85ef2df2ac52073d1be1f6bebdf2cdfe572ed8646f6257109 |
File details
Details for the file phik-0.12.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: phik-0.12.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 686.1 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f48d0dd94323401ed069bbaa673a879f3f002e5ef6fabda19eb3d0a5f8e3947f |
|
MD5 | a5bdcc135dfe0a83ba618ccc1a208d3b |
|
BLAKE2b-256 | ee3ed9bea3b996c60858b396cdb8ccc2ab35d6562db8fc3a7f1fb6e3a2d7b13d |
File details
Details for the file phik-0.12.4-cp310-cp310-macosx_11_0_arm64.whl
.
File metadata
- Download URL: phik-0.12.4-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 655.9 kB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d92cc961ee60b317896589bab087901440b2bc749dbd5e266bc3dfe25dbff19a |
|
MD5 | 174d8b9ce482438305a3ee940075557d |
|
BLAKE2b-256 | 409ff7cb4513c8a31c7c887b838e2ee4c2ab968983cf905c69e79ada1971b1f7 |
File details
Details for the file phik-0.12.4-cp310-cp310-macosx_10_13_x86_64.whl
.
File metadata
- Download URL: phik-0.12.4-cp310-cp310-macosx_10_13_x86_64.whl
- Upload date:
- Size: 659.2 kB
- Tags: CPython 3.10, macOS 10.13+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 778d00e33762c1e85681f65ef011933faabdc80ab53262f221cccf75eea535d5 |
|
MD5 | 441028f98f9b7a2c4d7053b9a3f24b2b |
|
BLAKE2b-256 | 8ed36cbfcd06de7aa26df397bcc404991e68b03112bb14a403f14d711a165cf8 |
File details
Details for the file phik-0.12.4-cp39-cp39-win_amd64.whl
.
File metadata
- Download URL: phik-0.12.4-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 666.3 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c15e987d90d34990fee0ef157fb00c9c69befdf520689ac5f320ff0ab74fa399 |
|
MD5 | 908ca42dd3f7ccfe47bf8771483607d4 |
|
BLAKE2b-256 | 53e2d1f5e9ce10f2cb9a8b3866f17cf7b47db95f086987565ecda6df542fe30b |
File details
Details for the file phik-0.12.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: phik-0.12.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 686.3 kB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1dd26c71de023852aa452897e41a55176d6d87c268323d0814514cd32a9fadc1 |
|
MD5 | e561c43ae4eff5107d0c10ed21f634fb |
|
BLAKE2b-256 | 3cc673d4815925b5e01843f6148bf84e49fd7dd52977cf9948175baf0c21bb28 |
File details
Details for the file phik-0.12.4-cp39-cp39-macosx_11_0_arm64.whl
.
File metadata
- Download URL: phik-0.12.4-cp39-cp39-macosx_11_0_arm64.whl
- Upload date:
- Size: 656.0 kB
- Tags: CPython 3.9, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7eb9c0a22d01007a4c51d48489c4f3ebe738461e092061c90da7c1ccf8d51e60 |
|
MD5 | ab66c843382d79746edf706f74271363 |
|
BLAKE2b-256 | 36f481b2272c66bf5f4390650d2efbf1acfa4f1a3f261a9f9e58aaf2fbb73431 |
File details
Details for the file phik-0.12.4-cp39-cp39-macosx_10_13_x86_64.whl
.
File metadata
- Download URL: phik-0.12.4-cp39-cp39-macosx_10_13_x86_64.whl
- Upload date:
- Size: 659.3 kB
- Tags: CPython 3.9, macOS 10.13+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c2c7482e8ca1e9f688eacd69baccf838fc535b9d3c13523b2d3b53b4aff04c5d |
|
MD5 | b93acb27182a75b320b9e316afbb5343 |
|
BLAKE2b-256 | 767c8cf317aca8477994318ddfcffd222e8be01b5bd9065aecf6a191da848518 |
File details
Details for the file phik-0.12.4-cp38-cp38-win_amd64.whl
.
File metadata
- Download URL: phik-0.12.4-cp38-cp38-win_amd64.whl
- Upload date:
- Size: 666.2 kB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb43bd2b3b6b068b4d2f85a303cfdc256294637f3a598234058cfdbdc75d8538 |
|
MD5 | 7dd112bb2ebdd69af57d930c69bdb8a8 |
|
BLAKE2b-256 | ec23282efc74f66a80aa2491257c0bcffbb62159c9af2eea0a1fd1993086779d |
File details
Details for the file phik-0.12.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: phik-0.12.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 686.1 kB
- Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85c329bd206bfdca689f72f1bb270707f19d5533882b3cde560ce0cbf4b27551 |
|
MD5 | 9b28db85f9d23f3be6581427e3c7154e |
|
BLAKE2b-256 | 027d83dcf9ce8865a2ecf93d17c31652f43139d0fa0d41e5e09a50a301470c4e |
File details
Details for the file phik-0.12.4-cp38-cp38-macosx_11_0_arm64.whl
.
File metadata
- Download URL: phik-0.12.4-cp38-cp38-macosx_11_0_arm64.whl
- Upload date:
- Size: 655.9 kB
- Tags: CPython 3.8, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0df90db67dadae940973ffd0692c2e9a207da46b8764e200cb7e6f2552d43154 |
|
MD5 | 00dd186d5fa2b71c356270f57c70c28f |
|
BLAKE2b-256 | 6e3b52a395a9c05d99341d41f4a5f088fc2f9e112f99e8f42ccc5b6c3a1ab5b0 |
File details
Details for the file phik-0.12.4-cp38-cp38-macosx_10_13_x86_64.whl
.
File metadata
- Download URL: phik-0.12.4-cp38-cp38-macosx_10_13_x86_64.whl
- Upload date:
- Size: 659.2 kB
- Tags: CPython 3.8, macOS 10.13+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.8.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b38483f02c8a2d471dd14ebc367f83cd619a3672033f1ce52382815cdb9382d |
|
MD5 | 520e08dc7f05764d5a49046bac5fa8b2 |
|
BLAKE2b-256 | 4d3192baae1342de13c4253f6d9af74d1b85011945bb33d07e96b920a9dd8393 |