class_docstr: An trained model that is ready to use for similarity. This model should not
  be constructed directly.
class_docstr_tok: ["An","trained","model","that","is","ready","to","use","for","similarity",".","This","model","should","not","be","constructed","directly","."]
docstr: For each image, retrieve the nearest neighbors from the model's stored
  data. In general, the query dataset does not need to be the same as
  the reference data stored in the model.
  
  Parameters
  ----------
  dataset : SFrame | SArray | turicreate.Image
      Query data.
      If dataset is an SFrame, it must contain columns with the same
      names and types as the features used to train the model.
      Additional columns are ignored.
  
  label : str, optional
      Name of the query SFrame column with row labels. If 'label' is not
      specified, row numbers are used to identify query dataset rows in
      the output SFrame.
  
  k : int, optional
      Number of nearest neighbors to return from the reference set for
      each query observation. The default is 5 neighbors, but setting it
      to ``None`` will return all neighbors within ``radius`` of the
      query point.
  
  radius : float, optional
      Only neighbors whose distance to a query point is smaller than this
      value are returned. The default is ``None``, in which case the
      ``k`` nearest neighbors are returned for each query point,
      regardless of distance.
  
  verbose: bool, optional
      If True, print progress updates and model details.
  
  batch_size : int, optional
      If you are getting memory errors, try decreasing this value. If you
      have a powerful computer, increasing this value may improve performance.
  
  Returns
  -------
  out : SFrame
      An SFrame with the k-nearest neighbors of each query observation.
      The result contains four columns: the first is the label of the
      query observation, the second is the label of the nearby reference
      observation, the third is the distance between the query and
      reference observations, and the fourth is the rank of the reference
      observation among the query's k-nearest neighbors.
  
  See Also
  --------
  similarity_graph
  
  Notes
  -----
  - If both ``k`` and ``radius`` are set to ``None``, each query point
    returns all of the reference set. If the reference dataset has
    :math:`n` rows and the query dataset has :math:`m` rows, the output
    is an SFrame with :math:`nm` rows.
  
  Examples
  --------
  >>> model.query(queries, 'label', k=2)
  +-------------+-----------------+----------------+------+
  | query_label | reference_label |    distance    | rank |
  +-------------+-----------------+----------------+------+
  |      0      |        2        | 0.305941170816 |  1   |
  |      0      |        1        | 0.771556867638 |  2   |
  |      1      |        1        | 0.390128184063 |  1   |
  |      1      |        0        | 0.464004310325 |  2   |
  |      2      |        0        | 0.170293863659 |  1   |
  |      2      |        1        | 0.464004310325 |  2   |
  +-------------+-----------------+----------------+------+
