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.3.tar.gz (620.3 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.3-cp311-cp311-win_amd64.whl (663.4 kB view details)

Uploaded CPython 3.11Windows x86-64

phik-0.12.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (679.5 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

phik-0.12.3-cp311-cp311-macosx_11_0_arm64.whl (649.9 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

phik-0.12.3-cp311-cp311-macosx_10_13_x86_64.whl (652.9 kB view details)

Uploaded CPython 3.11macOS 10.13+ x86-64

phik-0.12.3-cp310-cp310-win_amd64.whl (663.4 kB view details)

Uploaded CPython 3.10Windows x86-64

phik-0.12.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (679.5 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

phik-0.12.3-cp310-cp310-macosx_11_0_arm64.whl (649.9 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

phik-0.12.3-cp310-cp310-macosx_10_13_x86_64.whl (652.9 kB view details)

Uploaded CPython 3.10macOS 10.13+ x86-64

phik-0.12.3-cp39-cp39-win_amd64.whl (663.5 kB view details)

Uploaded CPython 3.9Windows x86-64

phik-0.12.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (679.8 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

phik-0.12.3-cp39-cp39-macosx_11_0_arm64.whl (649.9 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

phik-0.12.3-cp39-cp39-macosx_10_13_x86_64.whl (653.0 kB view details)

Uploaded CPython 3.9macOS 10.13+ x86-64

phik-0.12.3-cp38-cp38-win_amd64.whl (663.3 kB view details)

Uploaded CPython 3.8Windows x86-64

phik-0.12.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (679.5 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

phik-0.12.3-cp38-cp38-macosx_11_0_arm64.whl (649.9 kB view details)

Uploaded CPython 3.8macOS 11.0+ ARM64

phik-0.12.3-cp38-cp38-macosx_10_13_x86_64.whl (652.9 kB view details)

Uploaded CPython 3.8macOS 10.13+ x86-64

phik-0.12.3-cp37-cp37m-win_amd64.whl (664.0 kB view details)

Uploaded CPython 3.7mWindows x86-64

phik-0.12.3-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (680.0 kB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.17+ x86-64

phik-0.12.3-cp37-cp37m-macosx_10_13_x86_64.whl (653.0 kB view details)

Uploaded CPython 3.7mmacOS 10.13+ x86-64

File details

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

File metadata

  • Download URL: phik-0.12.3.tar.gz
  • Upload date:
  • Size: 620.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.5

File hashes

Hashes for phik-0.12.3.tar.gz
Algorithm Hash digest
SHA256 29f5eb2e72d064c3215c106559ed40402c5ec0c39391ccd27afa11f88d397407
MD5 dbb0f8755edd5495b18a1650075495de
BLAKE2b-256 8a64e69d13c19a6a19dbfaf742f3f08a1cc829da8df36e7661f5c671f95c6f2d

See more details on using hashes here.

File details

Details for the file phik-0.12.3-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: phik-0.12.3-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 663.4 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.5

File hashes

Hashes for phik-0.12.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 31a11ba71a918ac4480e7fcc41e527b975a51220a880ed1b6fc1c53ec536ac74
MD5 209079dae2924fd80e21f2dfd95113db
BLAKE2b-256 1bb8f3683553cb8d63eb7bdeedd6c6d69113c7fff920f6de2d4dcf49844c4ed6

See more details on using hashes here.

File details

Details for the file phik-0.12.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for phik-0.12.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ed2c70c7bb2019c5cf75e30ae31aa9e3cff42af65811f92bd0912c47f04eefde
MD5 c2b44a7c3a9db4f1fe514f25e5c0d2e3
BLAKE2b-256 0905bc351a83ad3174cd44c670e3557fa91433072be95df9cacc9d16fcbd9cc9

See more details on using hashes here.

File details

Details for the file phik-0.12.3-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for phik-0.12.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1010f0ff5f34cda0e461199c86a77513c29f72dd071f6054d2060fc116d3e3c7
MD5 7779af537e1214745aa8e601ad10d9b0
BLAKE2b-256 03d66c7bb5a2ae869dbdfd1978284fc6e6087c187ca72d43d42df8715c3b505b

See more details on using hashes here.

File details

Details for the file phik-0.12.3-cp311-cp311-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for phik-0.12.3-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 22b72c92b193af9e090cded7fb59e010a52310c476e401fc24facbb8998a5c3d
MD5 c56a6c1e600ef24f9c43bf15dedf2de9
BLAKE2b-256 e825afe81bfba6a5a3886bf50ed694ae0b2b4d58faaa01c7034b7e8151d7b03f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: phik-0.12.3-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 663.4 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.5

File hashes

Hashes for phik-0.12.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 e120fd130e281e67b09bc7b00f47ec3e9b0ea4ed3ba48944799656270bbf9d7a
MD5 2c94974c0b96b46aef8003a99b429fa9
BLAKE2b-256 11e8f2c58f6c3e71cd0371e8db40da32e83e65030c0a52dd2f05d3cd7ae7e1a0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phik-0.12.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a8c2b80707db400e293cfb30e1f18a9e52a19ab974169ee49e19ede73bb9bfcb
MD5 09415cfbf0ca1a6123de6db270ab3c86
BLAKE2b-256 5b7576e14c8c674b0bb8f08aa6a08578474a968999e0ce1bb6c5da224ef17294

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phik-0.12.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3d17f7ff33e0d1784cc5e969bd5e26840750b790d4f3082b85c3c90915914018
MD5 c5ed8fcf7e7ce23c840512bf4929a998
BLAKE2b-256 9a97fe6c51c7a7193d83b239f7c82dbc2dba4a7f362a69c7b422a914e2c0288a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phik-0.12.3-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 e877b647af1b0b5a8f0134085b2047c7a20d1e4d05f1701a33bed6d3720d4d0a
MD5 20a5e49369e127b045545caa753132bc
BLAKE2b-256 24733036744fec8926a6a7ca4a2e6ec241dcb85bb03ce24bc4b12d392fe522b1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: phik-0.12.3-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 663.5 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.5

File hashes

Hashes for phik-0.12.3-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 9d7c78f372175f89854c76b269602dffca5d8715d29f6f5caac7e236705b5acb
MD5 c57a8a70db3ba4be46cc087428de87e5
BLAKE2b-256 47120c0741f6e38278c68c48404569dfade4c6e50c03c05e704909c2c2ffc896

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phik-0.12.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cfed89c9a1bb88d80df8259bb30aa650244c877aaaca218025d92324074716b9
MD5 7376894ba6afbef98eedd2e9faa25ff4
BLAKE2b-256 3a76c9b729aaf03cc850bd4b0e1a55220ea36dc7b6cfbefd7cfa884e708f5228

See more details on using hashes here.

File details

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

File metadata

  • Download URL: phik-0.12.3-cp39-cp39-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 649.9 kB
  • Tags: CPython 3.9, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.5

File hashes

Hashes for phik-0.12.3-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 baac8ace316b801cdb38c84cd0e7e35e60d17d50032c34af9879b0cd91c20861
MD5 666570a334e273841b3f9162a09e18e3
BLAKE2b-256 11c0ae6bed243d3e7194a4a2b31e32682ca852cff7b564b38b4e5493cc4f4e49

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phik-0.12.3-cp39-cp39-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 dfbb20614288df46970640c9127f500f7e03a66631bb9aa3774a2f5222f19f75
MD5 8f3eb6ed697e8f0864efabdd712d3cae
BLAKE2b-256 1153b1f8520fc7f90904cfb7dd5765cace015069cacf45953f62f0dccc74a073

See more details on using hashes here.

File details

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

File metadata

  • Download URL: phik-0.12.3-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 663.3 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.5

File hashes

Hashes for phik-0.12.3-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 319655506e5184f65b4ae0c3d3e95e895a539880a3110c417d59823f3de58a88
MD5 49ede0e4afb0710aa0e3be0a4a89af2f
BLAKE2b-256 0e9a868be2f94812cfd366949aee0a190694cec98f13c775c8c6fb42c4fc11b8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phik-0.12.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 10a2f0e58d03e4b596974395aaaeac0bce93457d59ba6985d7bb753cdd236d87
MD5 1b66f667613365610a09174f289d2060
BLAKE2b-256 587d4640cde88ef5c35b005e7d36f51f41b11d549e95ed04333438805ac7e16d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: phik-0.12.3-cp38-cp38-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 649.9 kB
  • Tags: CPython 3.8, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.5

File hashes

Hashes for phik-0.12.3-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a09ec2279e8f1180dd9b736d95cdafb7414bb8b5e3d86be4de44f757861a411b
MD5 f1ec6de58a7ce2767a72ff04be496ba8
BLAKE2b-256 7469646b579c95b0b1567a9df261ba145091abd8b0e94ceb0bad83483d53e119

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phik-0.12.3-cp38-cp38-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 e00b7b1ad4ad999e50b7e1c653e1d6a17427a72243b6a5ca2d0728c943a1b7f1
MD5 79584e0b123074205a32341633bd2eda
BLAKE2b-256 bacaccf8937e8693f342c666435afb6e2de73908aeb33b829bcdd0f877c9f0d6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: phik-0.12.3-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 664.0 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.5

File hashes

Hashes for phik-0.12.3-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 ad340c225bd1b76c42a731036048242e1ee8a486876247b09ed4c51886b0cf67
MD5 775f6ed8acc9275b74b4ae8982cb55c6
BLAKE2b-256 b7b3e327612b67b2ab93749e648a92e5463cba763e7d4e8c74f69551133df076

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phik-0.12.3-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 aba959112c7ff5266d5dbb8a2b92a1cb3b2486a0514aa2ce97d1dabfb1c47e60
MD5 c5a0d18a9bfe66d7d7d6fb5b3ede292f
BLAKE2b-256 29b9778331c1e6a03ce285a2648e7b5ca5e5623b9f976897387b0221093ddd9b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phik-0.12.3-cp37-cp37m-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 4cb4fe15290076e9f0a227c46943919d861a4ec4bb0e930f59015f70ba28a1a2
MD5 179ad6b7fb2812fd83870fc152f6c9de
BLAKE2b-256 bea9bf331e0defee9fd950af724cb8a348fb34c2e6373b80043271486fbeec84

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