catdap1¶
pycatdap.catdap1 ¶
CATDAP-01: Pairwise AIC evaluation of categorical variable associations.
Evaluates every pair of categorical variables in a DataFrame using AIC, ranking explanatory variables by their informativeness for each response.
Catdap1Result
dataclass
¶
Catdap1Result(
tway_tables: Mapping[tuple[str, str], DataFrame],
aic: DataFrame,
aic_order: Mapping[str, list[str]],
total: Series,
)
Result container for :func:catdap1.
Attributes:
| Name | Type | Description |
|---|---|---|
tway_tables |
Mapping[tuple[str, str], DataFrame]
|
Two-way frequency tables keyed by |
aic |
DataFrame
|
ΔAIC values. Rows are response variables, columns are all
variables in the original column order. Self-entries are |
aic_order |
Mapping[str, list[str]]
|
For each response variable, explanatory variables sorted by ΔAIC ascending (best first). Read-only mapping. |
total |
Series
|
Per-column non-null count from the input data. Note: pairwise observation counts used in AIC may differ when NaN values exist. |
to_plotly_json ¶
Return a Plotly-Figure-compatible JSON spec for this result.
Produces a horizontal bar chart of ΔAIC values per explanatory
variable for the first response in :attr:aic. Suitable for
direct consumption by react-plotly.js or any Plotly renderer.
Returns:
| Type | Description |
|---|---|
dict
|
Plotly figure spec with |
Notes
Implements the contract from BLUEPRINT.md §5.7 / DP-4 (LizyStudio integration). Multi-response handling and richer payloads will be added in v0.3+ (Issue #12).
Source code in src/pycatdap/catdap1.py
catdap1 ¶
Evaluate pairwise associations between categorical variables using AIC.
For each response variable, computes ΔAIC for every other variable as explanatory, then ranks them by informativeness.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
DataFrame of categorical variables. Not modified. |
required |
response_names
|
list[str] or None
|
Column names to use as response variables. If |
None
|
Returns:
| Type | Description |
|---|---|
Catdap1Result
|
Container with two-way tables, AIC values, rankings, and totals. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If data is empty, has fewer than 2 columns, or a response name is missing. |