Repository: deepchecks/deepchecks

Issue:
[BUG] [CV] bug in kaggle because of sklearn version
**Describe the bug**
sklearn OrdinalEncoder has a parameter that was added in 0.24 and isn't in the kaggle version (handle_unknown)

**To Reproduce**
Steps to reproduce the behavior:
run drift checks on kaggle

**Expected behavior**
add this variable only if available
 
**Screenshots**
![Screen Shot 2022-03-30 at 16 28 29](https://user-images.githubusercontent.com/26321553/160863371-26c9bd70-205f-4333-98e0-29d53abb30f1.png)



Discussion:

Resolving patch:
diff --git a/deepchecks/core/check_utils/whole_dataset_drift_utils.py b/deepchecks/core/check_utils/whole_dataset_drift_utils.py
--- a/deepchecks/core/check_utils/whole_dataset_drift_utils.py
+++ b/deepchecks/core/check_utils/whole_dataset_drift_utils.py
@@ -16,12 +16,6 @@
 import numpy as np
 import pandas as pd
 
-from deepchecks.tabular import Dataset
-from deepchecks.utils.distribution.plot import feature_distribution_traces, drift_score_bar_traces
-from deepchecks.utils.features import N_TOP_MESSAGE, calculate_feature_importance_or_none
-from deepchecks.utils.strings import format_percent
-from deepchecks.utils.typing import Hashable
-
 from sklearn.pipeline import Pipeline
 from sklearn.compose import ColumnTransformer
 
@@ -35,6 +29,13 @@
 from sklearn.model_selection import train_test_split
 import plotly.graph_objects as go
 
+from deepchecks.tabular import Dataset
+from deepchecks.utils.distribution.plot import feature_distribution_traces, drift_score_bar_traces
+from deepchecks.utils.features import N_TOP_MESSAGE, calculate_feature_importance_or_none
+from deepchecks.utils.function import run_available_kwargs
+from deepchecks.utils.strings import format_percent
+from deepchecks.utils.typing import Hashable
+
 
 def run_whole_dataset_drift(train_dataframe: pd.DataFrame, test_dataframe: pd.DataFrame,
                             numerical_features: List[Hashable], cat_features: List[Hashable], sample_size: int,
@@ -113,8 +114,9 @@ def generate_model(numerical_columns: List[Hashable], categorical_columns: List[
                    random_state: int = 42) -> Pipeline:
     """Generate the unfitted Domain Classifier model."""
     categorical_transformer = Pipeline(
-        steps=[('encoder', OrdinalEncoder(handle_unknown='use_encoded_value', unknown_value=np.nan,
-                                          dtype=np.float64))]
+        steps=[('encoder', run_available_kwargs(OrdinalEncoder, handle_unknown='use_encoded_value',
+                                                unknown_value=np.nan,
+                                                dtype=np.float64))]
     )
 
     preprocessor = ColumnTransformer(
diff --git a/deepchecks/tabular/checks/methodology/unused_features.py b/deepchecks/tabular/checks/methodology/unused_features.py
--- a/deepchecks/tabular/checks/methodology/unused_features.py
+++ b/deepchecks/tabular/checks/methodology/unused_features.py
@@ -23,6 +23,7 @@
 
 from deepchecks.core import CheckResult, ConditionResult, ConditionCategory
 from deepchecks.tabular import Context, TrainTestCheck, Dataset
+from deepchecks.utils.function import run_available_kwargs
 from deepchecks.utils.typing import BasicModel
 
 
@@ -264,7 +265,7 @@ def naive_encoder(dataset: Dataset) -> Tuple[TransformerMixin, list]:
             ('cat',
              Pipeline([
                  ('nan_handling', SimpleImputer(strategy='most_frequent')),
-                 ('encode', OrdinalEncoder(handle_unknown='use_encoded_value', unknown_value=-1)),
+                 ('encode', run_available_kwargs(OrdinalEncoder, handle_unknown='use_encoded_value', unknown_value=-1)),
                  ('norm', RobustScaler())
              ]),
              dataset.cat_features)
diff --git a/deepchecks/utils/function.py b/deepchecks/utils/function.py
new file mode 100644
--- /dev/null
+++ b/deepchecks/utils/function.py
@@ -0,0 +1,26 @@
+# ----------------------------------------------------------------------------
+# Copyright (C) 2021-2022 Deepchecks (https://www.deepchecks.com)
+#
+# This file is part of Deepchecks.
+# Deepchecks is distributed under the terms of the GNU Affero General
+# Public License (version 3 or later).
+# You should have received a copy of the GNU Affero General Public License
+# along with Deepchecks.  If not, see <http://www.gnu.org/licenses/>.
+# ----------------------------------------------------------------------------
+#
+"""Contain functions for handling function in checks."""
+from inspect import signature
+from typing import Callable
+
+
+__all__ = ['run_available_kwargs']
+
+
+def run_available_kwargs(func: Callable, **kwargs):
+    """Run the passed object only with available kwargs."""
+    avail_kwargs = list(signature(func).parameters.keys())
+    pass_kwargs = {}
+    for kwarg_name in avail_kwargs:
+        if kwarg_name in kwargs:
+            pass_kwargs[kwarg_name] = kwargs[kwarg_name]
+    return func(**pass_kwargs)


Test patch:
diff --git a/tests/utils/test_functions.py b/tests/utils/test_functions.py
new file mode 100644
--- /dev/null
+++ b/tests/utils/test_functions.py
@@ -0,0 +1,24 @@
+# ----------------------------------------------------------------------------
+# Copyright (C) 2021-2022 Deepchecks (https://www.deepchecks.com)
+#
+# This file is part of Deepchecks.
+# Deepchecks is distributed under the terms of the GNU Affero General
+# Public License (version 3 or later).
+# You should have received a copy of the GNU Affero General Public License
+# along with Deepchecks.  If not, see <http://www.gnu.org/licenses/>.
+# ----------------------------------------------------------------------------
+#
+from hamcrest import assert_that, equal_to
+
+from deepchecks.utils.function import run_available_kwargs
+
+
+def test_not_error():
+    def aaa(a, b, c, f=10, m=5):
+        if m is None:
+            return 99
+        return a + b + c + f
+    assert_that(run_available_kwargs(aaa, a=2, b=3, c=5, d=10), equal_to(20))
+    assert_that(run_available_kwargs(aaa, a=1, b=1, c=5, f=0), equal_to(7))
+    assert_that(run_available_kwargs(aaa, a=4, b=0, c=3, f=1), equal_to(8))
+    assert_that(run_available_kwargs(aaa, a=4, b=0, c=3, f=1, m=None), equal_to(99))