Fix predict() ignoring base_margin in xgb.DMatrix#11880
Closed
Sanidhyavijay24 wants to merge 23 commits intodmlc:masterfrom
Closed
Fix predict() ignoring base_margin in xgb.DMatrix#11880Sanidhyavijay24 wants to merge 23 commits intodmlc:masterfrom
Sanidhyavijay24 wants to merge 23 commits intodmlc:masterfrom
Conversation
Added a check for nrounds=0 to prevent an invalid sequence in the iteration loop.
Fix handling of nrounds=0 to ensure 'iteration' is defined. But left a trailing whitespace by mistake , now fixed it .
whitespace/style error in previous commit
Added test for xgb.train with nrounds set to 0 to ensure it results in 0 iterations.
Updated test for xgb.train with nrounds = 0 to handle potential NULL return for empty models.
Removed unnecessary blank line in test case.
Enhanced test for xgb.train with nrounds = 0, including checks for serialization, continuation, and callbacks.
Updated test cases to use global 'train' variable instead of 'agaricus.train'. Adjusted parameters to include 'nthread' for consistency in xgb.train calls.
Added support for base_margin when using xgb.DMatrix.
Contributor
Author
|
Note on Commit History -> I can rebase/clean up the history if preferred, but "Squash and Merge" should handle it automatically. |
Removed unnecessary checks for internal margin when base_margin is NULL.
Updated test case to use a fresh DMatrix for prediction override testing.
Member
|
Doing some tests here: #11885 Not sure how practical it is to reject all changes after DMatrix construction. |
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.
Fixes #11872
The Issue ->
Previously,
predict.xgb.Boosterprevented passingbase_margin when the input wasxgb.DMatrix. Additionally, ifbase_marginwas NULL (default), the function failed to check internalDMatrix` attributes, causing predictions to ignore the margin entirely.The Fix ->
stop()block restriction.base_marginviasetinfoif passed explicitly.getinfo(newdata, "base_margin")if the argument is NULL.Test ->
Added a regression test verifying that changing the margin inside a
DMatrixalters the prediction, and that explicit arguments work.