code: def test_bogus_input_prob_evaluators(self):
      # Arrange (mismatch number of classes)
      t, _ = _generate_classes_and_scores(
          3, n=100, hard_predictions=False
      )
      _, p = _generate_classes_and_scores(
          4, n=100, hard_predictions=False
      )
      targets = turicreate.SArray(list(t))
      predictions = turicreate.SArray(list(p))
      float_predictions = predictions.apply(lambda x: x[0])
  
      with self.assertRaises(ToolkitError):
          score = turicreate.toolkits.evaluation.auc(
              targets, predictions
          )
      with self.assertRaises(ToolkitError):
          score = turicreate.toolkits.evaluation.roc_curve(
              targets, predictions
          )
      with self.assertRaises(ToolkitError):
          score = turicreate.toolkits.evaluation.log_loss(
              targets, predictions
          )
  
      with self.assertRaises(ToolkitError):
          score = turicreate.toolkits.evaluation.auc(
              targets, float_predictions
          )
      with self.assertRaises(ToolkitError):
          score = turicreate.toolkits.evaluation.roc_curve(
              targets, float_predictions
          )
      with self.assertRaises(ToolkitError):
          score = turicreate.toolkits.evaluation.log_loss(
              targets, float_predictions
          )
  
      bad_range_targets = turicreate.SArray([0, 1, 0, 1])
      bad_range_predictions = turicreate.SArray([1, 2, 3, 4])
      with self.assertRaises(ToolkitError):
          score = turicreate.toolkits.evaluation.log_loss(
              bad_range_targets, bad_range_predictions
          )
  
      with self.assertRaises(ToolkitError):
          score = turicreate.toolkits.evaluation.roc_curve(
              bad_range_targets, bad_range_predictions
          )
  
      with self.assertRaises(ToolkitError):
          score = turicreate.toolkits.evaluation.auc(
              bad_range_targets, bad_range_predictions
          )
  
      bad_range_targets = turicreate.SArray([0, 1, 0, 1])
      bad_range_predictions = turicreate.SArray(
          [[1.0, 2.0], [2.0, 3.0], [3.0, 4.0], [4.0, 5.0]]
      )
      with self.assertRaises(ToolkitError):
          score = turicreate.toolkits.evaluation.log_loss(
              bad_range_targets, bad_range_predictions
          )
  
      with self.assertRaises(ToolkitError):
          score = turicreate.toolkits.evaluation.roc_curve(
              bad_range_targets, bad_range_predictions
          )
  
      with self.assertRaises(ToolkitError):
          score = turicreate.toolkits.evaluation.auc(
              bad_range_targets, bad_range_predictions
          )
  
      targets = turicreate.SArray([0, 1, 2, 0])
      predictions = turicreate.SArray(
          [
              [0.9, 0.0, 0.1, 0.0],
              [0.8, 0.1, 0.1, 0.0],
              [0.1, 0.1, 0.8, 0.0],
              [0.1, 0.1, 0.8, 0.0],
          ]
      )
      good_index_map = {i: i for i in range(4)}
      incomplete_index_map = {i: i for i in range(3)}
      invalid_range_index_map = {0: 1, 1: 2, 2: 3, 3: 4}
      non_injective_index_map = {0: 0, 1: 0, 2: 2, 3: 3}
  
      # No exception with a correct index map
      score = turicreate.toolkits.evaluation.auc(
          targets, predictions, index_map=good_index_map
      )
      score = turicreate.toolkits.evaluation.roc_curve(
          targets, predictions, index_map=good_index_map
      )
      score = turicreate.toolkits.evaluation.log_loss(
          targets, predictions, index_map=good_index_map
      )
  
      # Exception if index_map size does not match prediction vector size
      with self.assertRaises(ToolkitError):
          score = turicreate.toolkits.evaluation.auc(
              targets, predictions, index_map=incomplete_index_map
          )
      with self.assertRaises(ToolkitError):
          score = turicreate.toolkits.evaluation.roc_curve(
              targets, predictions, index_map=incomplete_index_map
          )
      with self.assertRaises(ToolkitError):
          score = turicreate.toolkits.evaluation.log_loss(
              targets, predictions, index_map=incomplete_index_map
          )
  
      # Exception if index_map values do not span prediction vector indices
      with self.assertRaises(ToolkitError):
          score = turicreate.toolkits.evaluation.auc(
              targets, predictions, index_map=invalid_range_index_map
          )
      with self.assertRaises(ToolkitError):
          score = turicreate.toolkits.evaluation.roc_curve(
              targets, predictions, index_map=invalid_range_index_map
          )
      with self.assertRaises(ToolkitError):
          score = turicreate.toolkits.evaluation.log_loss(
              targets, predictions, index_map=invalid_range_index_map
          )
  
      # Exception if index_map uses the same index for two labels
      with self.assertRaises(ToolkitError):
          score = turicreate.toolkits.evaluation.auc(
              targets, predictions, index_map=non_injective_index_map
          )
      with self.assertRaises(ToolkitError):
          score = turicreate.toolkits.evaluation.roc_curve(
              targets, predictions, index_map=non_injective_index_map
          )
      with self.assertRaises(ToolkitError):
          score = turicreate.toolkits.evaluation.log_loss(
              targets, predictions, index_map=non_injective_index_map
          )
  
imports: from __future__ import print_function
  from __future__ import division
  from __future__ import absolute_import
  import unittest
  import turicreate
  from turicreate.toolkits._main import ToolkitError
  import math
  from numpy import inf
  import numpy
label_desc: Use image node_id 27 for calling the MetricsTest obj's underlying member method code with example usage: obj.test_bogus_input_prob_evaluators() without return types