catdap2¶
pycatdap.catdap2 ¶
CATDAP-02: Optimal explanatory variable subset search.
Finds the best subset of explanatory variables for a response variable, with support for continuous variable binning (pooling).
Catdap2Result
dataclass
¶
Catdap2Result(
base_aic: float,
aic: DataFrame,
aic_order: list[str],
subsets: list[SubsetResult],
intervals: Mapping[str, list[float]],
tway_tables: Mapping[str, DataFrame],
)
Result container for :func:catdap2.
Attributes:
| Name | Type | Description |
|---|---|---|
base_aic |
float
|
AIC of the null model (no explanatory variables). |
aic |
DataFrame
|
Single-variable ΔAIC values with columns |
aic_order |
list[str]
|
Variables sorted by ΔAIC ascending (best first). |
subsets |
list[SubsetResult]
|
Best variable subsets grouped by size. |
intervals |
Mapping[str, list[float]]
|
Pooling boundaries for continuous variables. Empty for categorical-only analyses. |
tway_tables |
Mapping[str, DataFrame]
|
Two-way tables for each single explanatory variable. |
to_plotly_json ¶
Return a Plotly-Figure-compatible JSON spec for this result.
Produces a horizontal bar chart of single-variable ΔAIC values,
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). The subset-trajectory visualization will be added in v0.3+ (Issue #12 / #20).
Source code in src/pycatdap/catdap2.py
catdap2 ¶
catdap2(
data: DataFrame,
pool: list[int] | None = None,
response_name: str | None = None,
accuracy: list[float] | None = None,
nvar: int | None = None,
) -> Catdap2Result
Search for optimal explanatory variable subsets using AIC.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataFrame
|
Input data with categorical and/or continuous variables. Not modified. |
required |
pool
|
list[int] or None
|
Pooling method per column:
|
None
|
response_name
|
str or None
|
Response variable column name. If |
None
|
accuracy
|
list[float] or None
|
Minimum bin width per column for pooling.
If |
None
|
nvar
|
int or None
|
Number of top variables to retain for multi-variable search. |
None
|
Returns:
| Type | Description |
|---|---|
Catdap2Result
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If inputs are invalid. |
Source code in src/pycatdap/catdap2.py
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 | |