Repository: deepchecks/deepchecks

Issue:
[BUG][HOTFIX] Add deprecation warning for condition parameter names
In 0.7 the drift checks were updated to add Cramer's V.
Thus the previous parameter condition names ("max_psi...  "max_earthmovers...") were renamed.
Previous parameters should still be re-added with deprecation warnings, for all relevant checks and conditions.



Discussion:

Resolving patch:
diff --git a/deepchecks/tabular/deprecation_warnings.py b/deepchecks/tabular/deprecation_warnings.py
--- a/deepchecks/tabular/deprecation_warnings.py
+++ b/deepchecks/tabular/deprecation_warnings.py
@@ -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.*'
+)
diff --git a/deepchecks/vision/deprecation_warnings.py b/deepchecks/vision/deprecation_warnings.py
--- a/deepchecks/vision/deprecation_warnings.py
+++ b/deepchecks/vision/deprecation_warnings.py
@@ -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.*'
+)


Test patch:
diff --git a/deepchecks/tabular/checks/model_evaluation/train_test_prediction_drift.py b/deepchecks/tabular/checks/model_evaluation/train_test_prediction_drift.py
--- a/deepchecks/tabular/checks/model_evaluation/train_test_prediction_drift.py
+++ b/deepchecks/tabular/checks/model_evaluation/train_test_prediction_drift.py
@@ -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.
 
@@ -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']
diff --git a/deepchecks/tabular/checks/train_test_validation/train_test_feature_drift.py b/deepchecks/tabular/checks/train_test_validation/train_test_feature_drift.py
--- a/deepchecks/tabular/checks/train_test_validation/train_test_feature_drift.py
+++ b/deepchecks/tabular/checks/train_test_validation/train_test_feature_drift.py
@@ -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.
 
@@ -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)
diff --git a/deepchecks/tabular/checks/train_test_validation/train_test_label_drift.py b/deepchecks/tabular/checks/train_test_validation/train_test_label_drift.py
--- a/deepchecks/tabular/checks/train_test_validation/train_test_label_drift.py
+++ b/deepchecks/tabular/checks/train_test_validation/train_test_label_drift.py
@@ -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.
 
@@ -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']
diff --git a/deepchecks/vision/checks/model_evaluation/train_test_prediction_drift.py b/deepchecks/vision/checks/model_evaluation/train_test_prediction_drift.py
--- a/deepchecks/vision/checks/model_evaluation/train_test_prediction_drift.py
+++ b/deepchecks/vision/checks/model_evaluation/train_test_prediction_drift.py
@@ -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.
@@ -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)
diff --git a/deepchecks/vision/checks/train_test_validation/train_test_label_drift.py b/deepchecks/vision/checks/train_test_validation/train_test_label_drift.py
--- a/deepchecks/vision/checks/train_test_validation/train_test_label_drift.py
+++ b/deepchecks/vision/checks/train_test_validation/train_test_label_drift.py
@@ -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.
@@ -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)