Skip to content
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

Merged
merged 4 commits into from Jun 18, 2021
Merged

Conversation

trivialfis
Copy link
Member

Related: #6091 .

Other than eliminating parsing, this is also for categorical data support. The old text parsing implementation doesn't understand categorical split outputs.

Copy link
Contributor

@wphicks wphicks left a 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.

src/c_api/c_api_utils.h Show resolved Hide resolved
@trivialfis trivialfis merged commit 7dd29ff into dmlc:master Jun 18, 2021
@trivialfis trivialfis deleted the feature-score branch June 18, 2021 03:53
Comment on lines +2242 to +2244
for feat, score in zip(features_arr, scores_arr):
results[feat] = score
return results
Copy link

@harupy harupy Jun 18, 2021

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

Copy link

@harupy harupy Jun 18, 2021

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.

Copy link
Member Author

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.

Copy link

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!

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.

None yet

4 participants