class_docstr: Unit test class for testing scikit-learn converter.
class_docstr_tok: ["Unit","test","class","for","testing","scikit-learn","converter","."]
code: def test_classifier_custom_class_name(self):
      from keras.layers import Dense
      from keras.layers import Activation
  
      # Create a simple Keras model
      model = Sequential()
      model.add(Dense(32, input_shape=(16,)))
      model.add(Activation("softmax"))
      classes = ["c%s" % i for i in range(32)]
  
      input_names = ["input"]
      output_names = ["prob_output"]
      expected_output_names = ["prob_output", "my_foo_bar_class_output"]
      spec = keras.convert(
          model,
          input_names,
          output_names,
          class_labels=classes,
          predicted_feature_name="my_foo_bar_class_output",
      ).get_spec()
      self.assertIsNotNone(spec)
  
      # Test the model class
      self.assertIsNotNone(spec.description)
      self.assertTrue(spec.HasField("neuralNetworkClassifier"))
      self.assertFalse(spec.HasField("neuralNetwork"))
  
      # Test the inputs and outputs
      self.assertEquals(len(spec.description.input), len(input_names))
      self.assertEqual(
          sorted(input_names),
          sorted(map(lambda x: x.name, spec.description.input)),
      )
      self.assertEquals(
          len(spec.description.output), len(expected_output_names)
      )
      self.assertEquals(
          expected_output_names,
          list(map(lambda x: x.name, spec.description.output)),
      )
  
      # Check the types
      self.assertEquals(
          spec.description.output[0].type.WhichOneof("Type"),
          "dictionaryType",
      )
      self.assertEquals(
          spec.description.output[0].type.dictionaryType.WhichOneof(
              "KeyType"
          ),
          "stringKeyType",
      )
      self.assertEquals(
          spec.description.output[1].type.WhichOneof("Type"),
          "stringType",
      )
      self.assertTrue(
          spec.description.predictedFeatureName,
          "my_foo_bar_class_output",
      )
      self.assertTrue(
          spec.description.predictedProbabilitiesName, "prob_output"
      )
  
      # Test the class parameters
      self.assertEqual(
          spec.WhichOneof("Type"),
          "neuralNetworkClassifier",
          "Expected a NN classifier model",
      )
      self.assertEqual(
          spec.neuralNetworkClassifier.WhichOneof("ClassLabels"),
          "stringClassLabels",
      )
      class_from_proto = list(
          spec.neuralNetworkClassifier.stringClassLabels.vector
      )
      self.assertEqual(sorted(classes), sorted(class_from_proto))
  
imports: import unittest
  from coremltools._deps import _HAS_KERAS2_TF
  from coremltools.proto import Model_pb2
  from coremltools.proto import FeatureTypes_pb2
  from coremltools.proto import NeuralNetwork_pb2
  import pytest
label_desc: Use image node_id 28 for calling the KerasSingleLayerTest obj's underlying member method code with example usage: obj.test_classifier_custom_class_name() without return types