code: def _extract_training_data(model, spec):
      """Extract the training data from the scikit model and add it to the CoreML spec"""
  
      if _is_algorithm_brute(model):
          X = model._fit_X
          if _is_valid_sparse_format(X):
              X = _unpack_sparse(X)
  
          for sample in X:
              coreml_sample = (
                  spec.kNearestNeighborsClassifier.nearestNeighborsIndex.floatSamples.add()
              )
              for feature in sample:
                  coreml_sample.vector.append(feature)
  
      elif _is_algorithm_kd_tree(model):
          # sklearn guarantees that tree data is not stored in a sparse format
          npdata = np.asarray(model._tree.data)
          for sample in npdata:
              coreml_sample = (
                  spec.kNearestNeighborsClassifier.nearestNeighborsIndex.floatSamples.add()
              )
              for feature in sample:
                  coreml_sample.vector.append(feature)
  
      for label in model._y:
          spec.kNearestNeighborsClassifier.int64ClassLabels.vector.append(
              label
          )
  
imports: from ..._deps import _HAS_SKLEARN
  from ...models import MLModel
  import coremltools
  from coremltools.proto import FeatureTypes_pb2
  import numpy
  import scipy
  import six
label_desc: Use image node_id 6 for calling a global function with example usage: _extract_training_data(model, spec) without return types