-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(train_test_split): Add "shuffle is True" warning (#791)
Addresses #684
- Loading branch information
1 parent
4335f13
commit 09de4b6
Showing
4 changed files
with
61 additions
and
17 deletions.
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
42 changes: 42 additions & 0 deletions
42
skore/src/skore/sklearn/train_test_split/warning/shuffle_true_warning.py
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
"""'Shuffle is true' warning. | ||
This warning is shown when ``shuffle`` is set to True. | ||
""" | ||
|
||
from __future__ import annotations | ||
|
||
from skore.sklearn.train_test_split.warning.train_test_split_warning import ( | ||
TrainTestSplitWarning, | ||
) | ||
|
||
|
||
class ShuffleTrueWarning(TrainTestSplitWarning): | ||
"""Check whether ``shuffle`` is set to ``True``.""" | ||
|
||
MSG = ( | ||
"We detected that the `shuffle` parameter is set to `True` either explicitly " | ||
"or from its default value. In case of time-ordered events (even if they are " | ||
"independent), this will result in inflated model performance evaluation " | ||
"because natural drift will not be taken into account. We recommend setting " | ||
"the shuffle parameter to `False` in order to ensure the evaluation process is " | ||
"really representative of your production release process." | ||
) | ||
|
||
@staticmethod | ||
def check( | ||
shuffle: bool, | ||
**kwargs, | ||
) -> bool: | ||
"""Check whether ``shuffle`` is set to ``True``. | ||
Parameters | ||
---------- | ||
shuffle : bool | ||
Whether to shuffle the data before splitting. | ||
Returns | ||
------- | ||
bool | ||
True if the check passed, False otherwise. | ||
""" | ||
return shuffle is False |
File renamed without changes.
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