Small cleanup for the model types.#11602
Merged
Merged
Conversation
Member
trivialfis
commented
Jul 31, 2025
- Remove binary-IO related code.
- Split up the approx tree SHAP implementation.
- Remove binary-IO related code. - Split up the approx tree SHAP implementation.
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR performs a cleanup of the tree model implementation by removing deprecated binary IO code and refactoring the approximate SHAP implementation. The changes modernize the codebase by eliminating legacy code and improving code organization.
- Removes binary IO related code from TreeParam struct and RegTree class
- Moves the approximate SHAP calculation from RegTree to a standalone function in the treeshap module
- Updates header dependencies and function calls to use the new SHAP implementation
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/tree/tree_model.cc | Removes parameter registration, adds JSON serialization methods, and removes the approximate SHAP method |
| src/predictor/treeshap.h | New header file declaring the standalone approximate SHAP function |
| src/predictor/treeshap.cc | Implements the moved approximate SHAP calculation with updated function signature |
| src/predictor/cpu_treeshap.h | Deleted file - functionality moved to treeshap.h |
| src/predictor/cpu_predictor.cc | Updates include and function call to use new SHAP implementation |
| include/xgboost/tree_model.h | Removes binary IO code, deprecated fields, and the approximate SHAP method declaration |
Comments suppressed due to low confidence (3)
src/predictor/treeshap.h:4
- The header guard name 'XGBOOST_PREDICTOR_CPU_TREESHAP_H_' contains 'CPU' but the file is named 'treeshap.h'. The guard should be 'XGBOOST_PREDICTOR_TREESHAP_H_' to match the filename.
#ifndef XGBOOST_PREDICTOR_CPU_TREESHAP_H_
src/predictor/treeshap.h:34
- The header guard closing comment 'XGBOOST_PREDICTOR_CPU_TREESHAP_H_' should match the opening guard and be 'XGBOOST_PREDICTOR_TREESHAP_H_' to be consistent with the filename.
#endif // XGBOOST_PREDICTOR_CPU_TREESHAP_H_
src/predictor/treeshap.cc:18
- The variable type has changed from 'unsigned' to 'bst_feature_t' but this may cause type mismatch issues. The original code used 'unsigned split_index = 0' and later assigns 'tree[nid].SplitIndex()' which likely returns an unsigned type.
bst_feature_t split_index = 0;
Member
Author
|
cc @rongou . |
rongou
approved these changes
Jul 31, 2025
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.