code: def evaluate_transformer(model, input_data, reference_output,
                           verbose=False):
      
      model = _get_model(model)
      if verbose:
          print(model)
          print("")
          print("Other Framework\t\tPredicted")
  
      num_errors = 0
      for index, row in enumerate(input_data):
          assert isinstance(row, dict)
          sanitized_row = _sanitize_value(row)
          ref_data = _sanitize_value(reference_output[index])
          if verbose:
              print("Input:\n\t", str(row))
              print("Correct output:\n\t", str(ref_data))
  
          predicted = _sanitize_value(model.predict(sanitized_row))
  
          assert isinstance(ref_data, dict)
          assert isinstance(predicted, dict)
  
          predicted_trimmed = dict( (k, predicted[k]) for k in ref_data.keys())
  
          if verbose:
              print("Predicted:\n\t", str(predicted_trimmed))
  
          if not _element_equal(predicted_trimmed, ref_data):
              num_errors += 1
  
      ret = {
          "num_samples": len(input_data),
          "num_errors": num_errors
      }
  
      if verbose:
          print("results: %s" % ret)
      return ret
docs: Evaluate a transformer specification for testing.
  
      Parameters
      ----------
      spec: [str | MLModel]
          File from where to load the Model from (OR) a loaded
          version of MLModel.
  
      input_data: list[dict]
          Test data on which to evaluate the models.
  
      reference_output: list[dict]
          Expected results for the model.
  
      verbose: bool
          Verbosity levels of the predictions.
  
      Examples
      --------
      .. sourcecode:: python
  
          >>> input_data = [{'input_1': 1, 'input_2': 2}, {'input_1': 3, 'input_2': 3}]
          >>> expected_output = [{'input_1': 2.5, 'input_2': 2.0}, {'input_1': 1.3, 'input_2': 2.3}]
          >>> metrics = coremltools.utils.evaluate_transformer(scaler_spec, input_data, expected_output)
  
      See Also
      --------
      evaluate_regressor, evaluate_classifier