Skip to main content

pypair logo

PyPair

PyPair is a statistical library to compute pairwise association between any two variables. In general, statistical variable types are viewed as categorical or continuous. Categorical variables have no inherit order to their values, while continuous variables do. This API has over 130 association measures implemented for any combination of categorical and/or continuous variables.

To install.

pip install pypair

Additional links.

Here's a short and sweet snippet for using the API against a dataframe that stores strictly binary data. The Pandas DataFrame.corr() method no longer processes non-numeric fields!

from pypair.association import binary_binary
from pypair.util import corr

jaccard = lambda a, b: binary_binary(a, b, measure='jaccard')
tanimoto = lambda a, b: binary_binary(a, b, measure='tanimoto_i')

df = get_a_pandas_binary_dataframe()

jaccard_corr = corr(df, jaccard)
tanimoto_corr = corr(df, tanimoto)

print(jaccard_corr)
print('-' * 15)
print(tanimoto_corr)

Another way to get started with PyPair is to use the convenience methods whose names indicate the variable pair types.

from pypair.association import binary_binary, categorical_categorical, \
    binary_continuous, concordance, categorical_continuous, continuous_continuous, confusion, agreement

# assume a and b are the appropriate iterables of values for 2 variables
jaccard = binary_binary(a, b, measure='jaccard')
acc = confusion(a, b, measure='acc')
phi = categorical_categorical(a, b, measure='phi')
kappa = agreement(a, b, measure='cohen_k')
biserial = binary_continuous(a, b, measure='biserial')
tau = concordance(a, b, measure='kendall_tau')
eta = categorical_continuous(a, b, measure='eta')
pearson = continuous_continuous(a, b, measure='pearson')

Software Copyright

Copyright 2020 One-Off Coder

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Book Copyright

Copyright 2020 One-Off Coder

This work is licensed under a Creative Commons Attribution 4.0 International License by One-Off Coder.

Creative Commons Attribution 4.0 International License

Art Copyright

Copyright 2020 Daytchia Vang

Citation

@misc{oneoffcoder_pypair_2020,
title={PyPair, A Statistical API for Bivariate Association Measures},
url={https://github.com/oneoffcoder/py-pair},
author={Jee Vang},
year={2020},
month={Nov}}

Sponsor, Love

Release files for pypair 3.0.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pypair 3.0.9
File Size Uploaded
pypair-3.0.9.tar.gz 24.7 kB Details

Release files / pypair-3.0.9.tar.gz

Download URL pypair-3.0.9.tar.gz
Size 24.7 kB
Tags Source
SHA-256 checksum
How to use checksums
139f038808597cc4d790bfbf5dd624673f2d57de2ebfa7aa866de6359ed787a7
BLAKE2b-256 checksum
How to use checksums
d1da8c082279cc3670173f6ddd50c3eadba4e069ab3fe6e05fe9ec5cff525e76
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.6.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5

Release history Release notifications | RSS feed

This release

3.0.9 This release

1 release file

3.0.8

1 release file

3.0.7

1 release file

3.0.6

1 release file

3.0.5

1 release file

3.0.4

1 release file

3.0.3

1 release file

3.0.1

1 release file

3.0.0

1 release file

2.0.0

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page