New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement feature score in GBTree. #7041
Conversation
bcf37d5
to
d6ac445
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implementation looks great! Very clean and readable. I had just one question that stems from my own lack of familiarity with the codebase, but everything LGTM.
* Support categorical data.
4cb1bab
to
3d82f2b
Compare
for feat, score in zip(features_arr, scores_arr): | ||
results[feat] = score | ||
return results |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @trivialfis, can we convert score
to the native python float type here for a use case below?
model = xgb.train(...)
imp = model. get_score(...)
with open(filepath, "w") as f:
json.dump(imp, f)
# throws TypeError: Object of type 'float32' is not JSON serializable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can do imp = {k: float(v) for k, v in imp.items()}
though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing that out, I will update with a new PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the quick action!
Related: #6091 .
Other than eliminating parsing, this is also for categorical data support. The old text parsing implementation doesn't understand categorical split outputs.