def test_conversion_bad_inputs(self):
        # Error on converting an untrained model
        with self.assertRaises(Exception):
            model = DecisionTreeClassifier()
            spec = skl_converter(model, "data", "out")

        # Check the expected class during covnersion.
        from sklearn.preprocessing import OneHotEncoder

        with self.assertRaises(Exception):
            model = OneHotEncoder()
            spec = skl_converter(model, "data", "out")
    def test_conversion(self):
        output_name = "target"
        spec = skl_converter(self.scikit_model, "data", "target").get_spec()
        self.assertIsNotNone(spec)

        # Test the model class
        self.assertIsNotNone(spec.description)
        self.assertIsNotNone(spec.treeEnsembleClassifier)

        # Test the interface class
        self.assertEqual(spec.description.predictedFeatureName, "target")

        # Test the inputs and outputs
        self.assertEqual(len(spec.description.output), 2)
        self.assertEqual(spec.description.output[0].name, "target")
        self.assertEqual(spec.description.output[0].type.WhichOneof("Type"),
                         "int64Type")
        self.assertEqual(len(spec.description.input), 1)

        input_type = spec.description.input[0]

        self.assertEqual(input_type.type.WhichOneof("Type"), "multiArrayType")
        self.assertEqual(input_type.name, "data")

        # Test the linear regression parameters.
        tr = spec.treeEnsembleClassifier.treeEnsemble
        self.assertIsNotNone(tr)
        self.assertEqual(len(tr.nodes), 111)
    def test_conversion(self):

        output_name = 'target'
        spec = skl_converter(self.scikit_model, 'data', 'target').get_spec()
        self.assertIsNotNone(spec)

        # Test the model class
        self.assertIsNotNone(spec.description)
        self.assertIsNotNone(spec.treeEnsembleClassifier)

        # Test the interface class
        self.assertEqual(spec.description.predictedFeatureName, 'target')

        # Test the inputs and outputs
        self.assertEqual(len(spec.description.output), 2)
        self.assertEqual(spec.description.output[0].name, 'target')
        self.assertEqual(spec.description.output[0].type.WhichOneof('Type'),
                         'int64Type')
        self.assertEqual(spec.description.input[0].name, 'data')
        self.assertEqual(spec.description.input[0].type.WhichOneof('Type'),
                         'multiArrayType')

        tr = spec.treeEnsembleClassifier.treeEnsemble
        self.assertIsNotNone(tr)
        self.assertEqual(len(tr.nodes), 315)