Skip to content

feat(chaid): emit split test stats (chi-square/p-value/df) in tree_nodes#1544

Merged
hidekoji merged 1 commit into
masterfrom
fix/chaid-parameters-support-660f8a
Jul 19, 2026
Merged

feat(chaid): emit split test stats (chi-square/p-value/df) in tree_nodes#1544
hidekoji merged 1 commit into
masterfrom
fix/chaid-parameters-support-660f8a

Conversation

@hidekoji

@hidekoji hidekoji commented Jul 18, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds the per-split test statistics to the CHAID tree_nodes tidy output so the
interactive decision-tree renderer (TAM) can display each split's adjusted
p-value, chi-square statistic, and df
on the splitting node, SPSS-style.

What changed

  • R/chaid.R — when a node splits, store the winning predictor's
    chi-square statistic and df on the node record (alongside the existing
    p_value / adjusted_p_value). Root and terminal records initialise the two
    new fields to NA.
  • R/build_chaid.Rbuild_chaid_tree_nodes() emits four new columns:
    p_value, adjusted_p_value, split_statistic, split_df. Values are
    populated on splitting nodes and NA on leaves (and on nodes whose best
    candidate failed the alpha_split gate). The rpart-compatible column order is
    preserved; the new columns are appended, so the existing N-ary renderer keeps
    working unchanged and simply ignores them until TAM reads them.
  • tests/testthat/test_build_chaid.R — new test asserting the stat columns
    exist, splitting nodes carry finite chi-square / df / adjusted p-value in
    [0,1], and leaves are NA.

Verification

test_build_chaid.R: 45 passing / 0 failing. Manual check on a target that
depends on a predictor produced chi-square = 139.31, df = 1, adjusted p < 0.001 on the root split, NA on leaves.

Note

Front-end display degrades gracefully: until a bundled exploratory release
ships these columns, TAM sees no split-stat columns and simply omits the block
(no crash).

🤖 Generated with Claude Code

Add p_value, adjusted_p_value, split_statistic, split_df columns to the
CHAID tree_nodes tidy output (build_chaid_tree_nodes) so the interactive
decision-tree renderer can show each split's adjusted p-value, chi-square
statistic, and df, SPSS-style. Stats are stored on the splitting node
(from the winning predictor's chi-square test) and left NA on leaves.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@hidekoji
hidekoji merged commit 320df6f into master Jul 19, 2026
3 checks passed
@hidekoji
hidekoji deleted the fix/chaid-parameters-support-660f8a branch July 19, 2026 01:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants