Beispiel #1
0
    def test_builder_with_validation(self):
        builder = KNearestNeighborsClassifierBuilder(
            input_name='input',
            output_name='output',
            number_of_dimensions=10,
            default_class_label='defaultLabel',
            k=3,
            weighting_scheme='inverse_distance',
            index_type='kd_tree',
            leaf_size=50)
        builder.author = 'CoreML Team'
        builder.license = 'MIT'
        builder.description = 'test_builder_with_validation'

        # Save the updated spec
        coreml_model = MLModel(builder.spec)
        coreml_model_path = '/tmp/__test_builder_with_validation.mlmodel'
        coreml_model.save(coreml_model_path)
        self.assertTrue(os.path.isfile(coreml_model_path))

        try:
            stdout, stderr, return_code = self._compile_mlmodel(
                coreml_model_path)
            self.assertEqual(return_code, 0)
        finally:
            self._delete_mlmodel_and_mlmodelc(coreml_model_path)
Beispiel #2
0
    def test_can_init_and_save_model_from_builder_with_updated_spec(self):
        builder = KNearestNeighborsClassifierBuilder(
            input_name="input",
            output_name="output",
            number_of_dimensions=10,
            default_class_label="defaultLabel",
            k=3,
            weighting_scheme="inverse_distance",
            index_type="kd_tree",
            leaf_size=50,
        )
        builder.author = "CoreML Team"
        builder.license = "MIT"
        builder.description = "test_builder_with_validation"

        # Save the updated spec
        coreml_model = MLModel(builder.spec)
        self.assertIsNotNone(coreml_model)
        coreml_model_path = "/tmp/__test_builder_with_validation.mlmodel"

        try:
            coreml_model.save(coreml_model_path)
            self.assertTrue(os.path.isfile(coreml_model_path))
        finally:
            self._delete_mlmodel_and_mlmodelc(coreml_model_path)