class_docstr: Construct a CoreML KNearestNeighborsClassifier specification.
  
  Please see the Core ML Nearest Neighbors protobuf message for more information
  on KNearestNeighborsClassifier parameters.
  
  Examples
  --------
  .. sourcecode:: python
  
      from coremltools.models.nearest_neighbors import KNearestNeighborsClassifierBuilder
      from coremltools.models.utils import save_spec
  
      # Create a KNearestNeighborsClassifier model that takes 4-dimensional input data and outputs a string label.
      >>> builder = KNearestNeighborsClassifierBuilder(input_name='input',
      ...                                              output_name='output',
      ...                                              number_of_dimensions=4,
      ...                                              default_class_label='default_label')
  
      # save the spec by the builder
      >>> save_spec(builder.spec, 'knnclassifier.mlmodel')
      
docstr: Set the numberOfNeighbors parameter for the KNearestNeighborsClassifier model.
  
  Parameters
  ----------
  allowed_range
          Tuple of (``min_value``, ``max_value``) defining the range of allowed values.
  
  allowed_values
          Set of allowed values for the number of neighbors.
  
  Returns
  -------
  None
docstr_tok: ["Set","the","numberOfNeighbors","parameter","for","the","KNearestNeighborsClassifier","model",".","Parameters","--","--","--","--","--","allowed_range","Tuple","of","(","``","min_value","``",",","``","max_value","``",")","defining","the","range","of","allowed","values",".","allowed_values","Set","of","allowed","values","for","the","number","of","neighbors",".","Returns","--","--","--","-","None"]
code: def set_number_of_neighbors_with_bounds(
      self, number_of_neighbors, allowed_range=None, allowed_set=None
  ):
      """
      Set the numberOfNeighbors parameter for the KNearestNeighborsClassifier model.
  
      Parameters
      ----------
      allowed_range
              Tuple of (``min_value``, ``max_value``) defining the range of allowed values.
  
      allowed_values
              Set of allowed values for the number of neighbors.
  
      Returns
      -------
      None
      """
      if number_of_neighbors <= 0:
          raise ValueError("number_of_neighbors must be > 0")
      if allowed_range is None and allowed_set is None:
          raise ValueError(
              "Exactly one of allowed_range or allowed_values must be provided"
          )
      if allowed_range is not None and allowed_set is not None:
          raise ValueError(
              "Exactly one of allowed_range or allowed_values must be provided"
          )
  
      if allowed_range is not None:
          if not isinstance(allowed_range, tuple):
              raise TypeError(
                  "allowed_range expects a tuple of (min_value, max_value)"
              )
          if len(allowed_range) != 2:
              raise TypeError(
                  "allowed_range expects a tuple of (min_value, max_value)"
              )
  
          (min_value, max_value) = allowed_range
          if min_value <= 0:
              raise ValueError("allowed_range minimum must be > 0")
          if max_value < min_value:
              raise ValueError(
                  "allowed_range max_value must be >= min_value"
              )
          if (
              number_of_neighbors < min_value
              or number_of_neighbors > max_value
          ):
              raise ValueError(
                  "number_of_neighbors is not within allowed range"
              )
  
          self.spec.kNearestNeighborsClassifier.numberOfNeighbors.defaultValue = (
              number_of_neighbors
          )
          self.spec.kNearestNeighborsClassifier.numberOfNeighbors.range.minValue = (
              min_value
          )
          self.spec.kNearestNeighborsClassifier.numberOfNeighbors.range.maxValue = (
              max_value
          )
  
      elif allowed_set is not None:
          if not isinstance(allowed_set, set):
              raise TypeError("allowed_values expects 'set' type")
          if len(allowed_set) == 0:
              raise TypeError("allowed_values cannot be empty")
  
          found_match = False
          for v in allowed_set:
              if not self._is_valid_number_type(v):
                  raise TypeError(
                      "allowed_values must contain only integer types"
                  )
              if v <= 0:
                  raise TypeError(
                      "allowed_values must only contain values > 0"
                  )
              if number_of_neighbors == v:
                  found_match = True
  
          if found_match:
              self.spec.kNearestNeighborsClassifier.numberOfNeighbors.defaultValue = (
                  number_of_neighbors
              )
              for v in allowed_set:
                  self.spec.kNearestNeighborsClassifier.numberOfNeighbors.set.values.append(
                      v
                  )
          else:
              raise ValueError(
                  "number_of_neighbors is not a valid value"
              )
  
imports: import numpy
  import coremltools
  from ...proto import FeatureTypes_pb2
  from ..None import datatypes
label_desc: Use image node_id 18 for calling the KNearestNeighborsClassifierBuilder obj's underlying member method code with example usage: obj.set_number_of_neighbors_with_bounds(number_of_neighbors, allowed_range, allowed_set) without return types