Skip to content

Grouped feature handling (xgboost) - #46

Open
jemus42 wants to merge 4 commits into
masterfrom
group-features
Open

Grouped feature handling (xgboost)#46
jemus42 wants to merge 4 commits into
masterfrom
group-features

Conversation

@jemus42

@jemus42 jemus42 commented Jul 18, 2026

Copy link
Copy Markdown
Collaborator

Aggregates decomposition terms so a set of features is treated as one feature, the main use case being dummy-encoded categoricals in xgboost: a one-hot factor's 15 dummy-level terms collapse to the conceptual f / x1 / f:x1.
The decomposition is additive, so regrouping is exact, components still sum to the prediction and group SHAP values are the sums of member SHAP values, preserving efficiency.

For dummy-encoded groups, $x gains a reconstructed factor so plot functions keep working and multiclass class suffixes are preserved.

Progress on #26.

jemus42 and others added 4 commits July 18, 2026 15:23
Aggregates decomposition terms so a set of features is treated as one
feature, the main use case being dummy-encoded categoricals in xgboost:
a one-hot factor's 15 dummy-level terms collapse to the conceptual
f / x1 / f:x1. The decomposition is additive, so regrouping is exact --
components still sum to the prediction and group SHAP values are the
sums of member SHAP values, preserving efficiency. For dummy-encoded
groups, $x gains a reconstructed factor so plot functions keep working;
multiclass class suffixes are preserved.

Progress on #26.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Builds the groups list for group_components() from the factor columns
of the original data, so users need not hand-write
list(season = paste0("season", levels(...))). Defaults to the
model.matrix() naming convention, which covers one-hot and treatment
coding (dropped reference levels are skipped); a naming function
of (feature, levels) supports other encoding schemes, validated
against the columns the model was actually trained with via object$x.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Walks the grouping API on the built-in bike data: the dummy-encoding
term explosion, group_components() + dummy_groups() to re-assemble the
factor, exactness and SHAP efficiency checks, plots on the grouped
object, custom naming functions, and semantic (non-dummy) groups.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

1 participant