docstr_tok: ["For","each","image",",","retrieve","the","nearest","neighbors","from","the","model","'s","stored","data",".","In","general",",","the","query","dataset","does","not","need","to","be","the","same","as","the","reference","data","stored","in","the","model",".","Parameters","--","--","--","--","--","dataset",":","SFrame","|","SArray","|","turicreate.Image","Query","data",".","If","dataset","is","an","SFrame",",","it","must","contain","columns","with","the","same","names","and","types","as","the","features","used","to","train","the","model",".","Additional","columns","are","ignored",".","label",":","str",",","optional","Name","of","the","query","SFrame","column","with","row","labels",".","If","'label","'","is","not","specified",",","row","numbers","are","used","to","identify","query","dataset","rows","in","the","output","SFrame",".","k",":","int",",","optional","Number","of","nearest","neighbors","to","return","from","the","reference","set","for","each","query","observation",".","The","default","is","5","neighbors",",","but","setting","it","to","``","None","``","will","return","all","neighbors","within","``","radius","``","of","the","query","point",".","radius",":","float",",","optional","Only","neighbors","whose","distance","to","a","query","point","is","smaller","than","this","value","are","returned",".","The","default","is","``","None","``",",","in","which","case","the","``","k","``","nearest","neighbors","are","returned","for","each","query","point",",","regardless","of","distance",".","verbose",":","bool",",","optional","If","True",",","print","progress","updates","and","model","details",".","batch_size",":","int",",","optional","If","you","are","getting","memory","errors",",","try","decreasing","this","value",".","If","you","have","a","powerful","computer",",","increasing","this","value","may","improve","performance",".","Returns","--","--","--","-","out",":","SFrame","An","SFrame","with","the","k-nearest","neighbors","of","each","query","observation",".","The","result","contains","four","columns",":","the","first","is","the","label","of","the","query","observation",",","the","second","is","the","label","of","the","nearby","reference","observation",",","the","third","is","the","distance","between","the","query","and","reference","observations",",","and","the","fourth","is","the","rank","of","the","reference","observation","among","the","query","'s","k-nearest","neighbors",".","See","Also","--","--","--","--","similarity_graph","Notes","--","--","-","-","If","both","``","k","``","and","``","radius","``","are","set","to","``","None","``",",","each","query","point","returns","all","of","the","reference","set",".","If","the","reference","dataset","has",":","math",":","`","n","`","rows","and","the","query","dataset","has",":","math",":","`","m","`","rows",",","the","output","is","an","SFrame","with",":","math",":","`","nm","`","rows",".","Examples","--","--","--","--",">",">",">","model.query","(","queries",",","'label","'",",","k=2",")","+","--","--","--","--","--","--","-+","--","--","--","--","--","--","--","--","-+","--","--","--","--","--","--","--","--","+","--","--","--","+","|","query_label","|","reference_label","|","distance","|","rank","|","+","--","--","--","--","--","--","-+","--","--","--","--","--","--","--","--","-+","--","--","--","--","--","--","--","--","+","--","--","--","+","|","0","|","2","|","0.305941170816","|","1","|","|","0","|","1","|","0.771556867638","|","2","|","|","1","|","1","|","0.390128184063","|","1","|","|","1","|","0","|","0.464004310325","|","2","|","|","2","|","0","|","0.170293863659","|","1","|","|","2","|","1","|","0.464004310325","|","2","|","+","--","--","--","--","--","--","-+","--","--","--","--","--","--","--","--","-+","--","--","--","--","--","--","--","--","+","--","--","--","+"]
code: def query(
      self,
      dataset,
      label=None,
      k=5,
      radius=None,
      verbose=True,
      batch_size=64,
  ):
      """
      For each image, retrieve the nearest neighbors from the model's stored
      data. In general, the query dataset does not need to be the same as
      the reference data stored in the model.
  
      Parameters
      ----------
      dataset : SFrame | SArray | turicreate.Image
          Query data.
          If dataset is an SFrame, it must contain columns with the same
          names and types as the features used to train the model.
          Additional columns are ignored.
  
      label : str, optional
          Name of the query SFrame column with row labels. If 'label' is not
          specified, row numbers are used to identify query dataset rows in
          the output SFrame.
  
      k : int, optional
          Number of nearest neighbors to return from the reference set for
          each query observation. The default is 5 neighbors, but setting it
          to ``None`` will return all neighbors within ``radius`` of the
          query point.
  
      radius : float, optional
          Only neighbors whose distance to a query point is smaller than this
          value are returned. The default is ``None``, in which case the
          ``k`` nearest neighbors are returned for each query point,
          regardless of distance.
  
      verbose: bool, optional
          If True, print progress updates and model details.
  
      batch_size : int, optional
          If you are getting memory errors, try decreasing this value. If you
          have a powerful computer, increasing this value may improve performance.
  
      Returns
      -------
      out : SFrame
          An SFrame with the k-nearest neighbors of each query observation.
          The result contains four columns: the first is the label of the
          query observation, the second is the label of the nearby reference
          observation, the third is the distance between the query and
          reference observations, and the fourth is the rank of the reference
          observation among the query's k-nearest neighbors.
  
      See Also
      --------
      similarity_graph
  
      Notes
      -----
      - If both ``k`` and ``radius`` are set to ``None``, each query point
        returns all of the reference set. If the reference dataset has
        :math:`n` rows and the query dataset has :math:`m` rows, the output
        is an SFrame with :math:`nm` rows.
  
      Examples
      --------
      >>> model.query(queries, 'label', k=2)
      +-------------+-----------------+----------------+------+
      | query_label | reference_label |    distance    | rank |
      +-------------+-----------------+----------------+------+
      |      0      |        2        | 0.305941170816 |  1   |
      |      0      |        1        | 0.771556867638 |  2   |
      |      1      |        1        | 0.390128184063 |  1   |
      |      1      |        0        | 0.464004310325 |  2   |
      |      2      |        0        | 0.170293863659 |  1   |
      |      2      |        1        | 0.464004310325 |  2   |
      +-------------+-----------------+----------------+------+
      """
      from array import array
  
      if not isinstance(
          dataset, (_tc.SFrame, _tc.SArray, _tc.Image, array)
      ):
          raise TypeError(
              "dataset must be either an SFrame, SArray or turicreate.Image"
          )
      if batch_size < 1:
          raise ValueError(
              "'batch_size' must be greater than or equal to 1"
          )
  
      if isinstance(dataset, _tc.SArray):
          dataset = _tc.SFrame({self.feature: dataset})
      elif isinstance(dataset, (_tc.Image, array)):
          dataset = _tc.SFrame({self.feature: [dataset]})
  
      extracted_features = self._extract_features(
          dataset, verbose=verbose, batch_size=batch_size
      )
      if label is not None:
          extracted_features[label] = dataset[label]
      return self.similarity_model.query(
          extracted_features, label, k, radius, verbose
      )
  
imports: from __future__ import print_function
  from __future__ import division
  from __future__ import absolute_import
  import time
  import turicreate
  from turicreate.toolkits._model import CustomModel
  import turicreate.toolkits._internal_utils
  from turicreate.toolkits._main import ToolkitError
  from turicreate.toolkits._model import PythonProxy
  from .._internal_utils import _mac_ver
  from ..None import _pre_trained_models
  from ..None import _image_feature_extractor
  from ..image_analysis import image_analysis
label_desc: Use image node_id 10 for calling the ImageSimilarityModel obj's underlying member method code with example usage: obj.query(dataset, label, k, radius, verbose, batch_size) and returns: self