ba
Bayesian Association — a unified probabilistic framework for exploring associations in categorical data, with dedicated support for QCA and Association Rule Mining.
To install: pip install ba
Claude Code skills
ba ships with two Claude Code skills
in .claude/skills/:
- ba-user — For anyone using ba as a library: choosing priors,
interpreting Bayes factors, writing QCA workflows, mining rules, handling
small-sample warnings. Useful prompts that would trigger this skill
automatically (if it's in scope):
- "Analyze my DataFrame for pairwise associations with Bayesian credible intervals"
- "What prior should I use for a dataset with only 15 cases?"
- "Walk me through a QCA analysis with calibration and Boolean minimization"
- ba-contributor — For developers modifying ba's source: adding measures to the registry, extending the Bayesian or QCA layers, writing tests, understanding the ContingencyTable hierarchy and Pot bridge.
You can invoke a skill explicitly via the slash command:
/ba-user Help me set up a prior sensitivity analysis for this 2×2 table
To make the skill available in another project, symlink it into that project's
.claude/skills/ directory:
# Make ba-user available in a specific project
mkdir -p /path/to/my-project/.claude/skills
ln -s /path/to/ba/.claude/skills/ba-user /path/to/my-project/.claude/skills/ba-user
# Or make it globally available (triggers across all projects)
ln -s /path/to/ba/.claude/skills/ba-user ~/.claude/skills/ba-user
See the skills documentation for more on skill scoping, and the Claude Code configuration guide for managing project vs. user-level settings.
Quick start
import ba
# Analyze all pairwise associations in a DataFrame
result = ba.analyze(df, outcome="Y")
result.summary() # metrics + Bayesian CIs for every pair
result.top_pairs(5) # strongest, most certain associations
Single-pair analysis
ct = ba.contingency_table(a=10, b=5, c=3, d=12)
ct.odds_ratio # 8.0
ct.phi # 0.471
ct.metrics(["lift", "phi", "cramers_v"])
# Bayesian posterior
post = ba.bayesian.posterior(ct, prior="jeffreys")
post.credible_interval["risk_difference"] # (0.12, 0.71)
post.prob_gt(0.0, "risk_difference") # 0.996
Per-tradition APIs
# Bayesian
ba.bayesian.posterior(ct, prior="uniform")
ba.bayesian.bayes_factor(ct)
ba.bayesian.sensitivity(ct, priors=["jeffreys", "uniform", "beta(2,2)"])
# QCA
binary_df = ba.qca.calibrate(df, {"age": 30, "illness": "any_present"})
tt = ba.qca.truth_table(binary_df, outcome="Y", conditions=["A", "B", "C"])
solution = ba.qca.minimize(tt)
ba.qca.necessity(binary_df, "Y", ["A", "B"])
# Association Rule Mining
rules = ba.rules.mine(df, min_support=0.1, outcome="Y")
Key features
- Categorical core, binary specialization. The core handles r×c contingency tables. Binary (2×2) is a specialization with extra metrics (OR, RR, phi, Yule's Q, QCA consistency/coverage).
- Uncertainty first. Every metric comes with Bayesian credible intervals. Bayes factors replace p-values as the default evidence measure.
- 22 built-in measures in an extensible registry — from support/lift to Cramér's V, mutual information, and Goodman-Kruskal gamma.
- QCA pipeline: calibrate → truth table → Quine-McCluskey minimization → necessity/sufficiency analysis, all with Bayesian CIs.
- Association rules with Bayesian augmentation, appearance constraints, and built-in brute-force mining (no mlxtend dependency required).
- Progressive disclosure.
ba.analyze()for one-liners;ba.bayesian/ba.rules/ba.qcafor per-tradition control;ContingencyTable/MeasureRegistryfor full access.
Metadata
Release files for ba 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ba-0.3.1.tar.gz | 128.9 kB | Without provenance | Details for ba-0.3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ba-0.3.1-py3-none-any.whl | Python 3 | none | any | Details for ba-0.3.1-py3-none-any.whl |
Total release size: 167.9 kB
Release files / ba-0.3.1.tar.gz
| Download URL | ba-0.3.1.tar.gz |
|---|---|
| Size | 128.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c0eaad0519a0264712e10ce915bd972ef352e7656cd38a10651d9854161c85a4
|
|
BLAKE2b-256 checksum How to use checksums |
e93424855288ea0c7fb90a6789d8841f35c297211a1b1327df9cbec8423a0dc6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / ba-0.3.1-py3-none-any.whl
| Download URL | ba-0.3.1-py3-none-any.whl |
|---|---|
| Size | 39.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a54bdeb6a1e782b742430399d69144d2d45b7aa3e00bb155aa528b11a880215d
|
|
BLAKE2b-256 checksum How to use checksums |
3f4078bd077b70b3b64c00499b81d045c5ab72dd409b79451815316176322483
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for ba 0.3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.