-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename LabelLeakageDataCheck to TargetLeakageDataCheck. (#1319)
* Rename LabelLeakageDataCheck to TargetLeakageDataCheck. * Adding PR 1319 to relase notes. * Sorting imports in default_data_checks.py * Renaming tests from _label_ to _target_
- Loading branch information
1 parent
dec69b1
commit 1f8a964
Showing
8 changed files
with
86 additions
and
81 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
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
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
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
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
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
71 changes: 0 additions & 71 deletions
71
evalml/tests/data_checks_tests/test_label_leakage_data_check.py
This file was deleted.
Oops, something went wrong.
71 changes: 71 additions & 0 deletions
71
evalml/tests/data_checks_tests/test_target_leakage_data_check.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,71 @@ | ||
import pandas as pd | ||
import pytest | ||
|
||
from evalml.data_checks.data_check_message import DataCheckWarning | ||
from evalml.data_checks.target_leakage_data_check import TargetLeakageDataCheck | ||
|
||
|
||
def test_target_leakage_data_check_init(): | ||
target_leakage_check = TargetLeakageDataCheck() | ||
assert target_leakage_check.pct_corr_threshold == 0.95 | ||
|
||
target_leakage_check = TargetLeakageDataCheck(pct_corr_threshold=0.0) | ||
assert target_leakage_check.pct_corr_threshold == 0 | ||
|
||
target_leakage_check = TargetLeakageDataCheck(pct_corr_threshold=0.5) | ||
assert target_leakage_check.pct_corr_threshold == 0.5 | ||
|
||
target_leakage_check = TargetLeakageDataCheck(pct_corr_threshold=1.0) | ||
assert target_leakage_check.pct_corr_threshold == 1.0 | ||
|
||
with pytest.raises(ValueError, match="pct_corr_threshold must be a float between 0 and 1, inclusive."): | ||
TargetLeakageDataCheck(pct_corr_threshold=-0.1) | ||
with pytest.raises(ValueError, match="pct_corr_threshold must be a float between 0 and 1, inclusive."): | ||
TargetLeakageDataCheck(pct_corr_threshold=1.1) | ||
|
||
|
||
def test_target_leakage_data_check_warnings(): | ||
y = pd.Series([1, 0, 1, 1]) | ||
X = pd.DataFrame() | ||
X["a"] = y * 3 | ||
X["b"] = y - 1 | ||
X["c"] = y / 10 | ||
X["d"] = ~y | ||
X["e"] = [0, 0, 0, 0] | ||
y = y.astype(bool) | ||
|
||
leakage_check = TargetLeakageDataCheck(pct_corr_threshold=0.5) | ||
assert leakage_check.validate(X, y) == [DataCheckWarning("Column 'a' is 50.0% or more correlated with the target", "TargetLeakageDataCheck"), | ||
DataCheckWarning("Column 'b' is 50.0% or more correlated with the target", "TargetLeakageDataCheck"), | ||
DataCheckWarning("Column 'c' is 50.0% or more correlated with the target", "TargetLeakageDataCheck"), | ||
DataCheckWarning("Column 'd' is 50.0% or more correlated with the target", "TargetLeakageDataCheck")] | ||
|
||
|
||
def test_target_leakage_data_check_input_formats(): | ||
leakage_check = TargetLeakageDataCheck(pct_corr_threshold=0.8) | ||
|
||
# test empty pd.DataFrame, empty pd.Series | ||
assert leakage_check.validate(pd.DataFrame(), pd.Series()) == [] | ||
|
||
y = pd.Series([1, 0, 1, 1]) | ||
X = pd.DataFrame() | ||
X["a"] = y * 3 | ||
X["b"] = y - 1 | ||
X["c"] = y / 10 | ||
X["d"] = ~y | ||
X["e"] = [0, 0, 0, 0] | ||
y = y.astype(bool) | ||
|
||
expected_messages = [DataCheckWarning("Column 'a' is 80.0% or more correlated with the target", "TargetLeakageDataCheck"), | ||
DataCheckWarning("Column 'b' is 80.0% or more correlated with the target", "TargetLeakageDataCheck"), | ||
DataCheckWarning("Column 'c' is 80.0% or more correlated with the target", "TargetLeakageDataCheck"), | ||
DataCheckWarning("Column 'd' is 80.0% or more correlated with the target", "TargetLeakageDataCheck")] | ||
|
||
# test y as list | ||
assert leakage_check.validate(X, y.values) == expected_messages | ||
|
||
# test X as np.array | ||
assert leakage_check.validate(X.to_numpy(), y) == [DataCheckWarning("Column '0' is 80.0% or more correlated with the target", "TargetLeakageDataCheck"), | ||
DataCheckWarning("Column '1' is 80.0% or more correlated with the target", "TargetLeakageDataCheck"), | ||
DataCheckWarning("Column '2' is 80.0% or more correlated with the target", "TargetLeakageDataCheck"), | ||
DataCheckWarning("Column '3' is 80.0% or more correlated with the target", "TargetLeakageDataCheck")] |