跳转到主要内容

Phi_K相关分析库

项目描述

Phi_K是一个实用的相关常数,可以在分类、有序和区间变量之间保持一致性。它基于对皮尔逊两个变量独立性假设检验的几个改进。本质上,两个变量的列联检验统计量被解释为来自一个旋转的双变量正态分布,其中倾斜被解释为Phi_K。

Phi_K的联合特性在现有系数上具有优势。首先,它可以在分类、顺序和区间变量之间保持一致性。其次,它捕捉非线性依赖。第三,在二元正态输入分布的情况下,它将回归到皮尔逊相关系数。当研究混合类型变量的相关矩阵时,这些特性非常有用。

关于计算背后的方法的详细信息,请参阅我们的出版物。我们强调对相关性的统计显著性进行正确评估,以及在列联表中解释变量关系,特别是在低统计样本的情况下。提供的算法易于使用,并通过此公共Python库提供。

示例笔记本

静态链接

Google Colab链接

基础教程

在Colab上的基础

高级教程(详细配置)

在Colab上的高级

Spark教程

不可用Spark

文档

Phi_K的完整文档,包括教程,可在read-the-docs找到。请参阅教程,了解如何使用pandas运行代码的详细示例。我们还有一个如何计算Spark DataFrame的Phi_K相关矩阵的示例。

查看

Phi_K库需要Python >= 3.8,且对pip友好。要开始,只需这样做

$ pip install phik

或者查看我们的GitHub仓库中的代码

$ git clone https://github.com/KaveIO/PhiK.git
$ pip install -e PhiK/

在这个例子中,代码以编辑模式(选项-e)安装。

现在您可以在Python中使用此包了

import phik

恭喜,您现在可以使用PhiK相关分析器库了!

快速运行

作为一个快速示例,您可以这样做

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')

有关所有可用示例,请参阅read-the-docs上的教程

联系和支持

请注意,支持仅基于最大努力提供。

项目详情


下载文件

下载适用于您平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源分布

phik-0.12.4.tar.gz (621.3 kB 查看哈希值)

上传时间

构建分布

phik-0.12.4-cp312-cp312-win_amd64.whl (666.4 kB 查看哈希值)

上传时间 CPython 3.12 Windows x86-64

phik-0.12.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (687.2 kB 查看哈希值)

上传于 CPython 3.12 manylinux: glibc 2.17+ x86-64

phik-0.12.4-cp312-cp312-macosx_11_0_arm64.whl (655.7 kB 查看哈希值)

上传于 CPython 3.12 macOS 11.0+ ARM64

phik-0.12.4-cp312-cp312-macosx_10_13_x86_64.whl (659.0 kB 查看哈希值)

上传于 CPython 3.12 macOS 10.13+ x86-64

phik-0.12.4-cp311-cp311-win_amd64.whl (667.1 kB 查看哈希值)

上传于 CPython 3.11 Windows x86-64

phik-0.12.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (687.8 kB 查看哈希值)

上传于 CPython 3.11 manylinux: glibc 2.17+ x86-64

phik-0.12.4-cp311-cp311-macosx_11_0_arm64.whl (657.3 kB 查看哈希值)

上传于 CPython 3.11 macOS 11.0+ ARM64

phik-0.12.4-cp311-cp311-macosx_10_13_x86_64.whl (660.6 kB 查看哈希值)

上传于 CPython 3.11 macOS 10.13+ x86-64

phik-0.12.4-cp310-cp310-win_amd64.whl (666.2 kB 查看哈希值)

上传于 CPython 3.10 Windows x86-64

phik-0.12.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (686.1 kB 查看哈希值)

上传于 CPython 3.10 manylinux: glibc 2.17+ x86-64

phik-0.12.4-cp310-cp310-macosx_11_0_arm64.whl (655.9 kB 查看哈希值)

上传于 CPython 3.10 macOS 11.0+ ARM64

phik-0.12.4-cp310-cp310-macosx_10_13_x86_64.whl (659.2 kB 查看哈希值)

上传于 CPython 3.10 macOS 10.13+ x86-64

phik-0.12.4-cp39-cp39-win_amd64.whl (666.3 kB 查看哈希值)

上传于 CPython 3.9 Windows x86-64

phik-0.12.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (686.3 kB 查看哈希值)

上传于 CPython 3.9 manylinux: glibc 2.17+ x86-64

phik-0.12.4-cp39-cp39-macosx_11_0_arm64.whl (656.0 kB 查看哈希值)

上传于 CPython 3.9 macOS 11.0+ ARM64

phik-0.12.4-cp39-cp39-macosx_10_13_x86_64.whl (659.3 kB 查看哈希值)

上传于 CPython 3.9 macOS 10.13+ x86-64

phik-0.12.4-cp38-cp38-win_amd64.whl (666.2 kB 查看哈希值)

上传于 CPython 3.8 Windows x86-64

phik-0.12.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (686.1 kB 查看哈希值)

上传于 CPython 3.8 manylinux: glibc 2.17+ x86-64

phik-0.12.4-cp38-cp38-macosx_11_0_arm64.whl (655.9 kB 查看哈希值)

上传于 CPython 3.8 macOS 11.0+ ARM64

phik-0.12.4-cp38-cp38-macosx_10_13_x86_64.whl (659.2 kB 查看哈希值)

上传于 CPython 3.8 macOS 10.13+ x86-64

支持者