Grouped feature handling (xgboost) - #46
Open
jemus42 wants to merge 4 commits into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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,
$xgains a reconstructed factor so plot functions keep working and multiclass class suffixes are preserved.Progress on #26.