Skip to main content

Phi_K correlation analyzer library

Project description

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

basic tutorial

basic on colab

advanced tutorial (detailed configuration)

advanced on colab

spark tutorial

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

Please note that support is (only) provided on a best-effort basis.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

phik-0.12.2.tar.gz (602.7 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

phik-0.12.2-cp310-cp310-win_amd64.whl (703.8 kB view details)

Uploaded CPython 3.10Windows x86-64

phik-0.12.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (737.2 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

phik-0.12.2-cp310-cp310-macosx_11_0_arm64.whl (975.2 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

phik-0.12.2-cp310-cp310-macosx_10_13_x86_64.whl (812.3 kB view details)

Uploaded CPython 3.10macOS 10.13+ x86-64

phik-0.12.2-cp39-cp39-win_amd64.whl (685.8 kB view details)

Uploaded CPython 3.9Windows x86-64

phik-0.12.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (709.4 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

phik-0.12.2-cp39-cp39-macosx_11_0_arm64.whl (730.7 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

phik-0.12.2-cp39-cp39-macosx_10_13_x86_64.whl (694.7 kB view details)

Uploaded CPython 3.9macOS 10.13+ x86-64

phik-0.12.2-cp38-cp38-win_amd64.whl (677.3 kB view details)

Uploaded CPython 3.8Windows x86-64

phik-0.12.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (696.1 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

phik-0.12.2-cp38-cp38-macosx_11_0_arm64.whl (674.0 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

phik-0.12.2-cp38-cp38-macosx_10_13_x86_64.whl (667.5 kB view details)

Uploaded CPython 3.8macOS 10.13+ x86-64

phik-0.12.2-cp37-cp37m-win_amd64.whl (673.5 kB view details)

Uploaded CPython 3.7mWindows x86-64

phik-0.12.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (690.3 kB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.17+ x86-64

phik-0.12.2-cp37-cp37m-macosx_10_13_x86_64.whl (662.8 kB view details)

Uploaded CPython 3.7mmacOS 10.13+ x86-64

File details

Details for the file phik-0.12.2.tar.gz.

File metadata

  • Download URL: phik-0.12.2.tar.gz
  • Upload date:
  • Size: 602.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0.post20210125 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.8.8

File hashes

Hashes for phik-0.12.2.tar.gz
Algorithm Hash digest
SHA256 b0674eb829d23290433f718d2360122be804b170ccc807ad9d9a8d1c13985533
MD5 01cb2f35f33b46f63daedfd543834a62
BLAKE2b-256 2e6c2ec53b5ea4cb6aee603de707599f30aada1ff3264b954fd8424e2ad40964

See more details on using hashes here.

File details

Details for the file phik-0.12.2-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: phik-0.12.2-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 703.8 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0.post20210125 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.8.8

File hashes

Hashes for phik-0.12.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 e1ade3e331c5ac66c2feb0fbb82405f76558426eb421d96212cedc1984f6593c
MD5 16a9266817f6e9b053b8d90e5cd189cb
BLAKE2b-256 40e576b4051cd0b7ebf1b60474c76c68e51e15b57266eed56d7e1ee9276acdf8

See more details on using hashes here.

File details

Details for the file phik-0.12.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: phik-0.12.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 737.2 kB
  • Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0.post20210125 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.8.8

File hashes

Hashes for phik-0.12.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 22de83d3a6321d9778a66d72438297913d3caae06581aa52272c871be99ac0af
MD5 c8d8c3a4f5fc9e96a67898ed8ee38b04
BLAKE2b-256 6c7204e60542878f72b72ea219220525f66fb9ea47e7bcf1b3d576ff31c1e498

See more details on using hashes here.

File details

Details for the file phik-0.12.2-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

  • Download URL: phik-0.12.2-cp310-cp310-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 975.2 kB
  • Tags: CPython 3.10, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0.post20210125 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.8.8

File hashes

Hashes for phik-0.12.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 404eda7c7e97540370948b05123c003f48de97a52bcc5429937c1aaea93b4cff
MD5 904439bb463551046cd98b3a5cfdf07a
BLAKE2b-256 51c3a614b20e76cbe7731baa7c93832980843e048b407ea96183c5443da0e0f5

See more details on using hashes here.

File details

Details for the file phik-0.12.2-cp310-cp310-macosx_10_13_x86_64.whl.

File metadata

  • Download URL: phik-0.12.2-cp310-cp310-macosx_10_13_x86_64.whl
  • Upload date:
  • Size: 812.3 kB
  • Tags: CPython 3.10, macOS 10.13+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0.post20210125 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.8.8

File hashes

Hashes for phik-0.12.2-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 c4acf6422b844c4cdc8b3c4a3b760838c7d5e0d28570b3ebeb8c95252b757ad3
MD5 88930a5ec00a291a98e68f1b96208f0d
BLAKE2b-256 34db4125b3709cc05d745458a19257b1ab7625abed141c8a3d866be6e90a6ca9

See more details on using hashes here.

File details

Details for the file phik-0.12.2-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: phik-0.12.2-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 685.8 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0.post20210125 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.8.8

File hashes

Hashes for phik-0.12.2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 4426e8620090b9f69bf89e2adb3d70849fecfb899b9aeab8d8c39a8d1302d880
MD5 129dc2e0a851b6c82f7f383b38f2f107
BLAKE2b-256 404770a506d64b3fca7b5279ef49a78505e26b34580f87a7680a955191e11dd1

See more details on using hashes here.

File details

Details for the file phik-0.12.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: phik-0.12.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 709.4 kB
  • Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0.post20210125 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.8.8

File hashes

Hashes for phik-0.12.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1168c6230bb68be5fa2dad63f4a89dc11c7de1980d386d4f5c474978d1025303
MD5 7c18e70cd3484c10333d3050b6c9a350
BLAKE2b-256 db6d60f8830e759075d96e7cea7f903c6b8c3f7b53ccdd3283bb2c5fd29cf20f

See more details on using hashes here.

File details

Details for the file phik-0.12.2-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

  • Download URL: phik-0.12.2-cp39-cp39-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 730.7 kB
  • Tags: CPython 3.9, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0.post20210125 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.8.8

File hashes

Hashes for phik-0.12.2-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ec225cbb551c9bfa32b28740c99e35486574c61c1af576cf682bb2aebaf2755f
MD5 5640146d9e070031e70e8ec6ac3802e8
BLAKE2b-256 6dd4e5d800eebd1527d1c84f998a5797ef74c8941e659aa81560c70083a8966b

See more details on using hashes here.

File details

Details for the file phik-0.12.2-cp39-cp39-macosx_10_13_x86_64.whl.

File metadata

  • Download URL: phik-0.12.2-cp39-cp39-macosx_10_13_x86_64.whl
  • Upload date:
  • Size: 694.7 kB
  • Tags: CPython 3.9, macOS 10.13+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0.post20210125 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.8.8

File hashes

Hashes for phik-0.12.2-cp39-cp39-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 e7efe7be5a8ec8c6be6a9416af2255e6cf38caf7b8226d2e79bb92540ffe2063
MD5 4379cf51a7251d5014c7e37d97d1835c
BLAKE2b-256 b44cc5546a5e0ca4576eed4bf206416550c521262de619ed94b8dc08a0c50f1d

See more details on using hashes here.

File details

Details for the file phik-0.12.2-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: phik-0.12.2-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 677.3 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0.post20210125 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.8.8

File hashes

Hashes for phik-0.12.2-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 5d4a0545787a76b3fba27d8d84addafde4254f7c341a3115646e5b21550f72a4
MD5 5cbfd3ef687eb892bca4f0688e00cee0
BLAKE2b-256 81c937862a454b999a0d54daadafe987136f4878df73f8eeda72b539cc073d58

See more details on using hashes here.

File details

Details for the file phik-0.12.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: phik-0.12.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 696.1 kB
  • Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0.post20210125 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.8.8

File hashes

Hashes for phik-0.12.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 087a691b05ea08dfd883689433cd46dfbd5b58c1aa9af782c24386d024dbde0e
MD5 f1102d31cf19a5bc3cbc360335fa941c
BLAKE2b-256 cd88bdae04b90b9f49fc53f885d4028b3dc5fed3b79900d7b00a6e94741887c8

See more details on using hashes here.

File details

Details for the file phik-0.12.2-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

  • Download URL: phik-0.12.2-cp38-cp38-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 674.0 kB
  • Tags: CPython 3.8, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0.post20210125 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.8.8

File hashes

Hashes for phik-0.12.2-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9035af804d581b1e475b84a3d31ba2673bfde760500ebaeea9b3675aad5633df
MD5 6fe531d5eedbd919f95abcaa7a967ed9
BLAKE2b-256 0906188f9d3fc948f7dec349083064c18e111ffa9a03476d6586c7697a089d98

See more details on using hashes here.

File details

Details for the file phik-0.12.2-cp38-cp38-macosx_10_13_x86_64.whl.

File metadata

  • Download URL: phik-0.12.2-cp38-cp38-macosx_10_13_x86_64.whl
  • Upload date:
  • Size: 667.5 kB
  • Tags: CPython 3.8, macOS 10.13+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0.post20210125 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.8.8

File hashes

Hashes for phik-0.12.2-cp38-cp38-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 db501972688734bd26137050b863ab40fa43ee6deb220cebd364385a25b71ff3
MD5 900199052b762f1c203323c8fafdf29d
BLAKE2b-256 a349e22adefc36704ea908b3ea7fc34aea2d5fb1d0665790057c44709d2f0767

See more details on using hashes here.

File details

Details for the file phik-0.12.2-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: phik-0.12.2-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 673.5 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0.post20210125 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.8.8

File hashes

Hashes for phik-0.12.2-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 f4205e4bf832bad9e6a3cef47d76a30eff8c0aa38432366c31be38c6669d49cd
MD5 18b81c20d1d98629516bebfc39494a8b
BLAKE2b-256 d7afdc78890b3c119daa374bc61a674835d644ca08fac61b7f1d1477a36c6b85

See more details on using hashes here.

File details

Details for the file phik-0.12.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: phik-0.12.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
  • Upload date:
  • Size: 690.3 kB
  • Tags: CPython 3.7m, manylinux: glibc 2.17+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0.post20210125 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.8.8

File hashes

Hashes for phik-0.12.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a77715fdccb798c7062e8ac5cf33fe0d758fd508b27ed7606df9daf81cd7776d
MD5 10629205b6f6319bec776c699c62364a
BLAKE2b-256 94a3a3e9aaa4d4c54704722e018f3326a39908d2ad4e472f6ee4dee622af1ec1

See more details on using hashes here.

File details

Details for the file phik-0.12.2-cp37-cp37m-macosx_10_13_x86_64.whl.

File metadata

  • Download URL: phik-0.12.2-cp37-cp37m-macosx_10_13_x86_64.whl
  • Upload date:
  • Size: 662.8 kB
  • Tags: CPython 3.7m, macOS 10.13+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/52.0.0.post20210125 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.8.8

File hashes

Hashes for phik-0.12.2-cp37-cp37m-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 6cce232b920b105e9ea6cbb1757d6e128d4c3ba5f8308b145b7422bcf6f965ab
MD5 425ef1382939af3ae2f15ec4030b3ade
BLAKE2b-256 fa4356682ea37a7ec91fe402cb27f8ac7e83f184b1cbb09ea15b3aa244db9a10

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page