-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
[R-package] Allow for valid data to be a slice of the training data #6844
Open
walkerjameschris
wants to merge
7
commits into
microsoft:master
Choose a base branch
from
walkerjameschris:fix/slice-reference
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1c3699f
Only set reference if one does not exist
walkerjameschris b6ac834
Adding unit test for training on slices of ldb.Dataset
walkerjameschris 25d681b
Correcting whitespace
walkerjameschris 6b1add4
Adding types for constants
walkerjameschris 1153a10
Adding integer qualifier
walkerjameschris 97a6691
Merge branch 'master' into fix/slice-reference
walkerjameschris d39bc5d
Merge branch 'master' into fix/slice-reference
walkerjameschris File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
Only set reference if one does not exist
Slices of datasets already contain a reference to the base data (e.g., R/lgb.Dataset.R:562). This change only sets a reference to the base dataset if one does not already exist.
- Loading branch information
commit 1c3699fd148fa87bf1b5db51267ac276516f53c9
There are no files selected for viewing
This file contains 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
Oops, something went wrong.
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.
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.
I don't think this is quite right.
This would result in not attempting the update if the validation
Dataset
has any reference. That's a problem, because it means that if the training data and validation data have different bin mappers, we might not find that out until much later in the program (and probably with hard-to-understand errors or maybe even more serious problems like segfaults).(if you're not sure what the terms "reference" or "bin mapper" mean in the context of LightGBM, please tell me and I'll explain)
I think the root cause of this bug is actually right here:
LightGBM/R-package/R/lgb.Dataset.R
Lines 647 to 652 in 6437645
When
private$reference
is notNULL
, it's anlgb.Dataset
(an{R6}
class instance).Using
identical()
on 2{R6}
class instances is not reliable... it can be affected by implementation details of how{R6}
works:But for that check, it does not matter whether they're the same exact R object (in fact, we can be confident that they aren't)... it's just important that their handles point to the same
Dataset
on the C++ side.I don't really want to take on maintaining or implementing an
==.lgb.Dataset()
generic here (as suggested in r-lib/R6#211)... for this purpose, I think we should try an internal function that only checks the equality of the characteristics we care about.Maybe something like this in
lgb.Dataset.R
(you may have to experiment with this a bit):And then replacing
identical()
with a call to that function in the spot I linked to above.Are you interested in attempting that?
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.
I appreciate you taking the time to break that down! This makes sense so far. I’d like to make an attempt at those changes so I can understand the codebase better. Thanks!