Skip to content

Commit

Permalink
Deprecation error 1536 (#1548)
Browse files Browse the repository at this point in the history
* Added drift warnings for drift conditions

* pylint changes
  • Loading branch information
nirhutnik authored and Matan Perlmutter committed May 31, 2022
1 parent b4bd746 commit 67ee47c
Show file tree
Hide file tree
Showing 7 changed files with 151 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ def run_logic(self, context: Context) -> CheckResult:
return CheckResult(value=values_dict, display=displays, header='Train Test Prediction Drift')

def add_condition_drift_score_not_greater_than(self, max_allowed_categorical_score: float = 0.15,
max_allowed_numeric_score: float = 0.075):
max_allowed_numeric_score: float = 0.075,
max_allowed_psi_score: float = None,
max_allowed_earth_movers_score: float = None):
"""
Add condition - require drift score to not be more than a certain threshold.
Expand All @@ -147,11 +149,31 @@ def add_condition_drift_score_not_greater_than(self, max_allowed_categorical_sco
the max threshold for the categorical variable drift score
max_allowed_numeric_score: float , default: 0.1
the max threshold for the numeric variable drift score
max_allowed_psi_score: float, default None
Deprecated. Please use max_allowed_categorical_score instead
max_allowed_earth_movers_score: float, default None
Deprecated. Please use max_allowed_numeric_score instead
Returns
-------
ConditionResult
False if any column has passed the max threshold, True otherwise
"""
if max_allowed_psi_score is not None:
warnings.warn(
f'{self.__class__.__name__}: max_allowed_psi_score is deprecated. please use '
f'max_allowed_categorical_score instead',
DeprecationWarning
)
if max_allowed_categorical_score is not None:
max_allowed_categorical_score = max_allowed_psi_score
if max_allowed_earth_movers_score is not None:
warnings.warn(
f'{self.__class__.__name__}: max_allowed_earth_movers_score is deprecated. please use '
f'max_allowed_numeric_score instead',
DeprecationWarning
)
if max_allowed_numeric_score is not None:
max_allowed_numeric_score = max_allowed_earth_movers_score

def condition(result: Dict) -> ConditionResult:
drift_score = result['Drift score']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,13 @@ def run_logic(self, context: Context) -> CheckResult:
displays = [headnote] + [displays_dict[col] for col in columns_order
if col in train_dataset.cat_features + train_dataset.numerical_features]

return CheckResult(value=values_dict, display=displays, header='Train Test Drift')
return CheckResult(value=values_dict, display=displays, header='Train Test Feature Drift')

def add_condition_drift_score_not_greater_than(self, max_allowed_categorical_score: float = 0.2,
max_allowed_numeric_score: float = 0.1,
number_of_top_features_to_consider: int = 5):
number_of_top_features_to_consider: int = 5,
max_allowed_psi_score: float = None,
max_allowed_earth_movers_score: float = None):
"""
Add condition - require drift score to not be more than a certain threshold.
Expand All @@ -239,11 +241,32 @@ def add_condition_drift_score_not_greater_than(self, max_allowed_categorical_sco
number_of_top_features_to_consider: int , default: 5
the number of top features for which exceed the threshold will fail the
condition.
max_allowed_psi_score: float, default None
Deprecated. Please use max_allowed_categorical_score instead
max_allowed_earth_movers_score: float, default None
Deprecated. Please use max_allowed_numeric_score instead
Returns
-------
ConditionResult
False if any column has passed the max threshold, True otherwise
"""
if max_allowed_psi_score is not None:
warnings.warn(
f'{self.__class__.__name__}: max_allowed_psi_score is deprecated. please use '
f'max_allowed_categorical_score instead',
DeprecationWarning
)
if max_allowed_categorical_score is not None:
max_allowed_categorical_score = max_allowed_psi_score
if max_allowed_earth_movers_score is not None:
warnings.warn(
f'{self.__class__.__name__}: max_allowed_earth_movers_score is deprecated. please use '
f'max_allowed_numeric_score instead',
DeprecationWarning
)
if max_allowed_numeric_score is not None:
max_allowed_numeric_score = max_allowed_earth_movers_score

def condition(result: Dict) -> ConditionResult:
cat_method, num_method = get_drift_method(result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ def run_logic(self, context: Context) -> CheckResult:
return CheckResult(value=values_dict, display=displays, header='Train Test Label Drift')

def add_condition_drift_score_not_greater_than(self, max_allowed_categorical_score: float = 0.2,
max_allowed_numeric_score: float = 0.1):
max_allowed_numeric_score: float = 0.1,
max_allowed_psi_score: float = None,
max_allowed_earth_movers_score: float = None):
"""
Add condition - require drift score to not be more than a certain threshold.
Expand All @@ -137,11 +139,31 @@ def add_condition_drift_score_not_greater_than(self, max_allowed_categorical_sco
the max threshold for the categorical variable drift score
max_allowed_numeric_score: float , default: 0.1
the max threshold for the numeric variable drift score
max_allowed_psi_score: float, default None
Deprecated. Please use max_allowed_categorical_score instead
max_allowed_earth_movers_score: float, default None
Deprecated. Please use max_allowed_numeric_score instead
Returns
-------
ConditionResult
False if any column has passed the max threshold, True otherwise
"""
if max_allowed_psi_score is not None:
warnings.warn(
f'{self.__class__.__name__}: max_allowed_psi_score is deprecated. please use '
f'max_allowed_categorical_score instead',
DeprecationWarning
)
if max_allowed_categorical_score is not None:
max_allowed_categorical_score = max_allowed_psi_score
if max_allowed_earth_movers_score is not None:
warnings.warn(
f'{self.__class__.__name__}: max_allowed_earth_movers_score is deprecated. please use '
f'max_allowed_numeric_score instead',
DeprecationWarning
)
if max_allowed_numeric_score is not None:
max_allowed_numeric_score = max_allowed_earth_movers_score

