[Refactor] Made CrossValTypes, HoldoutValTypes to have split functions directly#108
Open
nabenabe0928 wants to merge 12 commits intoautoml:masterfrom
Open
Conversation
nabenabe0928
commented
Feb 22, 2021
| class HoldoutValTypes(Enum): | ||
| """The type of hold out validation (refer to CrossValTypes' doc-string)""" | ||
| holdout_validation = partial(HoldoutValFuncs.holdout_validation) | ||
| stratified_holdout_validation = partial(HoldoutValFuncs.stratified_holdout_validation) |
Collaborator
Author
There was a problem hiding this comment.
Major change: IntEnum -> Enum and holding functions directly
|
|
||
| def __call__(self, val_share: float, indices: np.ndarray, stratify: Optional[Any] | ||
| ) -> Tuple[np.ndarray, np.ndarray]: | ||
| self.value(val_share=val_share, indices=indices, stratify=stratify) |
Collaborator
Author
There was a problem hiding this comment.
Now we can call the function directly in a way that HoldoutValTypes.holdout_validation().
|
|
||
|
|
||
| class HoldOutFunc(Protocol): | ||
| class HoldoutValFunc(Protocol): |
Collaborator
Author
There was a problem hiding this comment.
Since we often use holdout_validator, I unified the name.
62b326e to
c7fd2d5
Compare
c7fd2d5 to
a7e8a7f
Compare
1e82b21 to
d313a48
Compare
Since the previous codes had the default shuffle = True and the indices shuffle before splitting, the test cases for CV and Holdout did not match. More specifically, when I bring back the followings, I could reproduce the original outputs: 1. Bring back _get_indices in BaseDataset 2. Make the default value of self.shuffle in BaseDataset True 3. Input shuffle = True in KFold instead of using ShuffleSplit These reproduce the original outputs. Note that KFold(shuffle=True) and ShuffleSplit() are not identical and even when we input the same random_state, the results do not reproduce.
af8059b to
6ef981d
Compare
ravinkohli
reviewed
May 20, 2021
| indices: np.ndarray, | ||
| **kwargs: Any | ||
| ) -> List[Tuple[np.ndarray, np.ndarray]]: | ||
| Additionally, HoldoutValTypes.<function> can be called directly. |
Contributor
There was a problem hiding this comment.
can you add an example to use it directly?
ravinkohli
reviewed
May 20, 2021
|
|
||
|
|
||
| class CrossValFuncs(): | ||
| # (shuffle, is_stratify) -> split_fn |
Contributor
There was a problem hiding this comment.
can we also have documentation similar to HoldoutFuncs here?
ravinkohli
reviewed
May 20, 2021
Contributor
ravinkohli
left a comment
There was a problem hiding this comment.
Hey, thanks a lot for this PR. I have left a few suggestions. Also, could you state the reason for making this PR. What issues were there in the previous implementation? How does this PR solve them?
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.
While maintaining the changes as small as possible, I made the changes.