-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add support for combining hashes in vector columns to HashingTransformer #4828
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
Merged
Merged
Changes from 11 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
03fbcf0
Add "Combine" option.
yaeldMS 3d332ce
Add tests.
yaeldMS ea4a0b8
Add tests, and change data splitting APIs to use the new functionalit…
yaeldMS 08bb1e5
Address code review comment, change missing value handling and add a …
yaeldMS d48a3e8
Fix hashing tests.
yaeldMS 7868a52
Add test for backwards compatibility of model format.
yaeldMS f9c13aa
Fix build breaks and tests after rebase.
yaeldMS d315999
Combine V2 and V1 implementations of IHashers into one.
yaeldMS ef735d9
Update SaveAsOnnx.
yaeldMS d2c2d6a
fix baseline
yaeldMS d05dcf0
More unit test fixes
yaeldMS c5a140f
Code review comments.
yaeldMS e6bb9d8
Add back the back-compat test.
yaeldMS 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
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -511,19 +511,18 @@ internal static void EnsureGroupPreservationColumn(IHostEnvironment env, ref IDa | |
| var type = data.Schema[stratCol].Type; | ||
| if (!RangeFilter.IsValidRangeFilterColumnType(env, type)) | ||
| { | ||
| // Hash the samplingKeyColumn. | ||
| // REVIEW: this could currently crash, since Hash only accepts a limited set | ||
| // of column types. It used to be HashJoin, but we should probably extend Hash | ||
| // instead of having two hash transformations. | ||
| var origStratCol = samplingKeyColumn; | ||
| samplingKeyColumn = data.Schema.GetTempColumnName(samplingKeyColumn); | ||
| HashingEstimator.ColumnOptionsInternal columnOptions; | ||
| if (seed.HasValue) | ||
| columnOptions = new HashingEstimator.ColumnOptionsInternal(samplingKeyColumn, origStratCol, 30, (uint)seed.Value); | ||
| else if (((ISeededEnvironment)env).Seed.HasValue) | ||
| columnOptions = new HashingEstimator.ColumnOptionsInternal(samplingKeyColumn, origStratCol, 30, (uint)((ISeededEnvironment)env).Seed.Value); | ||
| else | ||
| columnOptions = new HashingEstimator.ColumnOptionsInternal(samplingKeyColumn, origStratCol, 30); | ||
| // HashingEstimator currently handles all primitive types except for DateTime, DateTimeOffset and TimeSpan. | ||
| var itemType = type.GetItemType(); | ||
| if (itemType is DateTimeDataViewType || itemType is DateTimeOffsetDataViewType || itemType is TimeSpanDataViewType) | ||
| data = new TypeConvertingTransformer(env, origStratCol, DataKind.Int64, origStratCol).Transform(data); | ||
|
|
||
| var localSeed = seed.HasValue ? seed : ((ISeededEnvironment)env).Seed.HasValue ? ((ISeededEnvironment)env).Seed : null; | ||
| var columnOptions = | ||
| localSeed.HasValue ? | ||
| new HashingEstimator.ColumnOptions(samplingKeyColumn, origStratCol, 30, (uint)localSeed.Value, combine: true) : | ||
| new HashingEstimator.ColumnOptions(samplingKeyColumn, origStratCol, 30, combine: true); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar comment as before. If the 30bits hashing is standard, can we define it as some global constant somewhere? |
||
| data = new HashingEstimator(env, columnOptions).Fit(data).Transform(data); | ||
| } | ||
| else | ||
|
|
||
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
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 realize the previous code too used 30 bits. But the default seems to be 31 bits. Any reason why we have 30 here? If there is a specific reason for 30 bits, can you please add a note to that in the code?
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 am actually not sure why 30 was chosen. If you think it's important I can try changing it back to 31.
In reply to: 386729669 [](ancestors = 386729669)
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 have no reason to say it should change to 31 either :-). But since it is is used in a couple of places, can you please make it a named constant?
In reply to: 425102125 [](ancestors = 425102125,386729669)