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

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.5.tar.gz (621.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.5-cp314-cp314-win_amd64.whl (677.5 kB view details)

Uploaded CPython 3.14Windows x86-64

phik-0.12.5-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (682.6 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

phik-0.12.5-cp314-cp314-macosx_11_0_arm64.whl (667.0 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

phik-0.12.5-cp314-cp314-macosx_10_13_x86_64.whl (670.7 kB view details)

Uploaded CPython 3.14macOS 10.13+ x86-64

phik-0.12.5-cp313-cp313-win_amd64.whl (678.1 kB view details)

Uploaded CPython 3.13Windows x86-64

phik-0.12.5-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (682.5 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

phik-0.12.5-cp313-cp313-macosx_11_0_arm64.whl (666.9 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

phik-0.12.5-cp313-cp313-macosx_10_13_x86_64.whl (670.7 kB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

phik-0.12.5-cp312-cp312-win_amd64.whl (676.2 kB view details)

Uploaded CPython 3.12Windows x86-64

phik-0.12.5-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (679.7 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

phik-0.12.5-cp312-cp312-macosx_11_0_arm64.whl (665.7 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

phik-0.12.5-cp312-cp312-macosx_10_13_x86_64.whl (671.7 kB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

phik-0.12.5-cp311-cp311-win_amd64.whl (675.0 kB view details)

Uploaded CPython 3.11Windows x86-64

phik-0.12.5-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (679.0 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

phik-0.12.5-cp311-cp311-macosx_11_0_arm64.whl (665.5 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

phik-0.12.5-cp311-cp311-macosx_10_13_x86_64.whl (671.0 kB view details)

Uploaded CPython 3.11macOS 10.13+ x86-64

phik-0.12.5-cp310-cp310-win_amd64.whl (674.5 kB view details)

Uploaded CPython 3.10Windows x86-64

phik-0.12.5-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (677.6 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

phik-0.12.5-cp310-cp310-macosx_11_0_arm64.whl (664.3 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

phik-0.12.5-cp310-cp310-macosx_10_13_x86_64.whl (669.4 kB view details)

Uploaded CPython 3.10macOS 10.13+ x86-64

phik-0.12.5-cp39-cp39-win_amd64.whl (674.4 kB view details)

Uploaded CPython 3.9Windows x86-64

phik-0.12.5-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (677.5 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

phik-0.12.5-cp39-cp39-macosx_11_0_arm64.whl (664.3 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

phik-0.12.5-cp39-cp39-macosx_10_13_x86_64.whl (669.5 kB view details)

Uploaded CPython 3.9macOS 10.13+ x86-64

File details

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

File metadata

  • Download URL: phik-0.12.5.tar.gz
  • Upload date:
  • Size: 621.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.10

File hashes

Hashes for phik-0.12.5.tar.gz
Algorithm Hash digest
SHA256 dfc15a9166ab0dcfe3f5f60de606fe9ce064a09af2dd212e726ed3625b795332
MD5 1484b85c989e43f6aa947e9e68e7a800
BLAKE2b-256 4744e8e26bcef558feb3668b073361c036bfef5de32d87061fc26cb1cf2e0124

See more details on using hashes here.

File details

Details for the file phik-0.12.5-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: phik-0.12.5-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 677.5 kB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.5

File hashes

Hashes for phik-0.12.5-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 30586ab21b6e8f3ca12fdef2f3e61ed558a0bc5b9414e91a72eb51d3cc49cba8
MD5 7e5fca6c5f2d4bc668f896e85fb10707
BLAKE2b-256 9d7dad3b73b67ee57fb8eee85d88aa51262aa901dd035160cd7f64ea8d81a836

See more details on using hashes here.

File details

Details for the file phik-0.12.5-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for phik-0.12.5-cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7eb23a6e6c882ab706d629db541be4ce16f25cead9f8db3f96bf0d3b9fa60716
MD5 5d12d65fdaa7345c5e053755492c0bf8
BLAKE2b-256 7ed08d34c1790b5539bfdfcd9e0429f45a3a608f53dc16d788b9bef48fdeb086

See more details on using hashes here.

File details

Details for the file phik-0.12.5-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for phik-0.12.5-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4ecf498afa5273e76887556885716c9b0bb750e016baa8bafa694c754e25a9cb
MD5 f76e2bdd6997c571121ecafa4729c41a
BLAKE2b-256 b7b9d6413e678c2c4792df5c87ce1629dd7a86d08a4d22a268081fbb8ddc4351

See more details on using hashes here.

File details

Details for the file phik-0.12.5-cp314-cp314-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for phik-0.12.5-cp314-cp314-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 603425410d79cb8bf7b1b59a66e67ad821c78a7871717fdc15a53db6ba8da744
MD5 90c5c799ffe15e4524f8c946f89bda08
BLAKE2b-256 23eb91b85218f8f273b9cda1b172f79e383701f9f0f4edc8afb0dceb64d60d75

See more details on using hashes here.

File details

Details for the file phik-0.12.5-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: phik-0.12.5-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 678.1 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.5

File hashes

Hashes for phik-0.12.5-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 8cfc30f872900531cd56a242537db0a4da61fb46512d58b2d1dc7fb98eff4438
MD5 4a3694274160d5e893eb8c151987dec1
BLAKE2b-256 0370435faffb2c27f48acdcf075c27992d572fad3f6876517c4547a665a8c553

See more details on using hashes here.

File details

Details for the file phik-0.12.5-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for phik-0.12.5-cp313-cp313-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9dc76280080e2b20ec341e40f2ee55e1824abe303f1b7af0958f1aedfaada859
MD5 cbdf931867722fad64762b5ca5dea2b6
BLAKE2b-256 02f2327a4d595a98e5797c53c6b9f7241ad205a8bc90db04cda132db9efc477f

See more details on using hashes here.

File details

Details for the file phik-0.12.5-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for phik-0.12.5-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8b335ee26f0817e2e79719ae00e0363099098cbabd3b6b998906a3b92239b88f
MD5 32e6a8b73647639a0a20f6e473514324
BLAKE2b-256 3c24f3ee42f54ff3e2de58458fb58f5faa1c80b7a42de83f5e30f612569c9871

See more details on using hashes here.

File details

Details for the file phik-0.12.5-cp313-cp313-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for phik-0.12.5-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 95f5de5cd0e8b7ce2cc976d257a6ee8f0b74888d6342b0f0ace7df6728b18757
MD5 5ceb6caa52f7a6ee3279f273a063400a
BLAKE2b-256 27b9651cc4b58bd0d4f3362b72ecb8691cd0dba404c3e62be239cba141a461f6

See more details on using hashes here.

File details

Details for the file phik-0.12.5-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: phik-0.12.5-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 676.2 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.10

File hashes

Hashes for phik-0.12.5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 5c4cc07d95008b150467364c6e9a9a5d75170df7360a4148816cccba741978a3
MD5 136ff29a0154d51dc7f8d3380085ffca
BLAKE2b-256 80980d1a58c5a69422f599a80b412dbfa580f7800f85e594b151456e78291085

See more details on using hashes here.

File details

Details for the file phik-0.12.5-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for phik-0.12.5-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 576286429a0ea5cbdff13e133599f3f17717c9a680e85fb121e6b56401154516
MD5 543a19b109a35ae7113ecc73d2ffe339
BLAKE2b-256 ea4450ebfa57d81d00a3125efb907c707b7bce9c79266dd354820888ab47359c

See more details on using hashes here.

File details

Details for the file phik-0.12.5-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for phik-0.12.5-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 87c990eee90c82a82cc4041321fbcddb5b156416c773de638cf1a6d267a7ef08
MD5 8dec4a3f410f160268b3db442f4c27a7
BLAKE2b-256 6b5c8de0d369cb24a19a45c43af9627a38e83a46dca414ca287eac2724f21528

See more details on using hashes here.

File details

Details for the file phik-0.12.5-cp312-cp312-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for phik-0.12.5-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 1209672e13c454cab6d3121ec17ad845c5cbaf9469740ccf4eaaa7a3ddc5f1b1
MD5 c37d6f71d12ff8fd893249a2f750035a
BLAKE2b-256 4f0e1f09b1e117fec9b73ea5f84061e0c1f47c86b09903382ab6b8176af9b3a4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: phik-0.12.5-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 675.0 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.10

File hashes

Hashes for phik-0.12.5-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 d3196535cfede7abfa13691ac3016fc8de358d75763addf4325c8d7980c2ad53
MD5 29920ab28a1daae10810ca2d92fe4c16
BLAKE2b-256 86a92e70ab81c9383c92d95d776a08fa6253529a5f018d02e2e78791195b1b71

See more details on using hashes here.

File details

Details for the file phik-0.12.5-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for phik-0.12.5-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d09adfffa7f2aa56441bfeeb1b628dc8aaf5415265e348a1b62977d944374970
MD5 bf3cd6234c90c458ae40990d25ca3891
BLAKE2b-256 670e2ff623f22ffa3b2f55d5959cd77007e3492b78474806c72f974b4943581a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phik-0.12.5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 911914cf97ffcddbbe97f57a445ecbc44eafeb96e8481f550887c1b9691b909a
MD5 d0edce1f49b9ce23d2855f2e08cb5b32
BLAKE2b-256 cf356f3e9bc68467fe767c43956491e38e84a580091b90035fd91c9fc9008baf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phik-0.12.5-cp311-cp311-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 d4b561951403bbce644b5e563de66a952b72afd57c1c758760255ff601927f9d
MD5 7c31c9f2071048bda376891813cd1d9d
BLAKE2b-256 fcbaedcf57953e08a04996f0d150bd056d3e76b484ace49e58205dd26d1e59c0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: phik-0.12.5-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 674.5 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.10

File hashes

Hashes for phik-0.12.5-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 ca57391c8b8da07368791a86d5a1155e31969b0323f7329a1925d9186ea082af
MD5 876f7956d110028e9bf417107d63922d
BLAKE2b-256 ae732f993628ef4854d4666cf7ff506abdbe977ca6a0258fab4ed3bf97e8ac6f

See more details on using hashes here.

File details

Details for the file phik-0.12.5-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for phik-0.12.5-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 cdfdc36b13a1403bfb0374d92ff34c6c450992e84f81452ff98a96e5ea23580c
MD5 607ab284603f67d716a872e9e4168f7f
BLAKE2b-256 521824d4395c026129f8e74cb1b3d93ae4f8baf99094f89c80857004834028a1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phik-0.12.5-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8c625bbce1d1312d735bb0113e2f8cb54e416225188161552034695901a79fbb
MD5 a0aab940ebae87c4df493208c49389a4
BLAKE2b-256 2ac949889e92a53fc291644eab8178f52b4ca63128eb6adddb026ed4448db930

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phik-0.12.5-cp310-cp310-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 41aacb9d365380ad5e83848c1d7cec7da4b7d29c7c50357586b5ae829fcfc3c6
MD5 d21a52635312d9d9af7f60be37d9aec4
BLAKE2b-256 a917d70af6c804341d9fc0291cdc2c28324f0edc6a2f850422aa005b575f45fe

See more details on using hashes here.

File details

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

File metadata

  • Download URL: phik-0.12.5-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 674.4 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.10

File hashes

Hashes for phik-0.12.5-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 bade0ec3fb4bbc52527fb425ad560647133e267087fbc76b920942dcff1dd5c6
MD5 40f9d6173d1fb08f4f97966a41e423de
BLAKE2b-256 695c1349185e6eb739ef72723b5179d25e7c40e21cf3729e9845499f53ff7526

See more details on using hashes here.

File details

Details for the file phik-0.12.5-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for phik-0.12.5-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 18fb84b7a0e1d95c9e2fbffc3d7ece44b2716d586b42e3c8b315d83fab4a1af4
MD5 3c8075561b6cb5e7850d82f18cd66463
BLAKE2b-256 d977d629943e85581b504d2cc9d1e7800e589697e91ed4bd8ef8f1d9a4742743

See more details on using hashes here.

File details

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

File metadata

  • Download URL: phik-0.12.5-cp39-cp39-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 664.3 kB
  • Tags: CPython 3.9, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.10

File hashes

Hashes for phik-0.12.5-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d289a6370a7326fcd805e3a588009269a9ae7d2a4ba75f4486c751ef8144c928
MD5 a15d51bf294487e3aaba5ad9781a4c3c
BLAKE2b-256 1f53e6d9f2439bab30b3282e8ab6b5ed62bd84d4ac768fea8117f03558416324

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for phik-0.12.5-cp39-cp39-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 bfa41a11e5787f5e244634849d99caff4b1b7a2119d5fbf610e3ea8f5b724af8
MD5 703a1a394167d32870bc36d2d6a9714a
BLAKE2b-256 034fa1ae28b9ea88d64a2ca5fa81d2309a66216f2563307ac5f99a6fbe46b5c7

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