Repository: deepchecks/deepchecks

Issue:
[BUG] NaNs break gaussian_kde in output of Drift checks


Train Test Feature Drift | ValueError: array must not contain infs or NaNs
-- | --





Discussion:

Resolving patch:
diff --git a/deepchecks/checks/distribution/plot.py b/deepchecks/checks/distribution/plot.py
--- a/deepchecks/checks/distribution/plot.py
+++ b/deepchecks/checks/distribution/plot.py
@@ -117,11 +117,8 @@ def feature_distribution_traces(train_column,
         Dicst: layout of y axis
     """
     if is_categorical:
-        train_dist = train_column
-        test_dist = test_column
-
         expected_percents, actual_percents, categories_list = \
-            preprocess_for_psi(dist1=train_dist, dist2=test_dist, max_num_categories=max_num_categories)
+            preprocess_for_psi(dist1=train_column, dist2=test_column, max_num_categories=max_num_categories)
         cat_df = pd.DataFrame({'Train dataset': expected_percents, 'Test dataset': actual_percents},
                               index=categories_list)
         train_bar = go.Bar(
diff --git a/deepchecks/checks/distribution/whole_dataset_drift.py b/deepchecks/checks/distribution/whole_dataset_drift.py
--- a/deepchecks/checks/distribution/whole_dataset_drift.py
+++ b/deepchecks/checks/distribution/whole_dataset_drift.py
@@ -219,8 +219,8 @@ def _display_dist(self, train_column: pd.Series, test_column: pd.Series, fi_ser:
 
         title = f'Feature: {column_name} - Explains {format_percent(fi_ser.loc[column_name])} of dataset difference'
         traces, xaxis_layout, yaxis_layout = \
-            feature_distribution_traces(train_column,
-                                        test_column,
+            feature_distribution_traces(train_column.dropna(),
+                                        test_column.dropna(),
                                         is_categorical=column_name in self._cat_features,
                                         max_num_categories=self.max_num_categories)
 


Test patch:
diff --git a/deepchecks/checks/distribution/train_test_feature_drift.py b/deepchecks/checks/distribution/train_test_feature_drift.py
--- a/deepchecks/checks/distribution/train_test_feature_drift.py
+++ b/deepchecks/checks/distribution/train_test_feature_drift.py
@@ -193,7 +193,7 @@ def _calc_drift_per_column(self, train_column: pd.Series, test_column: pd.Series
 
             score_bar = drift_score_bar_traces(score)
 
-            traces, xaxis_layout, yaxis_layout = feature_distribution_traces(train_column,
+            traces, xaxis_layout, yaxis_layout = feature_distribution_traces(train_dist,
                                                                              test_dist)
 
         elif column_type == 'categorical':
diff --git a/deepchecks/checks/distribution/train_test_label_drift.py b/deepchecks/checks/distribution/train_test_label_drift.py
--- a/deepchecks/checks/distribution/train_test_label_drift.py
+++ b/deepchecks/checks/distribution/train_test_label_drift.py
@@ -142,7 +142,7 @@ def _calc_drift_per_column(self, train_column: pd.Series, test_column: pd.Series
 
             score_bar = drift_score_bar_traces(score)
 
-            traces, xaxis_layout, yaxis_layout = feature_distribution_traces(train_column,
+            traces, xaxis_layout, yaxis_layout = feature_distribution_traces(train_dist,
                                                                              test_dist)
 
         elif column_type == 'categorical':