code: def test_condition_misclassified_samples_lower_than_fails(
      iris_split_dataset_and_model,
  ):
      # Arrange
      _, test, clf = iris_split_dataset_and_model
  
      threshold = 0.05
      thresh_samples = round(np.ceil(threshold * len(test)))
  
      # Act
      check = ConfusionMatrixReport().add_condition_misclassified_samples_lower_than_condition(
          misclassified_samples_threshold=threshold
      )
  
      result = check.run(test, clf)
  
      class_names = result.value.columns
      confusion_matrix = result.value.to_numpy()
      m, n = confusion_matrix.shape[0], confusion_matrix.shape[1]
  
      n_cells_above_thresh = 0
      max_misclassified_cell_idx = (0, 1)
  
      # Looping over the confusion matrix and checking only the misclassified cells
      for i in range(m):
          for j in range(n):
              # omitting the principal axis of the confusion matrix
              if i != j:
                  n_samples = confusion_matrix[i][j]
  
                  if n_samples > thresh_samples:
                      n_cells_above_thresh += 1
  
                      x, y = max_misclassified_cell_idx
                      max_misclassified_samples = confusion_matrix[x][y]
                      if n_samples > max_misclassified_samples:
                          max_misclassified_cell_idx = (i, j)
  
      # Assert
      x, y = max_misclassified_cell_idx
      max_misclassified_samples = confusion_matrix[x][y]
      max_misclassified_samples_ratio = max_misclassified_samples / len(
          test
      )
  
      assert_that(
          result.conditions_results[0],
          equal_condition_result(
              is_pass=False,
              name=f"Misclassified cell size lower than {format_percent(threshold)} of the total samples",
              details=f"Detected {n_cells_above_thresh} misclassified confusion matrix cell(s) each one "
              f"containing more than {format_percent(threshold)} of the data. "
              f"Largest misclassified cell ({format_percent(max_misclassified_samples_ratio)} of the data) "
              f'is samples with a true value of "{class_names[x]}" and a predicted value of "{class_names[y]}".',
          ),
      )
  
file_path: deepchecks/tests/tabular/checks/model_evaluation/confusion_matrix_report_test.py
imports: import numpy
  from hamcrest import assert_that, calling, equal_to, greater_than, has_length, raises
  from deepchecks.core.condition import ConditionCategory
  from deepchecks.core.errors import DeepchecksNotSupportedError, DeepchecksValueError, ModelValidationError
  from deepchecks.tabular.checks.model_evaluation import ConfusionMatrixReport
  from deepchecks.utils.strings import format_number, format_percent
  from tests.base.utils import equal_condition_result
label_desc: Use image node_id 9 for calling a global function with example usage: test_condition_misclassified_samples_lower_than_fails(iris_split_dataset_and_model) without return types