Skip to content

Small cleanup for the model types.#11602

Merged
trivialfis merged 7 commits into
dmlc:masterfrom
trivialfis:cleanup-tree-model
Jul 31, 2025
Merged

Small cleanup for the model types.#11602
trivialfis merged 7 commits into
dmlc:masterfrom
trivialfis:cleanup-tree-model

Conversation

@trivialfis
Copy link
Copy Markdown
Member

  • Remove binary-IO related code.
  • Split up the approx tree SHAP implementation.

- Remove binary-IO related code.
- Split up the approx tree SHAP implementation.
@trivialfis trivialfis requested a review from Copilot July 31, 2025 13:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

@trivialfis trivialfis changed the title Small cleanup for the tree model. Small cleanup for the model types. Jul 31, 2025
@trivialfis
Copy link
Copy Markdown
Member Author

cc @rongou .

@trivialfis trivialfis merged commit a9644bf into dmlc:master Jul 31, 2025
83 of 87 checks passed
@trivialfis trivialfis deleted the cleanup-tree-model branch July 31, 2025 19:07
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.

3 participants