Python implementation of CATDAP (CATegorical Data Analysis Program)
Project description
pycatdap
AIC-based EDA and ML error analysis library for categorical data.
pycatdap is a Python implementation of CATDAP (CATegorical Data Analysis Program), developed by Sakamoto & Katsura (1980) at the Institute of Statistical Mathematics. It extends the classic CATDAP toolkit with modern exploratory data analysis (EDA) and machine learning error analysis workflows.
📖 Documentation: https://nbx-liz.github.io/pycatdap/
Why pycatdap?
Unlike general profilers (ydata-profiling, Skrub) or slice discovery tools (DivExplorer, pysubgroup), pycatdap uses AIC as its core relevance measure. This gives it four unique advantages:
| Feature | Most tools | pycatdap |
|---|---|---|
| Variable relevance | Cramér's V, mutual info | AIC — explicit info-vs-complexity trade-off |
| Continuous binning | Equal-width or quantile | AIC-optimal binning |
| Subset discovery | Feature importance ranking | CATDAP-02 combinatorial search |
| Model coupling | Tied to specific frameworks | Model-agnostic (works with y_true, y_pred from anywhere) |
Installation
# Core
pip install pycatdap
# With visualization (matplotlib)
pip install "pycatdap[plot]"
# With interactive Plotly figures + HTML reports
pip install "pycatdap[plotly]"
Supported: Python 3.10 / 3.11 / 3.12 / 3.13
Quickstart
Classic CATDAP
import pycatdap
df = pycatdap.datasets.load_health_data()
# CATDAP-01: pairwise AIC analysis
result = pycatdap.catdap1(df, response_names=["symptoms"])
print(result.aic_order["symptoms"]) # variables ranked by ΔAIC
# CATDAP-02: best explanatory subset
result2 = pycatdap.catdap2(
df,
pool=[2, 2, 2, 0, 0, 0, 0, 2],
response_name="symptoms",
accuracy=[0., 0., 0., 1., 1., 1., 0.1, 0.],
)
for s in result2.subsets[:3]:
print(f"AIC={s.aic:.2f}, vars={s.variables}")
One-call EDA report (v0.5+)
report = pycatdap.profile(df, response="symptoms")
report.show() # Jupyter inline
report.to_html("report.html") # self-contained HTML, inline Plotly
report.to_dict() # JSON-friendly
report.to_plotly_json() # react-plotly.js / LizyStudio
ProfileResult exposes overview, variables (one VariableCard per
column, including ΔAIC vs the response), association (m × m ΔAIC
matrix), top_subsets (CATDAP-02 result when response is given), and
quality_warnings (high_cardinality / constant / id_candidate /
high_missing with overridable thresholds). See
docs/tutorials/08-profile-titanic.ipynb
for an end-to-end walkthrough.
Target analysis and CI-integrable suite (v0.6+)
# Target-driven: rank every column by ΔAIC vs `response`, keep top-K cross-tabs
ta = pycatdap.target_analysis(df, response="symptoms", top_k=5)
ta.ranking # variable / delta_aic / kind / n_obs
ta.top_summaries["cholesterol"] # full TargetSummary for drill-down
# Quality scan only (fast — no catdap2 / association_matrix)
qr = pycatdap.quality_report(df)
assert qr.passed, qr.show()
# CI gate: one-line data contract
suite = pycatdap.suite.AICIndependenceSuite(df, response="symptoms")
result = suite.run()
assert result.passed, result.summary()
# Non-AIC association measures (pure-numpy, no scipy)
m = pycatdap.association_matrix(df, measure="cramers_v")
pycatdap.measures.register("my_measure", my_fn) # pluggable per pysubgroup convention
See docs/tutorials/09-phase-d-target-analysis-and-suite.ipynb.
ML error analysis (planned, v0.8+)
# Coming in v0.8
result = pycatdap.error_analysis(
df=test_df,
y_true=y_test,
y_pred=model.predict(X_test),
)
result.show() # Jupyter
result.to_html("errors.html") # standalone report
result.top_slices # natural-language cohort descriptions
Status & Roadmap
| Version | Theme |
|---|---|
| v0.2.0 ✅ | Core CATDAP-01/02 (released) |
| v0.3.0 — v0.6.0 | EDA workflow (Plotly backend, profile, target analysis) |
| v0.7.0 — v0.11.0 | ML error analysis (slice discovery, calibration, drift) |
| v0.12.0 | LizyStudio integration |
| v1.0.0 | API stabilization |
Full roadmap: PLAN.md · Meta Issue #11
Development
git clone https://github.com/nbx-liz/pycatdap.git
cd pycatdap
uv sync --all-groups
uv run pytest # tests (excluding slow R cross-validation)
uv run pytest -m slow # slow tests (requires R + catdap package)
uv run python -m mkdocs serve # local docs preview
make ci # ruff + mypy + pytest + build
Contributing guidelines: CONTRIBUTING.md
Project structure
| Document | Purpose |
|---|---|
| BLUEPRINT.md | Canonical specification (Japanese) |
| HISTORY.md | Proposal-to-decision log (Japanese) |
| PLAN.md | Development roadmap (Japanese) |
| CHANGELOG.md | Release history |
| docs/ | Published documentation site |
Citation
If you use pycatdap in research, please cite the original CATDAP work:
@article{sakamoto1980categorical,
title={Categorical Data Analysis by AIC},
author={Sakamoto, Yosiyuki and Katsura, Koichi},
journal={Mathematical Sciences},
year={1980}
}
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pycatdap-0.6.0.tar.gz.
File metadata
- Download URL: pycatdap-0.6.0.tar.gz
- Upload date:
- Size: 475.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
54cb30a8e25dc9db87eaf4766d50eb045e40d63008e656b0f88d02caff2292a2
|
|
| MD5 |
6de84d3fbc61db9f49538aaab3377c49
|
|
| BLAKE2b-256 |
d710afa6062a38f07f73a1f27fd9935876b4177a8a923761b7408e4b59b5caab
|
Provenance
The following attestation bundles were made for pycatdap-0.6.0.tar.gz:
Publisher:
release.yml on nbx-liz/pycatdap
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pycatdap-0.6.0.tar.gz -
Subject digest:
54cb30a8e25dc9db87eaf4766d50eb045e40d63008e656b0f88d02caff2292a2 - Sigstore transparency entry: 1655071029
- Sigstore integration time:
-
Permalink:
nbx-liz/pycatdap@919591f79fc897d10c19dddd8dab3079c70f1bc2 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/nbx-liz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@919591f79fc897d10c19dddd8dab3079c70f1bc2 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file pycatdap-0.6.0-py3-none-any.whl.
File metadata
- Download URL: pycatdap-0.6.0-py3-none-any.whl
- Upload date:
- Size: 125.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d8e2e9e40a254fda06e0bcb3b08b0e177c207b3c121a80a02ef2bc43cdb1141
|
|
| MD5 |
a60ac74bf98cad2683972aa2ff8b34bf
|
|
| BLAKE2b-256 |
ff8b9f64b7073cca1eb03158fa5a0b14639959e0d5a3e7c10cbb16ab9ba217a1
|
Provenance
The following attestation bundles were made for pycatdap-0.6.0-py3-none-any.whl:
Publisher:
release.yml on nbx-liz/pycatdap
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pycatdap-0.6.0-py3-none-any.whl -
Subject digest:
5d8e2e9e40a254fda06e0bcb3b08b0e177c207b3c121a80a02ef2bc43cdb1141 - Sigstore transparency entry: 1655071091
- Sigstore integration time:
-
Permalink:
nbx-liz/pycatdap@919591f79fc897d10c19dddd8dab3079c70f1bc2 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/nbx-liz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@919591f79fc897d10c19dddd8dab3079c70f1bc2 -
Trigger Event:
workflow_dispatch
-
Statement type: