class_docstr: This class defines the minimal interface to a CoreML object in Python.
  
  At a high level, the protobuf specification consists of:
  
  - Model description: Encodes names and type information of the inputs and outputs to the model.
  - Model parameters: The set of parameters required to represent a specific instance of the model.
  - Metadata: Information about the origin, license, and author of the model.
  
  With this class, you can inspect a CoreML model, modify metadata, and make
  predictions for the purposes of testing (on select platforms).
  
  Examples
  --------
  .. sourcecode:: python
  
      # Load the model
      model = MLModel("HousePricer.mlmodel")
  
      # Set the model metadata
      model.author = "Author"
      model.license = "BSD"
      model.short_description = "Predicts the price of a house in the Seattle area."
  
      # Get the interface to the model
      model.input_description
      model.output_description
  
      # Set feature descriptions manually
      model.input_description["bedroom"] = "Number of bedrooms"
      model.input_description["bathrooms"] = "Number of bathrooms"
      model.input_description["size"] = "Size (in square feet)"
  
      # Set
      model.output_description["price"] = "Price of the house"
  
      # Make predictions
      predictions = model.predict({"bedroom": 1.0, "bath": 1.0, "size": 1240})
  
      # Get the spec of the model
      spec = model.get_spec()
  
      # Save the model
      model.save("HousePricer.mlpackage")
  
      # Load the model from the spec object
      spec = model.get_spec()
      # modify spec (e.g. rename inputs/outputs etc)
      model = MLModel(spec)
      # if model type is mlprogram, i.e. spec.WhichOneof('Type') == "mlProgram", then:
      model = MLModel(spec, weights_dir=model.weights_dir)
  
  See Also
  --------
  predict
class_docstr_tok: ["This","class","defines","the","minimal","interface","to","a","CoreML","object","in","Python",".","At","a","high","level",",","the","protobuf","specification","consists","of",":","-","Model","description",":","Encodes","names","and","type","information","of","the","inputs","and","outputs","to","the","model",".","-","Model","parameters",":","The","set","of","parameters","required","to","represent","a","specific","instance","of","the","model",".","-","Metadata",":","Information","about","the","origin",",","license",",","and","author","of","the","model",".","With","this","class",",","you","can","inspect","a","CoreML","model",",","modify","metadata",",","and","make","predictions","for","the","purposes","of","testing","(","on","select","platforms",")",".","Examples","--","--","--","--","..","sourcecode",":",":","python","#","Load","the","model","model","=","MLModel","(","``","HousePricer.mlmodel","''",")","#","Set","the","model","metadata","model.author","=","``","Author","''","model.license","=","``","BSD","''","model.short_description","=","``","Predicts","the","price","of","a","house","in","the","Seattle","area",".","''","#","Get","the","interface","to","the","model","model.input_description","model.output_description","#","Set","feature","descriptions","manually","model.input_description","[","``","bedroom","''","]","=","``","Number","of","bedrooms","''","model.input_description","[","``","bathrooms","''","]","=","``","Number","of","bathrooms","''","model.input_description","[","``","size","''","]","=","``","Size","(","in","square","feet",")","''","#","Set","model.output_description","[","``","price","''","]","=","``","Price","of","the","house","''","#","Make","predictions","predictions","=","model.predict","(","{","``","bedroom","''",":","1.0",",","``","bath","''",":","1.0",",","``","size","''",":","1240","}",")","#","Get","the","spec","of","the","model","spec","=","model.get_spec","(",")","#","Save","the","model","model.save","(","``","HousePricer.mlpackage","''",")","#","Load","the","model","from","the","spec","object","spec","=","model.get_spec","(",")","#","modify","spec","(","e.g",".","rename","inputs\/outputs","etc",")","model","=","MLModel","(","spec",")","#","if","model","type","is","mlprogram",",","i.e",".","spec.WhichOneof","(","'Type","'",")","==","``","mlProgram","''",",","then",":","model","=","MLModel","(","spec",",","weights_dir=model.weights_dir",")","See","Also","--","--","--","--","predict"]
docstr: Return predictions for the model.
  
  Parameters
  ----------
  data: dict[str, value] or list[dict[str, value]]
      Dictionary of data to use for predictions, where the keys are the names of the input features.
      For batch predictons, use a list of such dictionaries.
  
      The following dictionary values types are acceptable: list, array, numpy.ndarray, tensorflow.Tensor
      and torch.Tensor.
  
  Returns
  -------
  dict[str, value]
      Predictions as a dictionary where each key is the output feature name.
  
  list[dict[str, value]]
      For batch prediction, returns a list of the above dictionaries.
  
  Examples
  --------
  .. sourcecode:: python
  
                  data = {'bedroom': 1.0, 'bath': 1.0, 'size': 1240}
                  predictions = model.predict(data)
  
                  data = [ {'bedroom': 1.0, 'bath': 1.0, 'size': 1240},
                                   {'bedroom': 4.0, 'bath': 2.5, 'size': 2400} ]
                  batch_predictions = model.predict(data)
docstr_tok: ["Return","predictions","for","the","model",".","Parameters","--","--","--","--","--","data",":","dict","[","str",",","value","]","or","list","[","dict","[","str",",","value","]","]","Dictionary","of","data","to","use","for","predictions",",","where","the","keys","are","the","names","of","the","input","features",".","For","batch","predictons",",","use","a","list","of","such","dictionaries",".","The","following","dictionary","values","types","are","acceptable",":","list",",","array",",","numpy.ndarray",",","tensorflow.Tensor","and","torch.Tensor",".","Returns","--","--","--","-","dict","[","str",",","value","]","Predictions","as","a","dictionary","where","each","key","is","the","output","feature","name",".","list","[","dict","[","str",",","value","]","]","For","batch","prediction",",","returns","a","list","of","the","above","dictionaries",".","Examples","--","--","--","--","..","sourcecode",":",":","python","data","=","{","'bedroom","'",":","1.0",",","'bath","'",":","1.0",",","'size","'",":","1240","}","predictions","=","model.predict","(","data",")","data","=","[","{","'bedroom","'",":","1.0",",","'bath","'",":","1.0",",","'size","'",":","1240","}",",","{","'bedroom","'",":","4.0",",","'bath","'",":","2.5",",","'size","'",":","2400","}","]","batch_predictions","=","model.predict","(","data",")"]
code: def predict(self, data):
      """
      Return predictions for the model.
  
      Parameters
      ----------
      data: dict[str, value] or list[dict[str, value]]
          Dictionary of data to use for predictions, where the keys are the names of the input features.
          For batch predictons, use a list of such dictionaries.
  
          The following dictionary values types are acceptable: list, array, numpy.ndarray, tensorflow.Tensor
          and torch.Tensor.
  
      Returns
      -------
      dict[str, value]
          Predictions as a dictionary where each key is the output feature name.
  
      list[dict[str, value]]
          For batch prediction, returns a list of the above dictionaries.
  
      Examples
      --------
      .. sourcecode:: python
  
                      data = {'bedroom': 1.0, 'bath': 1.0, 'size': 1240}
                      predictions = model.predict(data)
  
                      data = [ {'bedroom': 1.0, 'bath': 1.0, 'size': 1240},
                                       {'bedroom': 4.0, 'bath': 2.5, 'size': 2400} ]
                      batch_predictions = model.predict(data)
  
      """
  
      def verify_and_convert_input_dict(d):
          self._verify_input_dict(d)
          self._convert_tensor_to_numpy(d)
          # TODO: remove the following call when this is fixed: rdar://92239209
          self._update_float16_multiarray_input_to_float32(d)
  
      if self.is_package and _is_macos() and _macos_version() < (12, 0):
          raise Exception(
              "predict() for .mlpackage is not supported in macOS version older than 12.0."
          )
      MLModel._check_predict_data(data)
  
      if self.__proxy__:
          return MLModel._get_predictions(
              self.__proxy__, verify_and_convert_input_dict, data
          )
      else:  # Error case
          if _macos_version() < (10, 13):
              raise Exception(
                  "Model prediction is only supported on macOS version 10.13 or later."
              )
  
          try:
              from ..libcoremlpython import _MLModelProxy
          except Exception as e:
              print("Exception loading model proxy: %s\n" % e)
              _MLModelProxy = None
          except:
              print("Exception while loading model proxy.\n")
              _MLModelProxy = None
  
          if not _MLModelProxy:
              raise Exception(
                  "Unable to load CoreML.framework. Cannot make predictions."
              )
          elif (
              _MLModelProxy.maximum_supported_specification_version()
              < self._spec.specificationVersion
          ):
              engineVersion = (
                  _MLModelProxy.maximum_supported_specification_version()
              )
              raise Exception(
                  "The specification has version "
                  + str(self._spec.specificationVersion)
                  + " but the Core ML framework version installed only supports Core ML model specification version "
                  + str(engineVersion)
                  + " or older."
              )
          elif _has_custom_layer(self._spec):
              raise Exception(
                  "This model contains a custom neural network layer, so predict is not supported."
              )
          else:
              if self._framework_error:
                  raise self._framework_error
              else:
                  raise Exception(
                      "Unable to load CoreML.framework. Cannot make predictions."
                  )
  
imports: import atexit
  import os
  import shutil
  import tempfile
  import warnings
  from copy import deepcopy
  import numpy
  import numpy
  from coremltools import ComputeUnit
  from coremltools._deps import _HAS_TF_1, _HAS_TF_2, _HAS_TORCH
  from coremltools.converters.mil.mil.program import Program
  from ..proto import FeatureTypes_pb2
  from ..proto import MIL_pb2
  from ..proto import Model_pb2
  from .utils import _MLMODEL_EXTENSION, _MLPACKAGE_AUTHOR_NAME, _MLPACKAGE_EXTENSION, _MODEL_FILE_NAME, _WEIGHTS_DIR_NAME, _create_mlpackage, _has_custom_layer, _is_macos, _macos_version
  from .utils import load_spec
  from .utils import save_spec
label_desc: Use image node_id 19 for calling the MLModel obj's underlying member method code with example usage: obj.predict(data) and returns: MLModel