prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  [FEAT] add tests for more model types
  we should test any model with predict and predict_proba functions, including the common ones:
  
  Scikitlearn (also pipelines)
  CatBoost
  LGBM
  XGBoost
  Custom binary classification model that implements the predict_proba and predict functions
  Custom multiclass classification model that implements the predict_proba and predict functions
  Custom regression model that implements the predict function
  
  
  </issue>
  <code>
  [start of deepchecks/tabular/checks/performance/confusion_matrix_report.py]
  1 # ----------------------------------------------------------------------------
  2 # Copyright (C) 2021-2022 Deepchecks (https://www.deepchecks.com)
  3 #
  4 # This file is part of Deepchecks.
  5 # Deepchecks is distributed under the terms of the GNU Affero General
  6 # Public License (version 3 or later).
  7 # You should have received a copy of the GNU Affero General Public License
  8 # along with Deepchecks.  If not, see <http://www.gnu.org/licenses/>.
  9 # ----------------------------------------------------------------------------
  10 #
  11 """The confusion_matrix_report check module."""
  12 import pandas as pd
  13 import sklearn
  14 import plotly.express as px
  15 
  16 from deepchecks.core import CheckResult
  17 from deepchecks.tabular import Context, SingleDatasetCheck
  18 
  19 
  20 __all__ = ['ConfusionMatrixReport']
  21 
  22 
  23 class ConfusionMatrixReport(SingleDatasetCheck):
  24     """Calculate the confusion matrix of the model on the given dataset."""
  25 
  26     def run_logic(self, context: Context, dataset_type: str = 'train') -> CheckResult:
  27         """Run check.
  28 
  29         Returns
  30         -------
  31         CheckResult
  32             value is numpy array of the confusion matrix, displays the confusion matrix
  33 
  34         Raises
  35         ------
  36         DeepchecksValueError
  37             If the data is not a Dataset instance with a label
  38         """
  39         if dataset_type == 'train':
  40             dataset = context.train
  41         else:
  42             dataset = context.test
  43 
  44         context.assert_classification_task()
  45         ds_y = dataset.label_col
  46         ds_x = dataset.features_columns
  47         model = context.model
  48 
  49         y_pred = model.predict(ds_x)
  50         total_classes = sorted(list(set(pd.concat([ds_y, pd.Series(y_pred)]).to_list())))
  51         confusion_matrix = sklearn.metrics.confusion_matrix(ds_y, y_pred)
  52 
  53         # Figure
  54         fig = px.imshow(confusion_matrix, x=total_classes, y=total_classes, text_auto=True)
  55         fig.update_layout(width=600, height=600)
  56         fig.update_xaxes(title='Predicted Value', type='category')
  57         fig.update_yaxes(title='True value', type='category')
  58 
  59         return CheckResult(confusion_matrix, display=fig)
  60
  [end of deepchecks/tabular/checks/performance/confusion_matrix_report.py]
  [start of deepchecks/tabular/checks/overview/model_info.py]
  1 # ----------------------------------------------------------------------------
  2 # Copyright (C) 2021-2022 Deepchecks (https://www.deepchecks.com)
  3 #
  4 # This file is part of Deepchecks.
  5 # Deepchecks is distributed under the terms of the GNU Affero General
  6 # Public License (version 3 or later).
  7 # You should have received a copy of the GNU Affero General Public License
  8 # along with Deepchecks.  If not, see <http://www.gnu.org/licenses/>.
  9 # ----------------------------------------------------------------------------
  10 #
  11 """Module contains model_info check."""
  12 import warnings
  13 
  14 import pandas as pd
  15 
  16 from deepchecks.tabular import Context, ModelOnlyCheck
  17 from deepchecks.core import CheckResult
  18 from deepchecks.utils.model import get_model_of_pipeline
  19 
  20 
  21 __all__ = ['ModelInfo']
  22 
  23 
  24 class ModelInfo(ModelOnlyCheck):
  25     """Summarize given model parameters."""
  26 
  27     def run_logic(self, context: Context) -> CheckResult:
  28         """Run check.
  29 
  30         Returns
  31         -------
  32         CheckResult
  33             value is dictionary in format {type: <model_type>, params: <model_params_dict>}
  34         """
  35         model = context.model
  36         estimator = get_model_of_pipeline(model)
  37         model_type = type(estimator).__name__
  38         model_params = estimator.get_params()
  39         default_params = type(estimator)().get_params()
  40 
  41         # Create dataframe to show
  42         model_param_df = pd.DataFrame(model_params.items(), columns=['Parameter', 'Value'])
  43         model_param_df['Default'] = model_param_df['Parameter'].map(lambda x: default_params.get(x, ''))
  44 
  45         def highlight_not_default(data):
  46             n = len(data)
  47             if data['Value'] != data['Default']:
  48                 return n * ['background-color: lightblue']
  49             else:
  50                 return n * ['']
  51         with warnings.catch_warnings():
  52             warnings.simplefilter(action='ignore', category=FutureWarning)
  53             model_param_df = model_param_df.style.apply(highlight_not_default, axis=1).hide_index()
  54 
  55         value = {'type': model_type, 'params': model_params}
  56         footnote = '<p style="font-size:0.7em"><i>Colored rows are parameters with non-default values</i></p>'
  57         display = [f'Model Type: {model_type}', model_param_df, footnote]
  58 
  59         return CheckResult(value, header='Model Info', display=display)
  60
  [end of deepchecks/tabular/checks/overview/model_info.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/deepchecks/tabular/checks/overview/model_info.py b/deepchecks/tabular/checks/overview/model_info.py
  --- a/deepchecks/tabular/checks/overview/model_info.py
  +++ b/deepchecks/tabular/checks/overview/model_info.py
  @@ -35,8 +35,12 @@
           model = context.model
           estimator = get_model_of_pipeline(model)
           model_type = type(estimator).__name__
  -        model_params = estimator.get_params()
  -        default_params = type(estimator)().get_params()
  +        try:
  +            model_params = estimator.get_params()
  +            default_params = type(estimator)().get_params()
  +        except AttributeError:
  +            model_params = {}
  +            default_params = {}
   
           # Create dataframe to show
           model_param_df = pd.DataFrame(model_params.items(), columns=['Parameter', 'Value'])
  diff --git a/deepchecks/tabular/checks/performance/confusion_matrix_report.py b/deepchecks/tabular/checks/performance/confusion_matrix_report.py
  --- a/deepchecks/tabular/checks/performance/confusion_matrix_report.py
  +++ b/deepchecks/tabular/checks/performance/confusion_matrix_report.py
  @@ -9,6 +9,7 @@
   # ----------------------------------------------------------------------------
   #
   """The confusion_matrix_report check module."""
  +import numpy as np
   import pandas as pd
   import sklearn
   import plotly.express as px
  @@ -46,7 +47,7 @@
           ds_x = dataset.features_columns
           model = context.model
   
  -        y_pred = model.predict(ds_x)
  +        y_pred = np.array(model.predict(ds_x)).reshape(len(ds_y), )
           total_classes = sorted(list(set(pd.concat([ds_y, pd.Series(y_pred)]).to_list())))
           confusion_matrix = sklearn.metrics.confusion_matrix(ds_y, y_pred)
  
verification_info: {"golden_diff": "diff --git a/deepchecks/tabular/checks/overview/model_info.py b/deepchecks/tabular/checks/overview/model_info.py\n--- a/deepchecks/tabular/checks/overview/model_info.py\n+++ b/deepchecks/tabular/checks/overview/model_info.py\n@@ -35,8 +35,12 @@\n         model = context.model\n         estimator = get_model_of_pipeline(model)\n         model_type = type(estimator).__name__\n-        model_params = estimator.get_params()\n-        default_params = type(estimator)().get_params()\n+        try:\n+            model_params = estimator.get_params()\n+            default_params = type(estimator)().get_params()\n+        except AttributeError:\n+            model_params = {}\n+            default_params = {}\n \n         # Create dataframe to show\n         model_param_df = pd.DataFrame(model_params.items(), columns=['Parameter', 'Value'])\ndiff --git a/deepchecks/tabular/checks/performance/confusion_matrix_report.py b/deepchecks/tabular/checks/performance/confusion_matrix_report.py\n--- a/deepchecks/tabular/checks/performance/confusion_matrix_report.py\n+++ b/deepchecks/tabular/checks/performance/confusion_matrix_report.py\n@@ -9,6 +9,7 @@\n # ----------------------------------------------------------------------------\n #\n \"\"\"The confusion_matrix_report check module.\"\"\"\n+import numpy as np\n import pandas as pd\n import sklearn\n import plotly.express as px\n@@ -46,7 +47,7 @@\n         ds_x = dataset.features_columns\n         model = context.model\n \n-        y_pred = model.predict(ds_x)\n+        y_pred = np.array(model.predict(ds_x)).reshape(len(ds_y), )\n         total_classes = sorted(list(set(pd.concat([ds_y, pd.Series(y_pred)]).to_list())))\n         confusion_matrix = sklearn.metrics.confusion_matrix(ds_y, y_pred)\n", "issue": "[FEAT] add tests for more model types\nwe should test any model with predict and predict_proba functions, including the common ones:\r\n\r\nScikitlearn (also pipelines)\r\nCatBoost\r\nLGBM\r\nXGBoost\r\nCustom binary classification model that implements the predict_proba and predict functions\r\nCustom multiclass classification model that implements the predict_proba and predict functions\r\nCustom regression model that implements the predict function\r\n\n", "before_files": [{"content": "# ----------------------------------------------------------------------------\n# Copyright (C) 2021-2022 Deepchecks (https://www.deepchecks.com)\n#\n# This file is part of Deepchecks.\n# Deepchecks is distributed under the terms of the GNU Affero General\n# Public License (version 3 or later).\n# You should have received a copy of the GNU Affero General Public License\n# along with Deepchecks.  If not, see <http://www.gnu.org/licenses/>.\n# ----------------------------------------------------------------------------\n#\n\"\"\"The confusion_matrix_report check module.\"\"\"\nimport pandas as pd\nimport sklearn\nimport plotly.express as px\n\nfrom deepchecks.core import CheckResult\nfrom deepchecks.tabular import Context, SingleDatasetCheck\n\n\n__all__ = ['ConfusionMatrixReport']\n\n\nclass ConfusionMatrixReport(SingleDatasetCheck):\n    \"\"\"Calculate the confusion matrix of the model on the given dataset.\"\"\"\n\n    def run_logic(self, context: Context, dataset_type: str = 'train') -> CheckResult:\n        \"\"\"Run check.\n\n        Returns\n        -------\n        CheckResult\n            value is numpy array of the confusion matrix, displays the confusion matrix\n\n        Raises\n        ------\n        DeepchecksValueError\n            If the data is not a Dataset instance with a label\n        \"\"\"\n        if dataset_type == 'train':\n            dataset = context.train\n        else:\n            dataset = context.test\n\n        context.assert_classification_task()\n        ds_y = dataset.label_col\n        ds_x = dataset.features_columns\n        model = context.model\n\n        y_pred = model.predict(ds_x)\n        total_classes = sorted(list(set(pd.concat([ds_y, pd.Series(y_pred)]).to_list())))\n        confusion_matrix = sklearn.metrics.confusion_matrix(ds_y, y_pred)\n\n        # Figure\n        fig = px.imshow(confusion_matrix, x=total_classes, y=total_classes, text_auto=True)\n        fig.update_layout(width=600, height=600)\n        fig.update_xaxes(title='Predicted Value', type='category')\n        fig.update_yaxes(title='True value', type='category')\n\n        return CheckResult(confusion_matrix, display=fig)\n", "path": "deepchecks/tabular/checks/performance/confusion_matrix_report.py"}, {"content": "# ----------------------------------------------------------------------------\n# Copyright (C) 2021-2022 Deepchecks (https://www.deepchecks.com)\n#\n# This file is part of Deepchecks.\n# Deepchecks is distributed under the terms of the GNU Affero General\n# Public License (version 3 or later).\n# You should have received a copy of the GNU Affero General Public License\n# along with Deepchecks.  If not, see <http://www.gnu.org/licenses/>.\n# ----------------------------------------------------------------------------\n#\n\"\"\"Module contains model_info check.\"\"\"\nimport warnings\n\nimport pandas as pd\n\nfrom deepchecks.tabular import Context, ModelOnlyCheck\nfrom deepchecks.core import CheckResult\nfrom deepchecks.utils.model import get_model_of_pipeline\n\n\n__all__ = ['ModelInfo']\n\n\nclass ModelInfo(ModelOnlyCheck):\n    \"\"\"Summarize given model parameters.\"\"\"\n\n    def run_logic(self, context: Context) -> CheckResult:\n        \"\"\"Run check.\n\n        Returns\n        -------\n        CheckResult\n            value is dictionary in format {type: <model_type>, params: <model_params_dict>}\n        \"\"\"\n        model = context.model\n        estimator = get_model_of_pipeline(model)\n        model_type = type(estimator).__name__\n        model_params = estimator.get_params()\n        default_params = type(estimator)().get_params()\n\n        # Create dataframe to show\n        model_param_df = pd.DataFrame(model_params.items(), columns=['Parameter', 'Value'])\n        model_param_df['Default'] = model_param_df['Parameter'].map(lambda x: default_params.get(x, ''))\n\n        def highlight_not_default(data):\n            n = len(data)\n            if data['Value'] != data['Default']:\n                return n * ['background-color: lightblue']\n            else:\n                return n * ['']\n        with warnings.catch_warnings():\n            warnings.simplefilter(action='ignore', category=FutureWarning)\n            model_param_df = model_param_df.style.apply(highlight_not_default, axis=1).hide_index()\n\n        value = {'type': model_type, 'params': model_params}\n        footnote = '<p style=\"font-size:0.7em\"><i>Colored rows are parameters with non-default values</i></p>'\n        display = [f'Model Type: {model_type}', model_param_df, footnote]\n\n        return CheckResult(value, header='Model Info', display=display)\n", "path": "deepchecks/tabular/checks/overview/model_info.py"}]}