class_docstr: Unit tests for the nearest neighbors builder class.
docstr: Validate the float samples returned from the converted scikit KNeighborsClassifier
docstr_tok: ["Validate","the","float","samples","returned","from","the","converted","scikit","KNeighborsClassifier"]
code: def _validate_samples(self, spec, expected_X, expected_y):
      """Validate the float samples returned from the converted scikit KNeighborsClassifier"""
      num_dimensions = (
          spec.kNearestNeighborsClassifier.nearestNeighborsIndex.numberOfDimensions
      )
      for index, sample in enumerate(
          spec.kNearestNeighborsClassifier.nearestNeighborsIndex.floatSamples
      ):
          for dim in range(0, num_dimensions):
              self.assertAlmostEqual(
                  sample.vector[dim], expected_X[index][dim], places=6
              )
  
      if spec.kNearestNeighborsClassifier.HasField("int64ClassLabels"):
          for index, label in enumerate(
              spec.kNearestNeighborsClassifier.int64ClassLabels.vector
          ):
              self.assertEqual(label, expected_y[index])
  
      elif spec.kNearestNeighborsClassifier.HasField(
          "stringClassLabels"
      ):
          for index, label in enumerate(
              spec.kNearestNeighborsClassifier.stringClassLabels.vector
          ):
              self.assertEqual(label, expected_y[index])
  
imports: import os
  import shutil
  from coremltools.models.utils import _is_macos
  import unittest
  from coremltools.models import MLModel
  from coremltools.models.nearest_neighbors import KNearestNeighborsClassifierBuilder
  from coremltools._deps import _HAS_SKLEARN
label_desc: Use image node_id 21 for calling the NearestNeighborsBuilderTest obj's underlying member method code with example usage: obj._validate_samples(spec, expected_X, expected_y) without return types