def condition(result: Dict) -> ConditionResult:
drift_score = result['Drift score']
Expand Down
17 changes: 17 additions & 0 deletions deepchecks/tabular/deprecation_warnings.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,20 @@
category=DeprecationWarning,
module=r'deepchecks.*'
)

# Added in 0.7 Warning filters for drift conditions
# Should be removed in 0.8

warnings.filterwarnings(
action='once',
message=r'.*max_allowed_psi_score is deprecated.*',
category=DeprecationWarning,
module=r'deepchecks.*'
)

warnings.filterwarnings(
action='once',
message=r'.*max_allowed_earth_movers_score is deprecated.*',
category=DeprecationWarning,
module=r'deepchecks.*'
)
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,9 @@ def compute(self, context: Context) -> CheckResult:
return CheckResult(value=values_dict, display=displays, header='Train Test Prediction Drift')

def add_condition_drift_score_not_greater_than(self, max_allowed_categorical_score: float = 0.15,
max_allowed_numeric_score: float = 0.075
max_allowed_numeric_score: float = 0.075,
max_allowed_psi_score: float = None,
max_allowed_earth_movers_score: float = None
) -> 'TrainTestPredictionDrift':
"""
Add condition - require prediction properties drift score to not be more than a certain threshold.
Expand All @@ -236,11 +238,31 @@ def add_condition_drift_score_not_greater_than(self, max_allowed_categorical_sco
the max threshold for the categorical variable drift score
max_allowed_numeric_score: float , default: 0.075
the max threshold for the numeric variable drift score
max_allowed_psi_score: float, default None
Deprecated. Please use max_allowed_categorical_score instead
max_allowed_earth_movers_score: float, default None
Deprecated. Please use max_allowed_numeric_score instead
Returns
-------
ConditionResult
False if any property has passed the max threshold, True otherwise
"""
if max_allowed_psi_score is not None:
warnings.warn(
f'{self.__class__.__name__}: max_allowed_psi_score is deprecated. please use '
f'max_allowed_categorical_score instead',
DeprecationWarning
)
if max_allowed_categorical_score is not None:
max_allowed_categorical_score = max_allowed_psi_score
if max_allowed_earth_movers_score is not None:
warnings.warn(
f'{self.__class__.__name__}: max_allowed_earth_movers_score is deprecated. please use '
f'max_allowed_numeric_score instead',
DeprecationWarning
)
if max_allowed_numeric_score is not None:
max_allowed_numeric_score = max_allowed_earth_movers_score

def condition(result: Dict) -> ConditionResult:
cat_method, num_method = get_drift_method(result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,9 @@ def compute(self, context: Context) -> CheckResult:
return CheckResult(value=values_dict, display=displays, header='Train Test Label Drift')

def add_condition_drift_score_not_greater_than(self, max_allowed_categorical_score: float = 0.15,
max_allowed_numeric_score: float = 0.075
max_allowed_numeric_score: float = 0.075,
max_allowed_psi_score: float = None,
max_allowed_earth_movers_score: float = None
) -> 'TrainTestLabelDrift':
"""
Add condition - require label properties drift score to not be more than a certain threshold.
Expand All @@ -234,11 +236,31 @@ def add_condition_drift_score_not_greater_than(self, max_allowed_categorical_sco
the max threshold for the PSI score
max_allowed_numeric_score: float , default: 0.075
the max threshold for the Earth Mover's Distance score
max_allowed_psi_score: float, default None
Deprecated. Please use max_allowed_categorical_score instead
max_allowed_earth_movers_score: float, default None
Deprecated. Please use max_allowed_numeric_score instead
Returns
-------
ConditionResult
False if any column has passed the max threshold, True otherwise
"""
if max_allowed_psi_score is not None:
warnings.warn(
f'{self.__class__.__name__}: max_allowed_psi_score is deprecated. please use '
f'max_allowed_categorical_score instead',
DeprecationWarning
)
if max_allowed_categorical_score is not None:
max_allowed_categorical_score = max_allowed_psi_score
if max_allowed_earth_movers_score is not None:
warnings.warn(
f'{self.__class__.__name__}: max_allowed_earth_movers_score is deprecated. please use '
f'max_allowed_numeric_score instead',
DeprecationWarning
)
if max_allowed_numeric_score is not None:
max_allowed_numeric_score = max_allowed_earth_movers_score

def condition(result: Dict) -> ConditionResult:
cat_method, num_method = get_drift_method(result)
Expand Down
17 changes: 17 additions & 0 deletions deepchecks/vision/deprecation_warnings.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,20 @@
category=DeprecationWarning,
module=r'deepchecks.*'
)

# Added in 0.7 Warning filters for drift conditions
# Should be removed in 0.8

warnings.filterwarnings(
action='once',
message=r'.*max_allowed_psi_score is deprecated.*',
category=DeprecationWarning,
module=r'deepchecks.*'
)

warnings.filterwarnings(
action='once',
message=r'.*max_allowed_earth_movers_score is deprecated.*',
category=DeprecationWarning,
module=r'deepchecks.*'
)

0 comments on commit 67ee47c

Please sign in to comment.